Repository navigation
Free the model when the backend sends UnloadModel - #36
Merged
Merged
Conversation
The backend sends UnloadModel when no model the organization permits fits the node - e.g. it disabled the only one. The client only logged it, so the model stayed resident and the app showed Ready while the backend counted the node as serving nothing. reload::unload drains in-flight generations, frees the model and resumes accepting; the handler holds model_switch so an unload cannot land mid-switch, and sets the status to NoModel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The backend sends
UnloadModelwhen no model the organization permits fits the node, for example when it disables the only model.ServerAction::Unloadonly logged "not handled by this build". So the model stayed loaded and the app kept showing Ready, while the backend had closed the node's serving row and counted it as serving nothing. The node and the platform disagreed.Change
reload::unload()(src-tauri/src/reload.rs). It lets in-flight generations finish, cancelling any that outlast the drain timeout, then frees the model and accepts work again. It returns whether a model was loaded.ServerAction::Unload(src-tauri/src/grpc_client.rs) now spawnshandle_unload_model. That holdsmodel_switch, so an unload cannot land in the middle of aLoadModelswitch. It then callsreload::unload, setsModelStatus::NoModeland logs the outcome.No new message goes to the backend: it has already closed the rows. When the node is assigned a model again, a normal
LoadModelfollows.Tests
unload_frees_the_model_after_in_flight_generations_finish: the model stays loaded until the in-flight generation finishes. New work is refused while draining and accepted again afterwards.unload_with_nothing_loaded_is_a_no_opLocal runs:
cargo test --workspace --all-targets,cargo clippy --workspace -- -D warningsandcargo fmt --checkall pass. There are no frontend changes, so Playwright was not run.Not covered by tests: whether the UI shows the no-model state, and whether memory is freed on a real node after an unload. Worth a manual check on a release build.
Related
The backend half is nodea-sh/nodea#336: the scheduler now gives an emptied node a model again when one is re-enabled.