fix: vision loss forward pass falls back to exclude on crash#223
Merged
Conversation
Qwen3's vision-language merge changes internal sequence length unpredictably. Both include and checkpoint modes crash intermittently with attention mask mismatches (mask too large OR too small depending on generated sequence length). Fix: catch IndexError/RuntimeError from the vision forward pass and retry with exclude mode (text-only, no vision tensors) for that step. Training never crashes — some steps get vision-aware gradients, some get text-only gradients, but all steps contribute to learning. This is the pragmatic fix. The proper fix (capturing logits during generation to avoid re-forward entirely) is future work. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
abrichr
added a commit
that referenced
this pull request
Mar 29, 2026
Root cause: manually concatenating action_ids onto prompt input_ids created inconsistent input (pixel_values sized for prompt, input_ids includes action tokens). Qwen3's vision merge changes internal sequence length, crashing with attention mask mismatches. Fix: process prompt_text + action_text as a SINGLE string through the processor. Produces consistent input_ids, pixel_values, attention_mask. The model handles vision merge correctly on processor output. Replaces the silent fallback from PR #223 with a proper solution that gives correct vision-aware gradients for ALL steps in ALL modes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
abrichr
added a commit
that referenced
this pull request
Mar 29, 2026
Root cause: manually concatenating action_ids onto prompt input_ids created inconsistent input (pixel_values sized for prompt, input_ids includes action tokens). Qwen3's vision merge changes internal sequence length, crashing with attention mask mismatches. Fix: process prompt_text + action_text as a SINGLE string through the processor. Produces consistent input_ids, pixel_values, attention_mask. The model handles vision merge correctly on processor output. Replaces the silent fallback from PR #223 with a proper solution that gives correct vision-aware gradients for ALL steps in ALL modes. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
Qwen3's vision merge changes sequence length unpredictably. Both
includeandcheckpointmodes crash intermittently with attentionmask mismatches. This killed 3 training runs on step 5.
Fix: catch the error and retry with
excludemode for that step.Training never crashes. Some steps get vision gradients, some don't,
but all contribute to learning.
🤖 Generated with Claude Code