Repository navigation
Add a Kimi K3 LoRA recipe on the MXFP4 release - #290
Merged
Merged
Conversation
Use the stock Tinker client with Spindle routing replay for the unfiltered Beam recipe. Persist metrics and evaluation responses incrementally, preserve pending behavior policies across checkpoint restarts, and bound execution and cancellation. Include partial-run summaries and a digitized blog comparison. Refresh the Beam sampler pin to include the latest fork base. Validation: 34 focused tests, 1294 full-suite tests passed with eight skips, locked pre-commit, independent review, and exact grading agreement on 5280 prior responses. Fresh deployment and learning validation remain pending.
When the restored update equals --stop-after, save a roundtrip checkpoint and exit before publication, evaluation or training. Preserve the pending behavior policy for continuation from the audited state. Reject stop boundaries earlier than the restored update. Independent delta review and 35 focused CPU tests passed. Full CPU suite: 1295 passed, eight skipped. Locked pre-commit passed. Actual GPU restore comparison remains pending.
Detect the public ServiceClient header parameter instead of forwarding an unsupported keyword. Verify proxy credentials reach the real SDK transport under both 0.26 and 0.39 before deliberate model-creation refusal. Keeps expert-routing replay unchanged.
Check in actual configuration, runtime provenance, wall-clock identity and complete startup journal records. The initial SDK-header error and retry are retained. No optimizer updates or evaluation results are claimed in this snapshot.
Miles multi-LoRA rejects explicit model seeds before accepting a model. Keep dataset shuffle and sampling seeds fixed, and let the deployment initialize adapters. Restrict the test service creation signature so this argument cannot return unnoticed.
A durable successful optimizer result must not be treated like an unknown submission if subsequent diagnostics or reporting fail. Record one accepted update with unavailable diagnostics marked, keep the next behavior-policy snapshot, and save the accepted state before exiting. Existing accepted records remain unique; rejection and unknown-outcome handling stay unchanged. Six fault/cache regressions fail before the change and pass afterward. Focused CPU tests: 42 passed. Full CPU suite: 1302 passed, 8 skipped. Locked pre-commit passed; independent review found no remaining issue. The active GPU process remains on its original client code until the planned checkpoint restart.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Beam needs two H200 nodes, but miles-v0.2.0 rejected multi-node trainers. Each node sees only its own uncommitted writes to the checkpoint volume, so Miles' native adapter saves broke in two ways across nodes: rank 0 alone creates the adapter directory, and the head checks shards other nodes have not committed. Every rank now creates the directory before writing its shards, each node commits the volume after a save or sampler export, and the head reloads it before checking and publishing the capture. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of the multi-node change found three problems: - The head reloaded the checkpoint volume after every save and sampler export, even when the capture sat on local disk. A reload fails while files on the volume are open, so a save during a checkpoint copy failed. - A failed volume commit inside the trainer actors marked the whole trainer as failed. - Every save on single-node trainers paid for a barrier, a commit and a reload it didn't need. The commit and reload now run only for captures on the checkpoint volume. The commit is a separate trainer call that fails only its own request and removes the partial capture. Saves, exports and publishes of captures on the volume hold the checkpoint I/O lock that persistence already holds. The per-rank directory wrapper is gone: torch's FileSystemWriter already creates the checkpoint directory on every rank. Co-Authored-By: Claude Opus 5.5 <[email protected]>
modal-projects/sglang#95 was rebased onto the current spindle-sglang-v0.5.23 tip and now adds the Beam attention gate to auto-detected LoRA targets only for models that declare it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md # src/spindle/providers/modal/rollout_image.py
Merge #252's current head. Its Miles v0.2.0 image already includes the Kimi K3 change, so the K3 recipe now uses trainer_image "miles-v0.2.0" and the K3-only trainer image and the fork_image() helper are gone. kimi_k3_image.py keeps only the sampler image. Kimi K3 trains with megatron_to_hf_mode "raw", which Spindle only passes to Miles, so miles-v0.2.0 no longer rejects it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Spindle passes --lora-type lora to every Miles trainer, but Miles v0.2.0's raw mode gives each projection its own lora_A and asserts canonical_lora at startup. The Kimi K3 recipe now sets lora_type canonical_lora, and a raw deployment on miles-v0.2.0 without it is rejected before a trainer starts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fred Robinson (frrad)
force-pushed
the
bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn
branch
9 times, most recently
from
November 18, 2026 04:20
f7ed75a to
b5140f9
Compare
Fred Robinson (frrad)
force-pushed
the
bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn
branch
from
November 18, 2026 05:46
b5140f9 to
84163b1
Compare
Merge reference-dapo-multinode (#348) and keep only the Kimi K3 changes on top of it: the recipe on the miles-v0.2.0-e814245 trainer image and the default sglang-v0.5.23-c4182b2 sampler image, which both contain the K3 fork changes. The Beam and old-runtime changes from the previous base are dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Micah Yong (micahtyong)
changed the base branch from
bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn
to
reference-dapo-multinode
November 18, 2026 16:45
qkv_format thd is the Miles default, and Miles native LoRA already requires moe_shared_expert_overlap off. Also correct the sampler start-time comment. 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
Kimi K3 LoRA runs on Spindle from the official MXFP4 release (
moonshotai/Kimi-K3@f831ab66) with the stock Tinker SDK.Recipe.
kimi_k3_lora_32k: a 2×8 B300 trainer and one 8×B300 sampler, 32K context, LoRA rank up to 32, two training clients per trainer. The sampler needs B300: no other GPU holds the 1.5 TB checkpoint on one node.What trains. Adapters cover attention, the dense first layer and the shared experts. The 896 routed experts stay frozen in MXFP4 on both sides. A rank-32 adapter is about 0.4 GB.
One weights setting. The trainer and the sampler both read the release. The trainer keeps routed experts as MXFP4 bytes and dequantizes them inside the expert GEMM. The sampler serves them with Marlin.
Sampler settings that matter.
weight_loader_disable_mmap: True. With mmap on, this sampler kept each loaded adapter file open on the snapshot volume. The sampler then could not reload the volume, so new adapter versions never arrived.SGLANG_K3_AR_FUSION=0: the fused all-reduce skips the LoRA wrappers ono_projand the shared experts.Images. No new images. The trainer uses
miles-v0.2.0-e814245, which already includes modal-projects/miles#39. The sampler usessglang-v0.5.23-c4182b2, which already includes modal-projects/sglang#97.Raw mode. Kimi K3 has no Megatron-Bridge mapping, so the recipe sets
megatron_to_hf_mode: rawwithlora_type: canonical_lora, the layout the built-in v0.2.0 images accept for raw mode.Client notes.
moonshotai/Kimi-K3, so it needs an explicitrenderer_name. Itskimi_k31_pro_*renderers produce the same tokens as K3's own chat encoding, but the cookbook only loads the matching tokenizer for K3.1-Pro model names, so they fail on K3. Until the cookbook maps K3 to them,renderer_name=role_colonworks but does not use K3's chat format.loss_fn=importance_sampling(orppo) tomath_rl. Its default,stable_reinforce, is not supported by the Miles backend.Depends on #348, which runs Miles v0.2.0 trainers across nodes. Kimi K3 needs that: its trainer spans two nodes.
E2E results
On this head (55a68d0, merged with main). The same SFT and RL runs passed again, now with main's FLA kernel pinning (#373) and checkpoint restore changes (#382). RL sampler–trainer KL stayed between 0.0009 and 0.0030 per step, and training steps took 14–15 s after the first. Checkpoints saved from both trainer nodes. A third run loaded the SFT run's final checkpoint and trained 2 more steps; its loss on the first batches was 1.424 / 1.469 against 1.481 / 1.547 from the base weights. The trainer started in 43 minutes and the sampler in 38. W&B: SFT, RL, restore.
The detailed run below is from #348's head.
Setup: a staging deployment of this branch at aadfb95 (on #348's head 67f1d07), recipe
kimi_k3_lora_32k(2×8 B300 trainer, 8×B300 sampler). The next commit, bc001ee, only drops two Miles flags that equal Miles' defaults and edits comments. Stock tinker-cookbook 0.6.1 drove it from a container withrenderer_name=role_colonand rank 32. The RL client started while SFT was still waiting for the trainer, so both runs shared one trainer, one client per slot. W&B: SFT, RL.RL:
math_rlon gsm8k, 8 groups × 4 samples, up to 1024 tokens, lr 1e-5,loss_fn=importance_sampling,save_every=2, 5 steps.forward_backwardtakes 12–23 s on the trainer.SFT:
chat_slon NoRobots, batch 32, max length 8192, lr 1e-4,save_every=2, 5 steps.forward_backwardtakes 427 s for the first step, then 39, 15, 12 and 12 s. Train NLL is 1.48 at step 0 and 1.48 at step 4, with batch-to-batch noise from 1.47 to 1.57.Checkpoints on two nodes. Each run saved two full checkpoints during training and one at the end. Both nodes' shards land in one checkpoint: the save takes 22–33 s on the trainer, committing the shared volume over 16 workers 2–18 s, and persisting 10–36 s.
Startup.
Not covered yet: resuming from a checkpoint.
Previous run on an earlier multi-node Miles v0.2.0 runtime (Miles f45c63c, SGLang bb327ef, 5 RL steps, 5 SFT steps)
Setup: a staging deployment of this branch at 78c62ee (on an earlier multi-node Miles v0.2.0 runtime), recipe
kimi_k3_lora_32k(2×8 B300 trainer, 8×B300 sampler). Stock tinker-cookbook 0.6.1 drove it from a container withrenderer_name=role_colonand rank 32. The RL client started while SFT was still waiting for the trainer, so both runs shared one trainer, one client per slot. W&B: SFT, RL.RL:
math_rlon gsm8k, 8 groups × 4 samples, up to 1024 tokens, lr 1e-5,loss_fn=importance_sampling,save_every=2, 5 steps.forward_backwardtakes about 12 s. Exporting the adapter takes 11–36 s and publishing it about 5 s.SFT:
chat_slon NoRobots, batch 32, max length 8192, lr 1e-4,save_every=2, 5 steps.forward_backwardtakes 307 s for the first step, then 28, 19, 15 and 12 s. Train NLL is 1.48 at step 0 and 1.48 at step 4, with batch-to-batch noise from 1.47 to 1.57.Checkpoints on two nodes. Each run saved full checkpoints at its steps 2 and 4 and at the end. Both nodes' shards land in one checkpoint: the save takes 19–22 s on the trainer, committing the shared volume 10–11 s, and persisting 9–27 s.
Startup.
Not covered yet: resuming from a checkpoint.
Earlier run on a K3-only trainer image (K3-only trainer image, 12 RL steps, 20 SFT steps)
Setup: a staging deployment of this branch's head (6070287) merged with #291, recipe
kimi_k3_lora_32k(2×8 B300 trainer, 8×B300 sampler). Stock tinker-cookbook 0.6.1 drove it from a container withrenderer_name=role_colonand rank 32. W&B: SFT, RL.RL:
math_rlon gsm8k, 8 groups × 4 samples, up to 1024 tokens, lr 1e-5,loss_fn=importance_sampling, 12 steps. Each step samples from the adapter the previous step trained.forward_backwardtakes 12.5–20 s per step after the first (153 s). Exporting the adapter takes 2–12 s (median 5 s) and publishing it 1.7–4.7 s. The sampler loads each new adapter version in under 1 s.SFT:
chat_slon NoRobots, batch 32, max length 8192, lr 1e-4, 20 steps.forward_backwardtakes 182 s for the first step, then 12.4–20 s. Train NLL is 1.48 at step 0 and 1.44 at step 19, with batch-to-batch noise from 1.17 to 1.67. The final checkpoint saves in 29 s, and the sampler adapter exports in 10 s and publishes in 2.5 s.Startup.
A trainer stops as soon as its last training client finishes. Here the RL run started 13 s after SFT finished, so it waited for a new trainer (the second start above). To reuse a warm trainer, start the next run before the previous one ends.
🤖 Generated with Claude Code