Repository navigation
Train LoRA on Qwen3.5 linear-attention layers - #262
Merged
Merged
Conversation
Micah Yong (micahtyong)
marked this pull request as ready for review
November 16, 2026 18:45
Micah Yong (micahtyong)
requested a review
from Kailash Ranganathan (kailash109)
as a code owner
November 16, 2026 18:45
Micah Yong (micahtyong)
force-pushed
the
micah/qwen35-gdn-lora
branch
from
November 16, 2026 18:46
8e260fc to
404a843
Compare
Add in_proj_qkv, in_proj_z, in_proj_b, in_proj_a and out_proj to the Qwen3.5 LoRA recipes, record target_modules in checkpoint metadata and reject a checkpoint whose targets differ from the deployment. This is the earlier state of the branch, rebased onto the frozen image names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… image The new sglang-v0.5.23-803bccb image serves LoRA on the fused in_proj_qkvz and in_proj_ba modules, and reads the in_proj_qkv, in_proj_z, in_proj_b and in_proj_a adapters Miles exports. So the trainer no longer keeps the b and a gate adapters at zero, and the exported adapter is no longer rewritten before the samplers load it. The gates are trained with the rest of the fused in_proj, as upstream Miles does in its fused LoRA mode. Only the Qwen3.5 configs that train these layers move to the new image. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reordering a recipe's target_modules doesn't change what is trained, so it shouldn't make saved checkpoints fail to load. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Micah Yong (micahtyong)
force-pushed
the
micah/qwen35-gdn-lora
branch
from
November 17, 2026 02:24
f49a004 to
a1d30a2
Compare
The fork PR merged with a merge commit, so 803bccb is reachable from spindle-sglang-v0.5.23 and the image no longer depends on the feature branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Summary
Three of every four layers in Qwen3.5 are linear attention (Gated DeltaNet). Their projections are
in_proj_qkv,in_proj_z,in_proj_b,in_proj_aandout_proj. Until now, the Qwen3.5 LoRA recipes adapted only the full-attention layers, the MLPs andlm_head. The linear-attention names never matched a recipe target, so those layers trained no adapter, and nothing warned about it. At the same learning rate, the model changed less per step than it should.This PR turns those targets on in the Qwen3.5-2B, Qwen3.5-4B and Qwen3.5-9B-Base LoRA recipes (9B 2K, 16K, 16K single and 64K). The 9B instruct and 128K recipes are unchanged. It works on both Miles images, the default and
miles-v0.2.0-15afe21.bandagates. This matches upstream Miles in its fused LoRA mode.in_proj_qkv,in_proj_z,in_proj_bandin_proj_amodules that share onelora_A. Spindle doesn't rewrite it.sglang-v0.5.23-803bccb, from Serve LoRA on all Qwen3.5 linear-attention projections modal-projects/sglang#99 (merged). It serves LoRA on SGLang's fusedin_proj_qkvzandin_proj_bamodules and reads the split names above. The sampler's--lora-target-modulesnow includein_proj_qkvz,in_proj_baandout_proj. The old image had noin_proj_batarget and crashed at startup when the gates were listed.target_modules. Loading a checkpoint saved with different targets fails with a plain message. The order of the list doesn't matter. Checkpoints these recipes saved before this change are rejected this way. The message points to a new docs section, "Older Qwen3.5 LoRA checkpoints". It shows a variant config with the old targets and sampler image, and how to load an old checkpoint into it withload_state.create_training_client_from_statealways restores on the config that saved the checkpoint, so it can't be used for this.Earlier revisions of this PR kept the gate adapters at zero in the trainer and merged q, k, v and z into one adapter before export, to fit the old sampler. Both are gone.
The new image follows the frozen-image process. Only the six configs above move to it, and every other config keeps
sglang-v0.5.23-c4182b2. The image installs commit803bccbfrom the fork branchspindle-sglang-v0.5.23.#312 adds
miles_cfg.lora_typeand thecanonical_loralayout. That layout gives each linear-attention projection its own adapter factors and trains noboraadapters, which is Tinker's exact layout for Qwen3.5. The new sampler image already reads its names, whether q, k and v come split or as onein_proj_qkv. If #312 moves the Qwen3.5 recipes, the "list all four" check should apply only to the fusedloralayout.Rollout:
-lora-pool for these recipes that started before the deploy.Testing
Qwen3.5-4B (
qwen35-4b-lora-32kwith 1 H100 trainer and 1 H100 sampler), rank 32, on both Miles images. Each check used the stock Tinker SDK with tinker-cookbook data helpers, pointed at the Spindle URL. Training data was no_robots, batch 32, LR 1e-4.miles-v0.2.0-15afe21save_state→load_statein a fresh client, max |Δ logprob|forward_backwardmedian, trainer sideloaded weights for target modules [..., 'in_proj_ba', 'in_proj_qkvz', ..., 'out_proj', ...]for every published adapter. Each pool started once, with no restarts.lora_Bforin_proj_bandin_proj_a, about the same size asin_proj_qkvandin_proj_z. All four modules share the samelora_A. Trainer and sampler logprobs agree as closely as they did when the gates were frozen.uv run --no-sync pytest -qon a1d30a2: 1406 passed. One test fails only on this machine (AF_UNIX path too long) and is unrelated.803bccb(Serve LoRA on all Qwen3.5 linear-attention projections modal-projects/sglang#99).Not run:
in_proj_bais the same as forin_proj_qkvz, but no 9B run has used it.