Skip to content

Serve LoRA on all Qwen3.5 linear-attention projections - #99

Merged
micahtyong merged 4 commits into
spindle-sglang-v0.5.23from
spindle-sglang-v0.5.23-gdn-lora
Nov 17, 2026
Merged

micahtyong merged 4 commits into
spindle-sglang-v0.5.23from
spindle-sglang-v0.5.23-gdn-lora

Conversation

@micahtyong

Copy link
Copy Markdown

Summary

Spindle trains LoRA on the Qwen3.5 linear-attention (GatedDeltaNet) layers. Its trainer uses one fused in_proj adapter over q, k, v, z, b and a, and exports a standard PEFT adapter with four modules: in_proj_qkv, in_proj_z, in_proj_b and in_proj_a, each with the same lora_A. This branch could serve only q, k, v and z, through in_proj_qkvz. A sampler started with in_proj_b or in_proj_a in --lora-target-modules failed at startup with get_hidden_dim not implemented for in_proj_b.

This PR brings over the GDN LoRA support from upstream:

  • in_proj_ba is a LoRA target for Qwen3.5. It has a hidden size, a stacked count of 2, and shards on the attention TP group like in_proj_qkvz. _normalize_in_proj_ba stacks split in_proj_b and in_proj_a weights into it.
  • _normalize_in_proj_qkvz also reads the two-way in_proj_qkv + in_proj_z split that Megatron-Bridge exports.
  • Adapter target_modules named in_proj_q, in_proj_k, in_proj_v, in_proj_qkv or in_proj_z map to in_proj_qkvz, and in_proj_b or in_proj_a map to in_proj_ba. Without this, an adapter that lists the split names fails the check against --lora-target-modules.
  • in_proj_qkvz, in_proj_ba and out_proj are accepted --lora-target-modules choices.

The first two commits are cherry-picks of the sglang-miles commits from sgl-project#30499 and sgl-project#37466. The third ports the target-name mapping, the attention-TP entry and a CPU unit test from sgl-project#48158. Models without GDN layers are unchanged. The fused in_proj GEMM is already off when LoRA is enabled, so LoRA runs through the separate in_proj_qkvz and in_proj_ba layers.

Testing

On 803bccb:

  • test/registered/unit/lora in the lmsysorg/sglang:v0.5.23 image with this branch's python/ copied in, on CPU: 186 passed, 16 skipped. The new test_qwen3_5_gdn_lora.py passes. Three tests in test_lora_spec_verify_batch_info.py fail on CPU, and they fail the same way on the base commit c4182b2.
  • sglang serve argument parsing accepts --lora-target-modules in_proj_qkvz, in_proj_ba and out_proj. On c4182b2 it rejects out_proj.
  • End to end through Train LoRA on Qwen3.5 linear-attention layers modal-labs/spindle#262, on 803bccb: Qwen3.5-4B LoRA, rank 32, 1 H100 trainer and 1 H100 sampler, stock Tinker SDK. On both Spindle trainer images, the sampler logged loaded weights for target modules [..., 'in_proj_ba', 'in_proj_qkvz', ..., 'out_proj', ...] for each published adapter and never restarted. After 10 training steps, trainer and sampler logprobs differed by 0.017 on average on held-out data, the same as before the gates were trained. The exported in_proj_b and in_proj_a adapters had non-zero lora_B in all 24 linear-attention layers.

a344370 after 803bccb only tightens the new unit test.

Not covered here: --lora-backend triton_v2, which keeps a per-stream workspace. in_proj_ba now has an adapter and runs on the alternate stream during CUDA graph capture, so check that backend before relying on it. Spindle uses csgmv.

yushengsu-thu and others added 4 commits November 16, 2026 17:29
Adapters exported from Megatron-Bridge list in_proj_qkv, in_proj_z,
in_proj_b and in_proj_a in target_modules, and canonical adapters list
in_proj_q, in_proj_k, in_proj_v and in_proj_z. Map these names to the
fused runtime modules so the adapter passes the --lora-target-modules
subset check. Shard in_proj_ba on the attention TP group like
in_proj_qkvz, since both are built on that group. Accept out_proj as a
--lora-target-modules choice too.

Ported from sgl-project#48158; the sglang-miles branch has the
same mapping.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@micahtyong
micahtyong marked this pull request as ready for review November 17, 2026 02:36
@micahtyong
micahtyong merged commit fc53793 into spindle-sglang-v0.5.23 Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants