Skip to content

Unpack DiT block output tuple in the non-checkpointed training branch - #86

Open
jeqcho wants to merge 1 commit into
dreamzero0:mainfrom
jeqcho:fix-grad-disabled-block-unpack
Open

Unpack DiT block output tuple in the non-checkpointed training branch#86
jeqcho wants to merge 1 commit into
dreamzero0:mainfrom
jeqcho:fix-grad-disabled-block-unpack

Conversation

@jeqcho

@jeqcho jeqcho commented Aug 7, 2026

Copy link
Copy Markdown

Fixes #85.

Blocks return (x, kv_cache); only the checkpointed branch unpacked it, so running the training forward with gradients disabled handed a tuple to the next block. This unpacks it in the non-checkpointed branch as well, with an assert that the cache slot is unused on this path.

Validated during a 12k-step LoRA fine-tune of DreamZero-AgiBot on bimanual YAM data (https://github.com/robocurve/dreamzero-yam, released at https://huggingface.co/robocurve/dreamzero-yam-molmoact2): the grad-disabled forward scored every 500-step milestone, and the deterministic val/loss it produced matched training loss behavior throughout. Checkpointed and grad-enabled paths are untouched.

Transformer blocks return (x, kv_cache). Only the gradient-checkpointing
branch unpacked the tuple, so running the training forward under
torch.no_grad() handed a tuple to the next block and crashed. Unpack it
in the non-checkpointed branch too.
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.

Training forward crashes under torch.no_grad() (DiT block output tuple not unpacked)

1 participant