Skip to content

[LoRA] Fix gated MoE-LoRA under virtual experts; compressed-tensors runner detection and EP expert map - #32241

Open
yushengsu-thu wants to merge 2 commits into
mainfrom
yusheng/kimi-moe-lora-residual
Open

[LoRA] Fix gated MoE-LoRA under virtual experts; compressed-tensors runner detection and EP expert map#32241
yushengsu-thu wants to merge 2 commits into
mainfrom
yusheng/kimi-moe-lora-residual

Conversation

@yushengsu-thu

@yushengsu-thu yushengsu-thu commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Ports the residual of Kimi 2.5/6 LoRA support (#25141, sglang-miles) that isn't already covered by the #31520#31525 series or by main's own evolution — the rest of that commit is superseded and intentionally left out.

Three pieces:

  • Gated virtual-experts fix (the important one): the gated gate_up path passes the full stacked B to merged_experts_fused_moe_lora_add while A carries gate+up ranks concatenated (2·r), so gated (SwiGLU) MoE LoRA is numerically wrong on main whenever lora_use_virtual_experts is set. The kernel now accepts a length-2 B: one shrink over the full 2·r rank, one expand per half into its own output slice.
  • Runner detection: compressed-tensors attaches the MoeRunner to the layer's scheme, not quant_method, so WNA16 models silently fell back to the Triton runner in auto mode.
  • EP expert map: refresh quant_info.expert_map/global_num_experts per forward from the dispatcher's lazily-built local_expert_mapping, for quant schemes whose get_marlin_quant_info doesn't populate them.

Supersedes the kernel half of #28564 (rebased to the moved kernel location under sglang/kernels/ops/moe/); the remaining #28564/#28562 content is carried in better form by #31520/#31523/#31524/#31525.


CI States

Latest PR Test (Base): ❌ Run #30043811407
Latest PR Test (Extra): ❌ Run #30043810693

…er/EP enablement

Ports the still-missing pieces of Kimi 2.5/6 LoRA support from sglang-miles
(#25141) to main; the rest of that work is superseded by the #31520-#31525
series or by main's own evolution.

- virtual_experts: accept a length-2 lora_b for the gated gate_up case.
  A carries gate+up ranks concatenated (2*r) while each B has rank r; the
  previous single-B call fed the full stacked tensor to a kernel whose
  bookkeeping assumed matching rank, so gated (SwiGLU) MoE LoRA was
  numerically wrong whenever lora_use_virtual_experts was set. One shrink
  runs over the full 2*r rank, then one expand per B writes its own output
  slice.
- FusedMoEWithLoRA runner detection: fall back to base_layer.scheme.runner —
  compressed-tensors attaches the MoeRunner to the scheme, not quant_method,
  so WNA16 models silently picked the Triton runner in auto mode.
- Refresh quant_info.expert_map/global_num_experts per forward from the
  dispatcher's lazily-built local_expert_mapping, so EP deployments of
  quant schemes whose get_marlin_quant_info does not populate them (e.g.
  compressed-tensors WNA16) route expert indices correctly.

Co-authored-by: Nan Jiang <59716405+nanjiangwill@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 23, 2026 20:27
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants