Skip to content

[megatron, sglang, ckpt, recipe] feat: add MiMo-7B MTP training on Ascend - #7446

Closed
RordChang wants to merge 2 commits into
verl-project:mainfrom
RordChang:feat/mtp-megatron-sglang-ascend
Closed

[megatron, sglang, ckpt, recipe] feat: add MiMo-7B MTP training on Ascend#7446
RordChang wants to merge 2 commits into
verl-project:mainfrom
RordChang:feat/mtp-megatron-sglang-ascend

Conversation

@RordChang

@RordChang RordChang commented Aug 17, 2026

Copy link
Copy Markdown

What does this PR do?

Adds MiMo-7B-RL MTP training on Ascend NPU with Megatron/MindSpeed for training, SGLang for rollout, and direct HCCL weight synchronization between the two sides.

  • Adds the registered sglang_hccl checkpoint engine for direct Megatron-to-SGLang weight updates.
  • Pairs each Megatron rank with a different colocated SGLang replica and creates persistent two-rank HCCL process groups.
  • Sends complete Hugging Face tensors in bounded buckets through SGLang's distributed weight-update API.
  • Restores actor parameter offload after non-naive checkpoint-engine synchronization.
  • Extends the canonical MiMo-7B MTP Megatron script with an Ascend mode while retaining the existing NVIDIA defaults.
  • Updates the existing MTP and checkpoint-engine documentation.

Related task: verl-project/verl-ascend-recipe#20

Checklist Before Starting

Test

  • pre-commit run --all-files --show-diff-on-failure --color=always: all hooks passed.
  • CPU validation: 12 passed, 1 warning.
  • bash -n examples/mtp_trainer/run_mimo_7b_mtp_megatron.sh: passed.

Experiment Results

Platform: 4 x Ascend 910B.

Metric Result
Completed training steps 100/100
Reward mean, first 10 steps -0.8080
Reward mean, last 10 steps 0.0891
Reward change +0.8971
Reward linear slope +0.01224/step
MTP loss mean, first 10 steps 0.5979
MTP loss mean, last 10 steps 0.3559
MTP loss change -0.2420
End-to-end throughput 533.3 token/s
Steady-state throughput 801.9 token/s

At step 100, each SGLang replica received 451 tensors in 12 buckets (15.67 GB) in 1.32-1.37 seconds; checkpoint tracking reached step 100.

Full redacted 100-step training log:
training_100step_sanitized.log

API and Usage Example

DEVICE=npu \
NPUS_PER_NODE=4 \
MODEL_PATH=/path/to/MiMo-7B-RL \
DATA_ROOT=/path/to/math \
bash examples/mtp_trainer/run_mimo_7b_mtp_megatron.sh

DATA_ROOT should contain train.parquet and test.parquet. Additional Hydra overrides can be appended to the command.

The recipe trains the MTP auxiliary head (enable_train=True) while SGLang performs rollout; rollout-side MTP acceleration remains disabled for this training configuration.

Design & Code Changes

  • SGLangHCCLCheckpointEngine prepares per-pair HCCL endpoints and streams complete named tensors without splitting a model parameter.
  • SGLangHCCLCheckpointEngineManager builds a cyclic derangement between trainer ranks and rollout replicas, initializes the SGLang update groups, and coordinates memory/generation state.
  • ActorRolloutRefWorker.update_weights returns offloaded actors to CPU after checkpoint-engine synchronization when parameter offload is enabled.
  • The canonical MiMo launcher selects sglang_hccl only for DEVICE=npu; existing CUDA behavior remains unchanged.

Checklist Before Submitting

  • Read the Contribute Guide.
  • Apply pre-commit checks: pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always.
  • Add / Update the documentation.
  • CPU validation results are reported above.
  • Once the PR is ready for CI, send a message in the ci-request channel or the Feishu group.
  • The recipe submodule is not changed, so no submodule reference update is required.

AI assistance disclosure: AI tools assisted with implementation, validation, and documentation preparation. The author reviewed the complete diff and takes responsibility for the submission.

Copilot AI lite review requested due to automatic review settings August 17, 2026 04:21

Copilot AI 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.

Pull request overview

Adds an Ascend NPU synchronous MiMo-7B MTP training path that performs direct Megatron→SGLang weight updates via paired HCCL process groups, plus CPU-side unit tests and documentation/recipe updates to support the new backend.

Changes:

  • Introduces the sglang_hccl checkpoint engine + a dedicated manager to build persistent paired (2-rank) HCCL groups and stream full HF-keyed tensors in bounded buckets.
  • Updates the actor worker weight-update path to re-offload parameters to CPU after non-naive checkpoint sync when parameter offload is enabled.
  • Extends the canonical MiMo-7B MTP Megatron launcher + docs to support DEVICE=npu, and adds CPU tests for bucketing/topology/HTTP error handling and global-step propagation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
verl/workers/engine_workers.py Re-offloads actor parameters after checkpoint-engine sync when param offload is enabled.
verl/checkpoint_engine/sglang_hccl_checkpoint_engine.py Adds direct paired HCCL Megatron→SGLang weight sync engine + custom manager.
verl/checkpoint_engine/README.md Documents the new sglang_hccl backend in the supported backends table.
verl/checkpoint_engine/init.py Exposes the new engine and manager from the checkpoint engine package.
tests/checkpoint_engine/test_sglang_hccl_on_cpu.py Adds CPU unit tests for bucketing, derangement mapping, HTTP handling, and group setup wiring.
tests/checkpoint_engine/test_global_steps_on_cpu.py Adds CPU coverage for param re-offload after checkpoint-engine send.
examples/mtp_trainer/run_mimo_7b_mtp_megatron.sh Extends the canonical MiMo-7B MTP launcher with Ascend mode and HCCL sync configuration.
examples/mtp_trainer/README.md Documents how to run the Ascend synchronous training mode via DEVICE=npu.
docs/advance/mtp.md Updates MTP dependency guidance for SGLang and Megatron-Bridge references.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 755 to +759
return metrics or {}
per_tensor_param, _ = self.actor.engine.get_per_tensor_param()
metrics = await self.checkpoint_engine.send_weights(per_tensor_param, global_steps=global_steps)
if self.actor.engine.is_param_offload_enabled:
self.actor.engine.to("cpu", model=True, optimizer=False, grad=False)
Comment on lines +231 to +237
elapsed = time.monotonic() - started
print(
"SGLang direct HCCL weight sync complete: "
f"step={global_steps}, tensors={tensor_count}, buckets={bucket_count}, "
f"bytes={total_bytes}, seconds={elapsed:.3f}",
flush=True,
)
Comment on lines +329 to +335
ray.get(init_refs)
self._group_initialized = True
print(
"SGLang direct HCCL groups initialized: "
f"groups={trainer_world_size}, world_size_per_group=2, backend={self.process_group_backend}",
flush=True,
)
|naive|torch.distributed|all_gather|NVIDIA/AMD/Ascend|Very High|NA|On-policy training<br>- Actor/rollout colocated
|nccl|NCCL|all_gather+broadcast|NVIDIA GPU & NCCL|Very High|Low: rebuild nccl group|Off-policy training<br>- Actor/rollout disaggregated<br>- Fixed clusters
|hccl|HCCL|all_gather+broadcast|Ascend NPU & HCCL| High|Low: rebuild hccl group|Off-policy training<br>- Actor/rollout disaggregated<br>- Fixed clusters
|sglang_hccl|HCCL|paired broadcast into SGLang|Ascend NPU & HCCL|High|Low: rebuild paired groups|On-policy training<br>- Actor/SGLang colocated<br>- Rollout TP 1
RordChang and others added 2 commits August 19, 2026 12:32
…cend

Signed-off-by: RordChang <13223981771@163.com>
Remove test-only changes following reviewer feedback while retaining the reported validation results in the PR description.

Co-authored-by: OpenAI Codex <noreply@openai.com>
Signed-off-by: RordChang <13223981771@163.com>
@RordChang
RordChang force-pushed the feat/mtp-megatron-sglang-ascend branch from 3422425 to 3bee0f8 Compare August 19, 2026 04:35
@@ -0,0 +1,345 @@
# Copyright (c) 2026 Huawei Technologies Co., Ltd. All Rights Reserved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hccl checkpoint engine的设计是和推理后端无关的,这里单独写了一个sglang的hccl checkpoint engine,建议复用原来的hccl checkpoint engine

@wucong25

Copy link
Copy Markdown
Collaborator

统一先提到verl-ascend-recipe:verl-ascend-recipe哈,此pr暂时关闭

@wucong25 wucong25 closed this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants