Repository navigation
Tests: follow the NF4 dequant cache into the for_inference and fp8 backward harnesses - #18368
Merged
Merged
Conversation
…ckward harnesses #18285 added two call paths the CPU harnesses could not follow: - for_inference now does from ..kernels.dequant_cache import clear_dequant_cache. _fast_base_model execs the lifted methods in a namespace with no package, so 14 tests fail with KeyError: '__name__' not in globals. Relative imports in the lifted bodies now resolve through an explicit stub table; one a fake reaches without a stub fails naming the import. - The LoRA backward dequantizes through dequant_cache.dequantize, which reads fast_dequantize from kernels.utils at call time, so the fp8 fixture's fast_lora patch no longer reached it and 2 tests hit the real Triton driver. Patch it in kernels.utils too.
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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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.
Summary
Sixteen tests in the CPU "rest" shard fail on main since #18285, in two groups:
Seen on the staging run for #17742, which does not touch these files.
Cause
#18285 keeps dequantized NF4 LoRA base weights in a cache. Both new call paths are correct; the CPU harnesses could not follow them.
FastBaseModel.for_inference(unsloth/models/vision.py) now clears that cache with an inlinefrom ..kernels.dequant_cache import clear_dequant_cache._fast_base_model()intest_return_logits_survives_for_training.pyliftsfor_inference/for_trainingout of the source and execs them in a namespace with no package. A relative import there raisesKeyError: '__name__' not in globals. The harness already stubbed whole helpers for this reason, but this import sits in the lifted method itself.dequant_cache.dequantize. That function readsfast_dequantizefromkernels.utilswhen called. The fp8 fixture only patchedfast_lora.fast_dequantize, so the real Triton path ran on a CPU runner. For an fp8 quant state,dequantizefalls straight through tofast_dequantize, so production behaviour is unchanged.Fix
Test-only:
_fast_base_model()rewrites each relativefrom ..x import ain the lifted bodies toa = _relative_import("x", "a"), resolved from an explicit stub table. The table starts withclear_dequant_cacheas a no-op. Guarded imports the fakes never reach still need no stub. One that a fake does reach without a stub fails withstub the relative import ('kernels.dequant_cache', 'clear_dequant_cache') lifted from unsloth/models, so the next inline import says what to add instead of surfacing as aKeyError.fast_dequantizeinkernels.utilsas well as infast_lora.Verification
kernels.utilspatch removed (sabotage)0 active driversruff is clean.
The 17th failure in that shard,
test_grpo_autocast_disabled.py::test_reading_it_tolerates_an_older_trainer, has a different cause (#18335) and is handled separately.