Skip to content

Fix FDG disabled-level crash and MagCache single-block step reset#21

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-management-51fa
Draft

Fix FDG disabled-level crash and MagCache single-block step reset#21
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-management-51fa

Conversation

@cursor

@cursor cursor Bot commented Jun 28, 2026

Copy link
Copy Markdown

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] with use_original_formulation=True), the disabled-level branch appended pred_cond_freq, which was never assigned for the first disabled level (crash) or was stale from a previous level (wrong reconstruction). The fix uses pred_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_index never advanced and state never reset after num_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 crashes
  • tests/hooks/test_mag_cache.py::test_mag_cache_single_block_step_reset — verifies step reset after two skips

Also includes a tiny check_copies.py change to invoke ruff via python -m ruff so copy checks work when ruff is not on PATH.

Before submitting

  • Did you write any new necessary tests?
Open in Web View Automation 

cursoragent and others added 2 commits June 28, 2026 22:10
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant