Fix FDG disabled-level crash and MagCache single-block step reset#21
Draft
cursor[bot] wants to merge 2 commits into
Draft
Fix FDG disabled-level crash and MagCache single-block step reset#21cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
FrequencyDecoupledGuidance appended pred_cond_freq in the disabled-level else branch, causing NameError when the first level was disabled and stale values when later levels were disabled. Use pred_cond_pyramid[level] instead. MagCache single-block models never advanced step_index on cache skips because the head hook returned early without invoking the co-located tail hook. Advance step state from the head hook skip path for single-block setups. Co-authored-by: Simon Lynch <srlynch1@users.noreply.github.com>
Co-authored-by: Simon Lynch <srlynch1@users.noreply.github.com>
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.
What does this PR do?
Fixes two critical correctness bugs in guidance/cache code paths.
FrequencyDecoupledGuidance NameError / stale pyramid levels
When a frequency level was disabled (e.g.
guidance_scales=[0.0, 7.5]withuse_original_formulation=True), the disabled-level branch appendedpred_cond_freq, which was never assigned for the first disabled level (crash) or was stale from a previous level (wrong reconstruction). The fix usespred_cond_pyramid[level]as intended by the comment.MagCache single-block step_index stuck on skip
Single-block transformers register both head and tail hooks on the same block. On cache skips, the head hook returns early without invoking the tail hook, so
step_indexnever advanced and state never reset afternum_inference_steps. This caused wrong outputs on subsequent inference cycles (e.g. step 2 output 22.0 instead of 24.0). The fix advances step state from the head hook skip path when head/tail are co-located.Tests
tests/guiders/test_frequency_decoupled_guidance.py— disabled first level no longer crashestests/hooks/test_mag_cache.py::test_mag_cache_single_block_step_reset— verifies step reset after two skipsAlso includes a tiny
check_copies.pychange to invoke ruff viapython -m ruffso copy checks work whenruffis not on PATH.Before submitting