Repository navigation
Stop pinning the gc freeze count in test_external_freeze_is_left_alone - #18237
Merged
Merged
Conversation
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Stop pinning the gc freeze count in test_external_freeze_is_left_alone
tests/test_gc_train_scope.py::test_external_freeze_is_left_alonefailed on aRepo tests (CPU, rest)run whose base already has every recent fix (#18220, a frontend-only PR):Cause
The test freezes the heap itself, runs
train(), and assertsgc.get_freeze_count()is exactly what it was before. That count is not stable. An object in the permanent generation is still freed by refcounting, and CPython drops it from the count when it goes. So any frozen object released whiletrain()runs lowers the count, and the assert fails with no change in behaviour. Here, two objects went.The scope code in
unsloth/models/_gc_train_scope.pyis correct: it leaves a freeze it does not own alone. Only the test's way of checking that is wrong.Fix
The test now checks the claim directly instead of comparing a counter that can move on its own:
gc.collect,gc.freezeandgc.unfreezethrough the scope module, the same waytest_wrapper_captured_after_install_freezes_oncealready does.train()called none of them.train()and after it.A new test,
test_freeze_count_falls_when_a_frozen_object_is_freed, pins the CPython behaviour above. It documents why the count is not compared.Verification
tests/test_gc_train_scope.py: 17 passed.gc.get_freeze_count() > 0early return) fails this test andtest_after_step_needs_an_owned_freeze.gc.unfreeze()on exit fails this test.tests/python/test_accelerator_skip_guards.pyandtests/studio/test_backend_ci_*.pypass, and ruff is clean.