fix: release accelerator model refs during cleanup#1321
Merged
kcz358 merged 1 commit intoMay 6, 2026
Merged
Conversation
kcz358
approved these changes
May 6, 2026
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.
Summary
lmms.clean()by callingAccelerator.free_memory()when an accelerator is attached.nn.Moduleattributes are deleted.In scope
lmms_eval/api/model.pyso base model cleanup clears Accelerate internal model references before existing module deletion, garbage collection, and CUDA cache clearing.test/models/test_model_cleanup.pyto verify cleanup callsfree_memory()and removes direct model attributes.Out of scope
llava_onevision1_5; the fix applies through the shared base cleanup path.Validation
python -m compileall -q lmms_eval/api/model.py test/models/test_model_cleanup.py| sample size:N=2 files| key metrics:syntax/import bytecode compilation| result:passpython -m pytest -q test/models/test_model_cleanup.py| sample size:N=1 test| key metrics:accelerator model references released during clean()| result:pass(1 passed in 3.47s)Risk / Compatibility
free_memory()clears Accelerate internal references before the existing direct module cleanup and CUDA cache clearing, reducing rank memory pressure before postprocessing/gathering.Type of Change