Skip to content

fix(qwen3_vl): fix IndexPutBackward0 invalid gradient shape in vision…#100

Open
alexqdh wants to merge 1 commit intoISEEKYAN:mainfrom
alexqdh:fix-indexputbackward-grad-shape
Open

fix(qwen3_vl): fix IndexPutBackward0 invalid gradient shape in vision…#100
alexqdh wants to merge 1 commit intoISEEKYAN:mainfrom
alexqdh:fix-indexputbackward-grad-shape

Conversation

@alexqdh
Copy link
Copy Markdown

@alexqdh alexqdh commented Mar 23, 2026

Problem

IndexPutBackward0 reads the now-stale
mask (sum=225 instead of 224), producing a gradient with the wrong shape.

Error: Function IndexPutBackward0 returned an invalid gradient at index 1 - got [225, 2560] but expected shape compatible with [224, 2560]

In the pure-image / pure-video early-return path of reorganize_inputs(), the THW consistency check present in the mixed (image+video) path is skipped. HF tokenizer placeholder count and image_grid_thw-derived ViT output count can differ by ±1 due to a data preprocessing inconsistency, which propagates silently to IndexPut.

  • utils.py:
    • Add mask-vs-grid_thw alignment in the pure-image and pure-video early-return paths of reorganize_inputs(), mirroring the existing assertion in the mixed path. Trusts image_grid_thw as ground truth and trims any excess True entries from the mask.

… token injection

Problem
-------
IndexPutBackward0 reads the now-stale
mask (sum=225 instead of 224), producing a gradient with the wrong shape.

Error: Function IndexPutBackward0 returned an invalid gradient at
index 1 - got [225, 2560] but expected shape compatible with [224, 2560]

In the pure-image / pure-video early-return path of
reorganize_inputs(), the T*H*W consistency check present in the mixed
(image+video) path is skipped.  HF tokenizer placeholder count and
image_grid_thw-derived ViT output count can differ by ±1 due to a data
preprocessing inconsistency, which propagates silently to IndexPut.

* utils.py:
  - Add mask-vs-grid_thw alignment in the pure-image and pure-video
    early-return paths of reorganize_inputs(), mirroring the existing
    assertion in the mixed path.  Trusts image_grid_thw as ground truth
    and trims any excess True entries from the mask.
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