Repository navigation
Disengage FBCache on the word of whoever owns it - #11304
Conversation
test_video_backend.py::test_video_step_cache_auto_toggles_on_actual_steps is red on main. Bisected: it passes at 9cf1f6e^ and fails at 9cf1f6e (#11174). CI's captured log names the branch outright: diffusion.cache: fbcache disable unavailable (cache hooks could not be verified removed); running uncached #11174 made the auto disengage refuse to clear the marker until the private-name hook sweep confirms the hooks are gone. That is right for the case it was written for: an ADOPTED low-level cache, installed through apply_first_block_cache, leaves _cache_config None, so diffusers' own disable_cache removes nothing and trusting it would clear the marker over live hooks. Clearing it there would let the CUDA graph wrapper capture across them, so "cannot verify" has to mean "still engaged". But the veto was applied unconditionally. When diffusers owns the cache, disable_cache returning without raising IS the evidence: it removed both hooks and cleared the config itself. Requiring the sweep on top makes every disengage depend on diffusers.hooks.first_block_cache staying importable, and where it is not, FBCache stays engaged on short trajectories forever -- the quality regression the auto policy exists to prevent. The veto now applies only where the code's own comment says it is needed. The test's diffusers stub was wrong too, and in a way that hid this: FirstBlockCacheConfig was a lambda returning ("fbcache", threshold). The cache layer matches on type(...).__name__ to tell its own config from a MagCache / PAB one, so a plain tuple read as "some other cache" and made the teardown unverifiable by construction. It is now a class named FirstBlockCacheConfig, as test_diffusion_cache.py already does, and the fake DiT records _cache_config the way diffusers does. Two regression tests cover both directions, since #11174's 618 lines of tests never reached this: its harness always makes the sweep succeed. Sabotage, each half independently necessary: revert the product fix only -> 2 failed (the new test, and the video one) revert the stub only -> 1 failed (the video one) both restored -> 365 passed
|
@codex review |
Codex Review SummaryThis 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 security review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
* Disengage FBCache on the word of whoever owns it test_video_backend.py::test_video_step_cache_auto_toggles_on_actual_steps is red on main. Bisected: it passes at 9cf1f6e^ and fails at 9cf1f6e (unslothai#11174). CI's captured log names the branch outright: diffusion.cache: fbcache disable unavailable (cache hooks could not be verified removed); running uncached unslothai#11174 made the auto disengage refuse to clear the marker until the private-name hook sweep confirms the hooks are gone. That is right for the case it was written for: an ADOPTED low-level cache, installed through apply_first_block_cache, leaves _cache_config None, so diffusers' own disable_cache removes nothing and trusting it would clear the marker over live hooks. Clearing it there would let the CUDA graph wrapper capture across them, so "cannot verify" has to mean "still engaged". But the veto was applied unconditionally. When diffusers owns the cache, disable_cache returning without raising IS the evidence: it removed both hooks and cleared the config itself. Requiring the sweep on top makes every disengage depend on diffusers.hooks.first_block_cache staying importable, and where it is not, FBCache stays engaged on short trajectories forever -- the quality regression the auto policy exists to prevent. The veto now applies only where the code's own comment says it is needed. The test's diffusers stub was wrong too, and in a way that hid this: FirstBlockCacheConfig was a lambda returning ("fbcache", threshold). The cache layer matches on type(...).__name__ to tell its own config from a MagCache / PAB one, so a plain tuple read as "some other cache" and made the teardown unverifiable by construction. It is now a class named FirstBlockCacheConfig, as test_diffusion_cache.py already does, and the fake DiT records _cache_config the way diffusers does. Two regression tests cover both directions, since unslothai#11174's 618 lines of tests never reached this: its harness always makes the sweep succeed. Sabotage, each half independently necessary: revert the product fix only -> 2 failed (the new test, and the video one) revert the stub only -> 1 failed (the video one) both restored -> 365 passed * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The failure
Repo tests (CPU, rest)is red onmain:Bisected: passes at
9cf1f6e24^, fails at9cf1f6e24(#11174). CI's captured log names the branch outright:What #11174 got right, and where it reached too far
#11174 made the auto disengage refuse to clear
_unsloth_step_cacheuntil the private-name hook sweep confirms the hooks are gone. That is correct for the case it was written for: an adopted low-level cache, installed throughapply_first_block_cache, leaves_cache_configasNone, so diffusers' owndisable_cacheremoves nothing. Clearing the marker there would clear it over live hooks, and the marker is what keeps the CUDA graph wrapper eager, so "cannot verify" genuinely has to mean "still engaged".But the veto was applied unconditionally. When diffusers owns the cache,
disable_cache()returning without raising is the evidence: it removed both hooks and cleared_cache_configitself. Requiring the private sweep on top makes every disengage depend ondiffusers.hooks.first_block_cachestaying importable, and on any version where it is not, FBCache stays engaged on short trajectories forever. That is the quality regressionFBCACHE_MIN_STEPSexists to prevent: an 8-step trajectory has almost no headroom, which is the reason the auto bar is there at all.The veto now applies only where the code's own comment says it is needed.
The test's stub was wrong too, and it is what hid this
The cache layer matches on
type(...).__name__to tell its own FBCache config from a MagCache / PAB one. A plain tuple reads as "some other cache", so the teardown was unverifiable by construction. It is now a class namedFirstBlockCacheConfig, exactly astest_diffusion_cache.pyalready does it, and the fake DiT records_cache_configthe way diffusers does.Robustification
Two regression tests, covering both directions. #11174 shipped 618 lines of tests that never reached this, because its harness always makes the sweep succeed; these deliberately make the private names unimportable:
diffusers.hooks.first_block_cacheis gone;fbcache, so the CUDA-graph hazard stays covered.Verification
Sabotage, each half independently necessary:
Full
studio/backend/testsrun, branch vs cleanmain(9f76c5a3e), same host and same-n 8:Diffing the two failure sets: nothing fails only on the branch, and exactly one failure exists only on
main--test_video_step_cache_auto_toggles_on_actual_steps. The remaining 165 and the 200 errors are this workspace's environment (no CUDA runtime for bitsandbytes) and are identical on both sides.