Skip to content

feat(vllm): MTP spec dec inference for nemotron super/ultra with refit drafter - #2999

Merged
yfw merged 15 commits into
mainfrom
yifu/super_mtp_rebased
Jul 22, 2026
Merged

yfw merged 15 commits into
mainfrom
yifu/super_mtp_rebased

Conversation

@yfw

@yfw yfw commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor
  • vLLM backend/worker support for MTP spec-decode for nemotron super/ultra (drafter arrives via refit)
  • super_launch.sh: ENABLE_MTP_INFERENCE gating (prefix caching off, chunked prefill, mamba_cache_mode=align, drop cudagraph sizes, speculative_config)
  • spec-decode acceptance metrics wired into async_grpo_train
  • detect MTP training (trains_mtp) in run_grpo_nemo_gym.py
  • Note: the current version of vllm we are using (0.20.0) shows high logprob errors when mtp inference is enabled with prefix caching. The current workaround is to disable prefix caching when mtp inference is enabled.

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

- vLLM backend/worker support for MTP spec-decode (drafter arrives via refit)
- super_launch.sh: ENABLE_MTP_INFERENCE gating (prefix caching off, chunked
  prefill, mamba_cache_mode=align, drop cudagraph sizes, speculative_config)
- spec-decode acceptance metrics wired into async_grpo_train
- detect MTP training (trains_mtp) in run_grpo_nemo_gym.py

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw
yfw requested review from a team as code owners June 30, 2026 00:37
@copy-pr-bot

copy-pr-bot Bot commented Jun 30, 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.

@youngeunkwon0405
youngeunkwon0405 self-requested a review June 30, 2026 05:19
yfw and others added 3 commits July 16, 2026 13:05
Resolve conflicts:
- vllm_backend.py: keep the class-level _mtp_drafter_from_disk attribute alongside
  main's bind_numa(); in update_weights_from_collective run main's
  process_weights_after_loading for the main model then the MTP drafter finalize.
- run_grpo_nemo_gym.py: keep the trains_mtp/has_refit_draft_weights wiring inside
  main's rl_init_timer.time("tokenizer") block.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
Unit-test the refit-into-drafter path added for co-trained MTP speculative
decoding, using the existing mocked-drafter harness (no GPU):

- _mtp_drafter_refit_enabled: gating matrix over spec method (mtp/deepseek_mtp
  vs eagle3/none), disk-load flag, and drafter presence.
- _maybe_refit_mtp_drafter: feeds vocab-trimmed policy weights to the drafter
  when enabled; no-op for the disk-load path and non-MTP drafters.
- _maybe_process_mtp_drafter_after_loading: finalizes against the draft model
  config when enabled; skipped for the disk-load path.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
…emotron-3-Super 120B

Add MTP-inference variants of the Nemotron-3-Super 120B-A12B GRPO recipes so
the co-trained MTP drafter refit path is exercised on both weight transports:

- grpo-nemotron3-super-120BA12B-16n8g-megatron-mtp: inherits the base recipe
  (already trains MTP) and enables speculative_config.method=mtp. Colocated ->
  IPC refit transport.
- grpo-nemotron3-super-120BA12B-8n4g-megatron-mtp: additionally co-trains the
  MTP layer (mtp_num_layers=5, matching 16n8g) so the drafter is refit rather
  than disk-loaded. Non-colocated -> collective refit transport.

Both keep load_format=dummy: trains_mtp=True routes the MTP weights through
refit. Drivers mirror the base ones with extra startup headroom for the MTP
drafter compile, and both are added to nightly.txt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw
yfw requested a review from a team as a code owner July 16, 2026 20:09
@yfw yfw added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Jul 16, 2026
@yfw

yfw commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 6a0d514

yfw and others added 2 commits July 17, 2026 05:00
…3-Super 120B math recipes

Fold MTP speculative-decoding inference into the existing 16n8g and 8n4g
Nemotron-3-Super math recipes instead of shipping separate -mtp recipes and
drivers (removed):

- 16n8g already co-trains the MTP layer; add speculative_config.method=mtp
  plus prefix caching / chunked prefill / mamba_cache_mode=align.
- 8n4g additionally co-trains the MTP layer (mtp_num_layers=5) so the vLLM
  drafter is refreshed via refit (non-colocated / collective transport).

Validated end-to-end on GB200 8n4g: MTP speculative decoding active with ~44%
draft acceptance (mean accept length 3.21).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
…ecipe

The colocated 16n8g recipe (gpu_memory_utilization=0.5 shared with training)
leaves vLLM limited memory on H100, yielding fewer Mamba cache blocks than
vLLM's default max_num_seqs=1024. With mamba_cache_mode=align each decode
sequence needs one Mamba block, so CUDA graph capture fails. Cap at
max_num_seqs=16, matching the proven Nemotron-3-Super H100 gym config
(stage1_rlvr_convergence_27node_h100.yaml). GB200 8n4g is non-colocated with
far more memory, so it is unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@youngeunkwon0405
youngeunkwon0405 removed their request for review July 17, 2026 23:56
@yfw

yfw commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7ac4824

`_get_drafter_model` returns a dynamic vLLM drafter model (Eagle3/MTP head),
not a plain `nn.Module`. Annotating it `Optional[torch.nn.Module]` made
pyrefly resolve `.load_weights` and `.mtp_start_layer_idx` through
`nn.Module.__getattr__` (typed `Module | Tensor`), producing spurious
not-callable / no-matching-overload errors. Return `Any` (matching the
pre-refactor raw `getattr` behavior), which clears all 6 errors.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw
yfw force-pushed the yifu/super_mtp_rebased branch from 8c3034c to cecd98d Compare July 20, 2026 16:47
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 84d2aa9

@ashors1 ashors1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds MTP speculative-decoding support for vLLM inference with a refit-based drafter weight update path. The core gating logic (_mtp_drafter_refit_enabled) correctly handles all cases (co-trained vs disk-loaded MTP, Eagle3, disabled spec-decode). Six comments below — one correctness concern and five suggestions.

Generated by Claude Code

Comment thread examples/nemo_gym/run_grpo_nemo_gym.py Resolved
yfw added 2 commits July 20, 2026 13:58
Signed-off-by: Yi-Fu Wu <[email protected]>
# Conflicts:
#	nemo_rl/models/generation/vllm/vllm_backend.py
@yfw yfw changed the title feat(vllm): MTP speculative-decoding inference with refit drafter feat(vllm): MTP speculative-decoding inference for nemotron super/ultra with refit drafter Jul 21, 2026
@yfw yfw changed the title feat(vllm): MTP speculative-decoding inference for nemotron super/ultra with refit drafter feat(vllm): MTP spec dec inference for nemotron super/ultra with refit drafter Jul 21, 2026
Signed-off-by: Yi-Fu Wu <[email protected]>

# Conflicts:
#	nemo_rl/models/generation/vllm/vllm_backend.py
@yfw

yfw commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7684a73

ashors1
ashors1 previously approved these changes Jul 21, 2026
@yfw

yfw commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test fee9f80

@yfw

yfw commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 574732c

@yfw
yfw merged commit bc382dc into main Jul 22, 2026
79 checks passed
@yfw
yfw deleted the yifu/super_mtp_rebased branch July 22, 2026 00:24
@yuki-97 yuki-97 mentioned this pull request Sep 8, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants