Skip to content

fix(recipe): resync Moonlight pipeline layout - #5708

Merged
yaoyu-33 merged 1 commit into
mainfrom
yuya/verified-bug-hunter-moonlight-layout-20260820
Aug 20, 2026
Merged

yaoyu-33 merged 1 commit into
mainfrom
yuya/verified-bug-hunter-moonlight-layout-20260820

Conversation

@yaoyu-33

Copy link
Copy Markdown
Contributor

Problem

The public recipe runner accepts pipeline-topology overrides and rebuilds recipe-owned layouts before training. Moonlight-16B already defines supported PP/VP layouts, but its provider did not register that builder with the shared runner.

For the supported moonlight_16b_sft_config override model.pipeline_model_parallel_size=2 model.virtual_pipeline_model_parallel_size=1 on 16 ranks, the override and Bridge runtime validation succeed (TP=1, PP=2, CP=1, EP=8, DP=8), but the layout remained None. Megatron-Core then tries to split Moonlight's 27 decoder layers evenly across two pipeline stages and fails instead of using the recipe's documented 14/13 split.

Root cause and fix

sync_model_pipeline_layout() can only rebuild a layout when the model provider exposes _pipeline_model_parallel_layout_builder. Moonlight's provider omitted that registration even though _get_moonlight_pipeline_layout() already owns all supported layouts.

Register the existing builder when constructing the provider and normalize MCore's None representation for no virtual pipeline parallelism to VP=1. This matches the established recipe-owned layout contract and adds no topology or API surface.

Validation

The focused regression applies the real Hydra overrides, invokes the shared runner synchronizer, and completes Bridge runtime configuration validation before checking the resolved layout.

uv run --no-sync python -m pytest --confcutdir=tests/unit_tests/recipes tests/unit_tests/recipes/test_moonlight_recipes.py -k pipeline_layout_tracks_supported_runner_override -q
base: 1 failed, 15 deselected (layout was None)
fix:  1 passed, 15 deselected

uv run --no-sync python -m pytest --confcutdir=tests/unit_tests/recipes tests/unit_tests/recipes/test_moonlight_recipes.py -k "not peft_convergence_contract" -q
15 passed, 1 deselected

uv run --no-sync python -m pytest --confcutdir=tests/unit_tests/recipes tests/unit_tests/recipes/test_deepseek_recipes.py tests/unit_tests/recipes/test_glm_45v_recipes.py tests/unit_tests/recipes/kimi_vl/test_kimi_k25_vl.py -k pipeline_layout -q
25 passed, 73 deselected

git diff --check
passed

uv run --no-sync pre-commit run --all-files
all hooks passed

Scope

This change only resynchronizes Moonlight's existing layouts after supported PP/VP overrides. It does not add new layouts, change recipe defaults or public APIs, modify Megatron-Core, or claim model-quality, convergence, performance, GPU, distributed, or full-suite validation.

Signed-off-by: Yu Yao <yaoyu.094@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 20, 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.

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 2a6871a

@claude

claude Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

LGTM - light review

The change wires up _pipeline_model_parallel_layout_builder on the Moonlight provider so sync_model_pipeline_layout can rebuild the recipe-owned layout after CLI PP/VP overrides, matching the existing DeepSeek-V3 and Kimi-K2 recipe pattern. The vp_size: int | None signature plus the None-to-1 normalization is consistent with those siblings and handles the default virtual_pipeline_model_parallel_size = None case. The new test exercises the real runner sync path end-to-end (PP=2, VP=1) rather than mocking it, which is the right coverage for the fix.

Minor observations (non-blocking):

  • The builder is now attached inside _moonlight_16b_model_provider(), so every config (pretrain/SFT/PEFT) that goes through it also gains the builder. Intentional and consistent; per-config static layout assignments remain as defaults and the builder only re-fires when a topology override is present. Worth confirming the static defaults still match builder output per config.
  • _FakeMoonlightModelProvider gained many new attributes to satisfy runtime_config_update; slightly brittle coupling but acceptable for a runner-level test.

Suggested test cases

  • test_moonlight_pipeline_layout_tracks_supported_runner_override (new - PP=2/VP=1 override path)
  • tests/unit_tests/recipes/test_moonlight_recipes.py full module (regression on all pretrain/SFT/PEFT config builders that now attach the layout builder)
  • No perf tests impacted (no scripts/performance/configs/ or functional launcher configs touched).

@yaoyu-33 yaoyu-33 added area:recipe Training recipes and launch configs bug Something isn't working needs-more-tests Requires additional L0 and L1 test coverage before merge needs-review PR is ready for code review and waiting on a reviewer labels Aug 20, 2026
@yaoyu-33
yaoyu-33 merged commit 8a8c76a into main Aug 20, 2026
90 checks passed
@yaoyu-33
yaoyu-33 deleted the yuya/verified-bug-hunter-moonlight-layout-20260820 branch August 20, 2026 17:13

This branch was previously deployed

2 inactive deployments
public — 2a6871ae Deployed Aug 20, 2026 by copy-pr-bot[bot] via release / finalize / publish-docs #4835
test — 2a6871ae Deployed Aug 20, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #20810
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recipe Training recipes and launch configs bug Something isn't working needs-more-tests Requires additional L0 and L1 test coverage before merge needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant