Conversation
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
kevintli
added this pull request to stack #13
October 2, 2026 22:05
…Miles/Bridge Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration
Bot
force-pushed
the
devin/1790903668-expert-lora-compat
branch
from
October 2, 2026 23:45
1b9f474 to
84cc6e6
Compare
…karound The new Bridge has no gpt-oss export override (per-expert LoRA exports as (E, ...) through the generic path) and includes NVIDIA-NeMo/Megatron-Bridge#5376, which keeps grouped-expert SwiGLU gate/up order on checkpoint load. The checkpoint-load restore is still needed because Miles load_slot drops the factory-merged weights. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Bridge 2e09c234 imports megatron.core.transformer.mla_qk_norm_config, which radixark/Megatron-LM added in 8a5dbe5. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Update: bump Megatron-Bridge, keep only the load workaround
Bug 1 turned out to be fixed upstream already: radixark/Megatron-Bridge's
bridgebranch was rebuilt on NVIDIA main, which doesn't have the gpt-oss export override, so the generic export path now publishes the full(32, ...)expert LoRA tensors. Our Miles commit (5510af6) already expects that Bridge (2e09c234), but Spindle pinned the older582783a. This PR now:BRIDGE_REVISIONfrom582783ato2e09c234, andMEGATRON_REVISIONfrom8c1e057to8a5dbe5, since the new Bridge importsmegatron.core.transformer.mla_qk_norm_config(radixark/Megatron-LM@8a5dbe5)publish_noopand its testsdist_checkpointing.loadThe new Bridge also includes NVIDIA-NeMo/Megatron-Bridge#5376. On the old pin, the grouped-expert
linear_fc1merge on load reordered the gate/up rows, so every run that resumed from a checkpoint (including the "after" runs below) trained with permuted expert gate/up LoRA B after the resume. That also covers the FP32 masters and Adam moments, so it persisted past the first optimizer step.Validation: resumed the F4 run from its update-16 checkpoint on the new pins for 3 updates (batches 16-18). The restore runs (
tensors=24), the expertlinear_fc1LoRA B moves by the same ~6.7% aslinear_fc2from update 16 to 17 with no gate/up permutation, the publishedgate_up_projLoRA B is(32, 5760, 32)and bit-identical to the trainer checkpoint, and KL stays at ~0.002 like the earlier "after" run.The rest of this description is from the original version of this PR.
Summary
While trying to get gpt-oss-20b working on Spindle, I noticed a few bugs in Miles and Megatron-Bridge which caused our sampler policy to diverge from the trainer policy over the course of training. This showed up as unusually large KL and worse reward curves compared to the original blog post results. This PR implements a workaround on the Spindle side before we upstream the actual bugfixes to those repos.
Observed bugs
lora/checkpoint.load_slot): Miles unintentionally throws away the result ofdist_checkpointing.load, which means the first training step uses uninitialized weights (untiloptim_stepcopies over the correct ones from the optimizer state), causing a temporary spike in KL / instability.Workaround
This PR implements
miles_runtime/expert_lora_compat.py, which runs only whenEXPERT_LORA_COMPAT=1. That compatibility wrapper does the following:Safety checks:
(E, ...), and logspublish_noopandrestore_noopwhen upstream is already correct.Removal: once upstream fixes both bugs, delete the module and the two
enabled()branches.Validation
Setup: gpt-oss-20b, TP=8 EP=8, sec-search-rl, full 24-update runs
The plots below show
kl_sample_train_v2before and after this bug fix. Notice that without the fix:Tests:
tests/backends/test_expert_lora_compat.pycovers the 4→32 rewrite, the no-op on complete exports, rejection of mismatched or missing tensors, the param copy, and the master refreshpytest(with torch installed) gives 714 passed, 1 skippedLink to Devin session: https://modal.devinenterprise.com/sessions/f53cfabb210146de8f0338fe388d7973
Open in Devin Desktop: https://modal.devinenterprise.com/desktop/session/f53cfabb210146de8f0338fe388d7973?variant=devin
Requested by: @kevintli