Skip to content

minimal reproduction of token superposition training#5645

Draft
giganttheo wants to merge 3 commits into
NVIDIA:mainfrom
giganttheo:tst
Draft

minimal reproduction of token superposition training#5645
giganttheo wants to merge 3 commits into
NVIDIA:mainfrom
giganttheo:tst

Conversation

@giganttheo

Copy link
Copy Markdown
  • [*] I, the PR author, have personally reviewed every line of this PR.

What does this PR do?

⚠️ For major changes (either in lines of code or in its impact), please make sure to first share a design doc with the team. If you're unsure what's the best way to do so, contact @NVIDIA/mcore-oncall.

Issue tracking

For PRs from open-source community contributors:

  • New features: a linked issue is required. Please open a feature request and reference it here before submitting the PR.
  • Small updates (bug fixes, minor improvements): a linked issue is recommended and will accelerate the PR review process.

Linked issue:

Contribution process

Pre-checks

  • I have added relevant unit tests
  • I have added relevant functional tests
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Code review

Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!

All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.

Step 1: Mark PR as "Ready for Review"

  1. When your PR is ready, click Ready for Review.
  2. An oncall reviewer is auto-assigned and expert reviewers are notified based on your changes.
    • Some PRs may jump straight to step 2. This is determined by .github/CODEOWNERS.

⚠️ Only mark as ready once merge-conflicts are resolved and the CI is passing.
Final Review might get declined if these requirements are not fulfilled.

Step 2: Final Review

For PRs that change megatron/core, once all expert reviewers have approved, the Final Review label is applied automatically and final reviewers are assigned.

For PRs outside megatron/core, this step is skipped.

Step 3: Approved

Once all required reviewers have approved, the Approved label is applied automatically.

Merge

Any member of mcore-engineers will be able to merge your PR.

@copy-pr-bot

copy-pr-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@bloc97

bloc97 commented Jul 3, 2026

Copy link
Copy Markdown

Token superposition patch notes

This prototype adds one parameter-free training mode to HybridModel:

--token-superposition-size S

S=1 is the unchanged baseline. S>1 averages each non-overlapping bag of S token embeddings and averages ordinary vocabulary-parallel cross entropy over the S labels in the next bag.

Stage 1 example

For baseline processed length 4096 and bag size 6:

--train-iters 100000 \
--exit-interval 5000 \
--save /checkpoints/my_run \
--token-superposition-size 6 \
--seq-length 24576 \
--max-position-embeddings 24576 \
--no-create-attention-mask-in-dataloader

The decoder receives 4096 latent positions. Stop and save at the desired phase boundary using Megatron's normal checkpoint options.

Stage 2 example

Resume the same checkpoint with:

--train-iters 100000 \
--load /checkpoints/my_run \
--save /checkpoints/my_run \
--token-superposition-size 1 \
--seq-length 4096 \
--max-position-embeddings 24576

Keep --max-position-embeddings large enough for the stage-1 raw sequence in both phases. Do not use --use-checkpoint-args if it restores the stage-1 --seq-length or token-superposition size over the new command-line values.

Deliberate first-pass restrictions

The implementation raises an error for pipeline parallelism, context parallelism, packed/SFT sequences, explicit attention masks, padding masks, learned absolute position embeddings, and Megatron MTP. Tensor, data, expert, and sequence parallel paths are left intact. The implementation has been syntax-checked and its loss indexing was numerically checked against the paper's padded-reference formulation, but it has not been executed as a full distributed Megatron training job in this environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants