What was tuned
Table | |
|---|
| Method | LoRA SFT on all 40 layers (custom training stack, no HF Trainer) |
| LoRA | rank 16, alpha 32, scale alpha/r = 2 |
| Targets | attn.wq_a, attn.wq_b, attn.wkv, attn.wo_b, ffn.shared_experts.w1/w2/w3 → 7 modules × 40 layers = 280 tensors, 318.8M params (1.17 %) |
| Data | 203 R1-distillation conversations, prompts rendered with the model's own encoder, loss on the assistant turn only |
| Schedule | 164 steps, batch 1 sequence, max len 16384, AdamW lr 1e-4 cosine → 0.1×, 5 % warmup, clip 1.0, bf16 forward/backward, full activation checkpointing |
| Loss | 0.83 (step 1) → 0.60 (step 164) |
| Magnitude | ‖ΔW‖/‖W‖ median 5.1e-3 per tensor |
Layout (important)
Merging LoRA into this checkpoint is done as W' = dequant(W_fp8, S_e8m0) + (B @ A) * alpha/r, and the result is
stored dense bf16 for the 280 tuned tensors:
48 × model-000NN-of-00048.safetensors byte-identical copies of the base shardsmodel-rft1-bf16.safetensors 10.3 GB, bf16, exactly the 280 tuned tensorsmodel.safetensors.index.json points those 280 names at model-rft1-bf16.safetensors, and drops their (now unused) .scale entriesconfig.json base config + quantization_config.ignored_layers
The base shards still contain the old FP8 copies of those 280 tensors (and their scales). Index-driven
loading is therefore mandatory, so that each tensor is read only from the shard the index assigns it to:
- Loader must honour
weight_map per tensor — anything that reads every shard in full and merges by
name will see duplicate names and must not be used.
- Loader must honour
quantization_config.ignored_layers — the listed modules
(attn.wq_a_wkv, attn.wq_b, attn.wo_b, ffn.shared_experts.gate_up_proj, ffn.shared_experts.down_proj)
have no FP8 scale in the index and must be built as unquantized bf16 linears.
Why not just re-quantise into FP8?
Measured: requantising the merged weights onto the original 32×32 E8M0 grid keeps only 20.6 % of the delta
(r = ⟨W'-W, ΔW⟩/‖ΔW‖² median 0.206, residual 0.928 over all 280 tensors) — the tune is of the same
order as the FP8 block-quantisation error and would be largely washed out. Keeping the tuned modules in bf16
preserves the update exactly; the cost is 10.3 GB of extra storage over the base checkpoint.
Serving
Reference stack: UnieInfra with the index-ownership loader patch
(model_loader/weight_utils.py, each tensor is taken only from the shard the safetensors index assigns),
TP=4, ENGRAM_HOST_TABLE=1, LANGUAGE_MODEL_ONLY=1.
MODEL_PATH=/models/DeepSeek-V4.1-Flash-1017-rft1 ./scripts/deepseek-v4.1-flash-1017.sh
vLLM / transformers will pick the right shard for each tensor because they load through the index, but they do
not understand ignored_layers for this architecture, so the five module types above would be built as FP8
linear without scales. Expect them to need explicit support before this checkpoint runs there.
Provenance
Training and merge scripts are in train/: model_train.py (model + LoRA), train_sft.py (SFT loop),
merge_lora_fp8.py (FP8/bf16 merge, validate / retention / merge modes), load_real.py (checkpoint loader),
verify_delta.py (checks the stored bf16 tensors reproduce dequant(W) + ΔW; measured rel err 1.5e-3 = bf16 rounding).
The LoRA adapter itself (lora.pt, 200 MB, 280 A/B pairs) is not published here.