glm 5.2 lora fp8 rollout fix - #31066
Open
kailash109 wants to merge 1 commit into
Open
kailash109 wants to merge 1 commit into
kailash109 wants to merge 1 commit into
Conversation
kailash109
requested review from
Fridge003,
Ying1123,
jybsuper,
lifuhuang and
yushengsu-thu
as code owners
July 13, 2026 19:59
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
46 tasks
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.
Fix LoRA-B buffer sizing for quantized column-parallel layers
Motivation
Serving a LoRA adapter on an FP8-quantized base (--quantization fp8 --lora-paths ...) crashes at engine init when the adapter targets a fused column-parallel module:
ValueError: LoRA B output dim 4096 does not match base partition prefix dim 2048 for 2 slicesI encountered this error when trying to train GLM-5.2 with LoRA on gate_proj/up_proj, TP > 1 with sglang fp8 rollouts (--quantization fp8). The identical configuration works in bf16 with no fp8 rollout.
Root cause
LoRAMemoryPool.get_lora_B_shape sizes the per-rank LoRA-B buffer by dividing get_hidden_dim()'s full output dim by the TP degree, gated on heuristics that probe base-layer attributes to detect non-standard sharding (e.g. replicated dense/shared-expert gate_up_proj under --moe-dense-tp-size 1).
The probe reads input_size // input_size_per_partition. UnquantizedLinearMethod never sets input_size_per_partition, so on bf16 the probe fails and the fallback path computes the correct per-rank dim. Fp8LinearMethod.create_weights does set layer.input_size_per_partition — and for a column-parallel layer input is unsharded, so the ratio is 1. The probe then reports "unsharded", the split is skipped, and B is allocated at the full output dim against a TP-sharded base. Then the error arises when set_lora_info correctly rejects the mismatch (shared_experts.gate_up_proj: B = 4096 vs per-rank output_partition_sizes = [1024, 1024]).
Modifications
Add _column_parallel_out_partition(): Resolve matching base modele per (module_name, layer_idx) and read output_size_per_partition (same quantity validated against in set_lora_info).
In get_lora_B_shape, for non-MoE column-parallel modules, use the probed per-rank dim directly, and fall back to the existing _column_parallel_lora_b_per_rank_dim arithmetic (which retains the qkv_proj KV-head-replication special case) only when no base module can be probed. MoE modules keep the moe_tp_size path unchanged. For bf16, the probed value equals what previous path computed in all preexisting working configs.
Validation
Pre-fix: crash at lora/layers.py set_lora_info on GLM-5.2 5-layer, TP2, FP8 (module mlp.shared_experts.gate_up_proj, Fp8LinearMethod, B=(4096,16) vs partitions [1024,1024]); same crash at TP32 ([64,64], prefix 128).
Post-fix: same configs load, attach, serve, and run RL rollout + LoRA weight-sync end-to-end at 4-GPU and 64-GPU scale; bf16 runs unchanged.
The training scripts are separate and run Miles on top of Modal -- if necessary I can create a repro of serving GLM5.2 Lora via sglang with and without this fix. Thanks!
CI States
Latest PR Test (Base):⚠️ Run #29280640163⚠️ Run #29280639826
Latest PR Test (Extra):