-
Notifications
You must be signed in to change notification settings - Fork 72
Try to make backend configuration a little more robust. #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If there's no change to the backend config, then there's no need to fail the request on an active runner. Also, if the active runner is unused, then we can evict it and then update its config. Signed-off-by: Jacob Howard <[email protected]>
| // If the configuration hasn't changed, then just return. | ||
| if existingConfig, ok := l.runnerConfigs[runnerId]; ok && reflect.DeepEqual(runnerConfig, existingConfig) { | ||
| l.log.Infof("Configuration for %s runner for model %s unchanged", backendName, model) | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silvin-lubecki I think this path should handle your case without eviction (we can look at eviction disablement or configuration in a separate PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is good, but I think we should avoid using DeepEqual if possible. Looking at the inference.BackendConfiguration type, it's simple enough we can add an Equal method:
import "slices"
func (b *BackendConfiguration) Equals(other *BackendConfiguration) bool {
return b.ContextSize == other.ContextSize &&
slices.Equal(b.RawFlags, other.RawFlags)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a risk to DeepEqual? It feels like there's a bigger risk if someone forgets to update Equals when they add a new field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point about the maintenance risk! That's definitely a valid concern.
However, I think an explicit Equals method would be beneficial here for a couple of reasons:
Explicitness and readability: With only 2 fields (ContextSize and RawFlags), the comparison logic is clear. For such a simple struct, the Equals method is just 2 lines with slices.Equal.
Type safety: reflect.DeepEqual accepts any types and will silently return false for type mismatches, which could mask bugs during refactoring.
For the maintenance concern, we could add a focused test:
func TestBackendConfigurationEquals(t *testing.T) {
base := &BackendConfiguration{ContextSize: 100, RawFlags: []string{"--flag"}}
// Test each field difference
different := *base
different.ContextSize = 200
require.False(t, base.Equals(&different))
different = *base
different.RawFlags = []string{"--other"}
require.False(t, base.Equals(&different))
}This way, adding a new field without updating Equals would likely be caught by the test.
That said, DeepEqual works perfectly fine for this use case too - what's your preference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave it @p1-0tr to decide since he's sort of the CODEOWNER here 😉. I tend to lean towards less code = less maintenance. I don't see a risk with differing types since everything here is statically typed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if that helps, but it seems the type can be safely compared with ==.
Sorry, looked at the wrong thing. Definitely not comparable with ==.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike reflection as a matter of principle. But in this case I don't mind the DeepEquals, because it keeps the code simple and small, and it will likely disappear once we implement proper runner configuration management.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, I won't block on this 😄 I think I join @p1-0tr on this, I raised it as a matter of principle. And if it's temporary, then LGTM ✅
silvin-lubecki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
context: Detect DD based on the OS and allow WSL2 client
If there's no change to the backend config, then there's no need to fail the request on an active runner. Also, if the active runner is unused, then we can evict it and then update its config.