perf(qwen): project only the final token during trainside generation - #442
Merged
Merged
Conversation
HF generate() already sets logits_to_keep=1; the custom trainside loop only reads [:, -1, :] but still projected the full prefill [B, L, vocab].
2 tasks done
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
The Qwen trainside autoregressive loops only sample
logits[:, -1, :], but prefill projected every prompt position throughlm_head. Pass the models' nativelogits_to_keep=1contract so Qwen3, Qwen2.5-VL, and Qwen3.5 materialize only[B, 1, vocab]logits.Qwen3.5 applies the same selection on its cacheless VeOmni path, where the full growing sequence is forwarded each step. Replay remains unchanged because it needs every response-token log-probability.
Related Issue
N/A
Test Plan
ruff check/ruff format --check/python lint/check_docstring_lines.pyon the three changed AR modules — passgenerate()behavior.Compatibility / Risk
No config, checkpoint, state-dict, or public API changes. The repository pins Transformers 5.6, and the HF plus VeOmni Qwen forwards all support
logits_to_keep. Prompts are left-padded, so the final row is each sample's last real token.Reviewer Notes
Open #430 edits
qwen3/ar.pyon the replay exact-actor path, not these generation-loop arguments.Checklist