Repository navigation
[Fix] lora: Preserve MoE projection identity and routing lifetimes - #45681
Merged
Merged
Conversation
This was referenced Oct 21, 2026
ch-wan
requested review from
Alisehen,
AniZpZ,
Edwardf0t1,
FlamingoPg,
OrangeRedeng,
b8zhong,
hnyls2002,
ispobock,
merrymercy and
yizhang2077
as code owners
October 23, 2026 06:06
ch-wan
force-pushed
the
cheng/hot-fix/moe-lora-gated-virtual-projections
branch
from
October 23, 2026 06:07
e6670af to
b62e3d7
Compare
ch-wan
force-pushed
the
cheng/hot-fix/cutlass-moe-complete-maps
branch
from
October 23, 2026 09:03
4532436 to
22687df
Compare
ch-wan
force-pushed
the
cheng/hot-fix/moe-lora-gated-virtual-projections
branch
from
October 23, 2026 09:03
b62e3d7 to
b400733
Compare
ch-wan
force-pushed
the
cheng/hot-fix/cutlass-moe-complete-maps
branch
from
October 23, 2026 09:59
22687df to
c8f926b
Compare
ch-wan
force-pushed
the
cheng/hot-fix/moe-lora-gated-virtual-projections
branch
from
October 23, 2026 09:59
b400733 to
df67b1a
Compare
ch-wan
force-pushed
the
cheng/hot-fix/cutlass-moe-complete-maps
branch
from
October 23, 2026 11:36
c8f926b to
1aa9634
Compare
ch-wan
force-pushed
the
cheng/hot-fix/moe-lora-gated-virtual-projections
branch
2 times, most recently
from
October 23, 2026 19:21
dc9638c to
69c4b92
Compare
ch-wan
force-pushed
the
cheng/hot-fix/cutlass-moe-complete-maps
branch
2 times, most recently
from
October 23, 2026 19:31
d5ee31a to
491587f
Compare
Base automatically changed from
cheng/hot-fix/cutlass-moe-complete-maps
to
main
October 23, 2026 19:32
ch-wan
force-pushed
the
cheng/hot-fix/moe-lora-gated-virtual-projections
branch
from
October 23, 2026 19:32
69c4b92 to
5bcaf4d
Compare
jybsuper
added a commit
that referenced
this pull request
Oct 24, 2026
Main is at 6a319e7. One conflict: this branch moved test/registered/lora/test_virtual_experts_kernels.py to test/registered/kernels/ops/lora/ and replaced its align tests with an exact-placement check, while d0022e1 (#45681) rewrote the old path, removed fused_sanitize_expert_ids and made the CUDA-JIT align map out-of-range IDs to the sentinel bucket by default. Resolution in the moved file: - main's topk-remap class as is (this branch never changed it), with its imports and without the removed sanitizer; - this branch's exact-placement align check, plus main's used-count bounds (count >= 0, used blocks within expert_ids); - both align paths get the same invalid IDs (-1 and >= num_experts), since main's JIT path now buckets out-of-range IDs itself; the note that such IDs can touch invalid memory is gone with it; - the empty-input case main kept, through the same check; - main's sanitizer-free JIT subclass; - this branch's location and registration (base-b-kernel-unit on 1-gpu-small); main had moved the old path to extra-a. Auto-merged, worth a look: test_moe_lora_routing.py keeps this branch's est_time (20) next to main's new cases; test_experimental_sgl_marlin_runtime_unit.py keeps this branch's weekly CPU registration while main added a prewarm regression test to it; test_experimental_sgl_marlin_shared_outer_reduce.py is main's version (both sides moved it to extra-a).
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.
This PR is part of a stack (oldest at bottom):
Motivation
Independent gate/up A factors require matching rank halves during expansion. The stock virtual-expert hook reused the gate half for the up output: with
x=1,A_gate=2,A_up=3,B_gate=5,B_up=7, it produced[10,14]instead of[10,21]. Inactive routes and absent/disabled adapters also need complete private outputs without consuming stale or NaN payloads.Changes
Keep one full-
2Rshrink and select the matching A half inside the existing expansion. Internal rank/half-width constants and half-local masks support ragged widths without another projection launch or tensor. The default expansion keeps its original formulas.Bound raw virtual IDs and adapter slots before histogram, address or payload formation. Preserve borrowed inputs, valid adapter 0 and original-width int64 validity; shared routing retains negative routes. Missing, disabled and out-of-range adapters cannot read private deltas or contribute NaN scores.
Complete owned LoRA outputs in their existing kernels and guard capacity-grid programs before grouped division/modulo. Empty helpers preserve their return/output contracts. Activation and shared-outer rank reductions retain active arithmetic and rounding.
Prepare paired per-expert gate-B/down-A routing once on the main stream, aligning at each stage's actual block size. Release the shared raw owner before projection buffers and the side-stream fork. Existing cache contracts and staged fallbacks remain for unsupported pairings, including global-ID EP.
Remove unused expert-ID sanitizers and the unused metadata-bearing activation branch. Keep the production three-tensor activation and existing producer/reduction contracts.
CI cadence
The CUDA virtual-expert and experimental shared-outer LoRA suites now run in opt-in
extra-a-test-1-gpu-small. CPU runtime checks and the core routing-kernel tests remain in base CI; the existing XPU registration is preserved.Across the stack, six existing CUDA file registrations move from base CI to extra/nightly, removing 854 estimated GPU-seconds from the default gate (registration estimates, not a measured wall-time saving). All test bodies, cases, inputs, assertions and tolerances are unchanged. Full before/after discovery validates 2,535 files and 3,077 registrations, with every moved file selected in its enabled destination suite. Configured hooks pass; native tests were not rerun for this registration-only update.
Validation
At integrated
e6670af1ad, the focused native Marlin/LoRA route suite passes 14 tests on 1× B300 with the pinned providers, including changing padded routes and output completion.Two additional direct Marlin output-ownership configurations did not complete within a 600-second cold-compilation budget on B300. No result is claimed for that extended run; it is separate from the completed route replay and producer-contract checks.
The focused production activation/reduction suite passes 10 tests on 1× B300 after cleanup. The deleted helpers had no production callers; retained production Triton kernel bodies are unchanged.
Performance comparisons use main
b008ec3de6before #44480, #44991, #44993 and #44994 merged. The integrated candidate also includes intervening main changes; the measured improvement is not attributed solely to this PR.3c486bd6versusb008ec3d) completed 60 workers and 384 fixedrtol=0.01, atol=0.001checks at M32/512, H256/I128/E8/topk2/rank8. Factored and multi-adapter outputs agree bitwise across revisions. Paired graph medians improve 1.82%/1.41% for factored and 4.72%/6.62% for multi-adapter paths; measured peaks do not increase. The nongated stock compatibility fixture retains bit instability on both revisions despite passing fixed-close checks; it does not prove a fully gated checkpoint.H200/B300 tests used PyTorch 2.14.1+cu130, Triton 3.8.0, sgl-kernel 0.4.10 and FlashInfer 0.7.2. The H200 performance/memory results precede the main rebase; no B300 full-runner LoRA performance, native MUSA or distributed-serving result is claimed.
Rebase validation (before the CI registration fix)
This five-PR stack was rebased without conflicts onto main
8b9f72417f. All five patches retain their stable patch IDs relative to the preceding published stack; the newer main commits do not touch the stack's changed files. The existing removal of the unusedmaterialized_routingparameter and its three call-site arguments in #45917 is preserved.Each rebased PR commit passed its configured pre-commit checks independently. The final stack passes
git diff --check, and all 72 changed Python files parse successfully. CPU test suites, native GPU tests and performance measurements were not rerun for this rebase. Previously reported results, including those at integratede6670af1ad, remain evidence for those earlier revisions with their stated limits.Prior CI registration fix
The GGUF weighting test now uses the existing
nightly-musa-1-gpusuite withnightly=True; at that revision, its CUDA kernel-unit registration was unchanged. The previous nonexistent MUSA suite caused global registry validation to fail before CPU, CUDA and AMD tests could run.The original collection failure was reproduced. Full registration collection and suite validation now pass on the GGUF component (2,533 files / 3,075 registrations) and the integrated stack (2,535 files / 3,077 registrations), including enabled MUSA nightly and CUDA selection. Configured pre-commit checks pass for the corrected test. This update changes one registration line and is propagated through the existing stack.
CPU CI follow-up
Run 39935811691 exposed an upstream Flux2 import test registered in the CPU suite, whose environment lacks the diffusion dependencies. The import chain also queries the active GPU. #45915 moves that check to the existing CUDA diffusion unit suite, which installs those dependencies, while retaining its XPU registration and the real subprocess check that blocks Intel Triton imports. This registration fix is propagated through the stack.
#45917 also updates the MoE CPU fixtures to use the production CompressedTensors/Quark method wrappers and to resolve the FP8 routing policy through the initialization hook. Existing backend, EP mapping and zero-valued/default routing assertions remain intact. The three original fixture failures were reproduced before the fix; both complete files now pass on CPU (26 tests, 55 subtests).
The Flux2 import check passes on 1× NVIDIA B300 with PyTorch 2.14.1+cu130, Triton 3.8.0 and Diffusers 0.37.0; its five Intel-XPU numerical cases are skipped on CUDA and were not rerun on XPU. Full integrated registry collection validates 2,535 files / 3,077 registrations, including the enabled diffusion/XPU selections and the preceding GGUF MUSA fix. Configured checks pass for the changed files. Only three test files change across this follow-up; production code is unchanged. A fresh full CI result is not claimed.
Merge preparation
Rebased this component onto main
ac3db731b3for squash merge. The preceding stack components are already merged into main; only this component is replayed here. No test suites or performance measurements were rerun for this merge. Earlier validation sections describe their named revisions.CI States
Latest PR Test (Base): 🚫 Run #40012205098
Latest PR Test (Extra): ❌ Run #40012205102
Latest PR Test (AMD ROCm 10): 🚫 Run #40012205313