Skip to content

Fix Stable Cascade checkpointing crash by using native diffusers checkpointing - #1539

Merged
dxqb merged 1 commit into
Nerogar:mergefrom
dxqb:fix-stable-cascade-checkpointing-1529
Jun 17, 2026
Merged

dxqb merged 1 commit into
Nerogar:mergefrom
dxqb:fix-stable-cascade-checkpointing-1529

Conversation

@dxqb

@dxqb dxqb commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

enable_checkpointing_for_stable_cascade_blocks searched for a homogeneous
nn.ModuleList of a single block type (SDCascadeResBlock / SDCascadeAttnBlock /
SDCascadeTimestepBlock), but StableCascadeUNet's down_blocks/up_blocks
interleave all three block types within the same list by design. The matcher's
assert all(isinstance(m, t) for m in child_module) therefore always failed once
it found the first matching list, crashing on startup whenever checkpointing was
enabled for the prior.

This workaround predates diffusers' own gradient-checkpointing support for Stable
Cascade (it was written when the model still relied on the older Wuerstchen pipeline
code without enable_gradient_checkpointing()). diffusers' StableCascadeUNet now
supports native gradient checkpointing with correct per-block-type dispatch
internally, so this switches to model.prior_prior.enable_gradient_checkpointing(),
the same call already used for Wuerstchen v2, and removes the now-unused custom
matcher function.

Fixes #1529

Drafted by Claude

…kpointing

enable_checkpointing_for_stable_cascade_blocks searched for a homogeneous
nn.ModuleList of a single block type, but StableCascadeUNet's down_blocks/
up_blocks interleave SDCascadeResBlock, SDCascadeTimestepBlock, and
SDCascadeAttnBlock in the same list, so the homogeneity assert always
failed when checkpointing was enabled. diffusers' StableCascadeUNet
already supports native gradient checkpointing with correct per-block-type
dispatch, so use model.prior_prior.enable_gradient_checkpointing()
instead, matching how Wuerstchen v2 is already handled.

Fixes Nerogar#1529

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dxqb dxqb added the preview merged in the preview branch label Jun 17, 2026
@dxqb
dxqb changed the base branch from master to merge June 17, 2026 20:05
@dxqb
dxqb merged commit 138e0db into Nerogar:merge Jun 17, 2026
1 check passed
@dxqb
dxqb deleted the fix-stable-cascade-checkpointing-1529 branch June 17, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview merged in the preview branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: StableCascade training is broken

1 participant