Repository navigation
feat(mtp): enable MTP to accept pre-fused input embeddings for multimodal models - #2510
Merged
Merged
Conversation
Signed-off-by: SlyneD <slyned@nvidia.com>
Contributor
|
/ok to test d78fb9a |
Signed-off-by: SlyneD <slyned@nvidia.com>
4 of 7 tasks
Contributor
|
/ok to test fff5d7e |
Contributor
adil-a
reviewed
Jun 16, 2026
Collaborator
|
/claude review |
adil-a
approved these changes
Jun 16, 2026
10 of 24 tasks
This branch was previously deployed
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.
What does this PR do ?
In multimodal LLM training (e.g., SALM), audio/vision positions in the input sequence carry continuous features from a perception encoder that cannot be recovered by re-embedding an integer token id. The existing MTP path assumes all positions have a corresponding token id and uses embed_fn(rolled_input_ids) to produce the future-token signal — this yields embed_fn(padding_id) at every audio position, which is wrong.
This PR adds a second input mode to the MTP forward path: when pre-fused input embeddings are available (e.g., the fused audio+text tensor in SALM), the caller pre-rolls them per depth and passes them as embed_inputs, bypassing embed_fn entirely. Audio positions then carry the correct audio embedding as their future-token signal. The existing input_ids + embed_fn path is unchanged for pure-text models.
Changelog
Before your PR is "Ready for review"
Pre checks:
Additional Information
This fix is required for SALM (Speech and Language Model) training in NeMo, where the input sequence interleaves text tokens and audio frame embeddings. The NeMo-side change (pre-rolling inputs_embeds before calling the LLM) will be submitted in a separate NeMo PR that depends on this one.