[megatron] 5/n towards Kimi K2.6: Kimi K2.5-family (KimiK25ForConditionalGeneration) support with INT4 QAT + LoRA - #2027
Draft
casper-hansen wants to merge 7 commits into
Draft
Conversation
…viable for very large MoE On a 384-expert / 61-layer model (Kimi-K2.7-Code) the first LoRA disk sync OOM-killed workers node by node; _save_lora_adapters_and_sync had three compounding costs: - Only rank 0 wrote the PEFT files, which requires a shared filesystem: with merge_lora=false every vLLM worker hot-loads the adapter from its *local* filesystem. The first rank of each node now writes (identical content, atomic renames so engines never observe partial files), and rank 0 sends the LoraLoadRequest after a barrier. - Every rank kept a full copy of the gathered adapter state; with per-expert PEFT keys that is tens of GB per rank (~650 GB per node in aggregate). Only the per-node writer ranks materialize it now -- the others just participate in the collectives. - The float32 upcast doubled the state and the on-disk adapter for no fidelity gain (adapters train in bf16 and vLLM casts on load). The export keeps the training dtype. Also expose megatron-bridge's capacity-normalized MoE LoRA (megatron_config.lora_config.normalize_moe_lora: expert rank = rank/topk); at full rank the per-expert export is inherently huge (41 GB at rank 32) and is rewritten + re-read by every engine each sync (~5 GB with normalization). Co-authored-by: Cursor <cursoragent@cursor.com>
…onalGeneration) support with INT4 QAT + LoRA - KimiK25TextBridge: DeepSeek-V3 bridge adapted to the unified VL checkpoint (text_config + language_model. weight prefix); text-only training with the vision tower left frozen in the inference engine (language_model_only), with a clear error for full-VLM requests. - vLLM: declare KimiK25ForConditionalGeneration LoRA-capable (patch applied in the SkyRL worker extension import; the DeepSeek decoder already supports LoRA). The worker-side LoRA gate is an instance-level runtime Protocol check that requires every SupportsLoRA member (is_3d_moe_weight, is_non_gated_moe, lora_skip_prefixes too); mirror the DeepSeek decoder's declarations and pin it with a protocol-membership test. - Forward HF cache/auth env vars (HF_HOME & co) to Ray workers so model paths resolve identically on worker actors. - Truncated-real-model GPU integration test: bridge dispatch, provider construction, weight round-trip, LoRA export (incl. capacity-normalized expert LoRA via normalize_moe_lora). Stacked on 4/n (the GPU test exercises normalize_moe_lora). Co-authored-by: Cursor <cursoragent@cursor.com>
The flag lives on the shared MegatronLoraConfig and megatron-bridge supports it on both PEFT types; lora_type=canonical_lora silently kept full expert rank. Co-authored-by: Cursor <cursoragent@cursor.com>
vLLM 0.26 (now on main via NovaSky-AI#1854) added an annotation-only lora_manager member to the SupportsLoRA protocol. The patched KimiK25ForConditionalGeneration is checked *structurally* (unlike native nominal subclasses), so the member must exist on the class; without it the supports_lora() gate rejects the model. Set it to None, the documented 'not yet set' state. Also future-proof KimiK25TextBridge.build_conversion_tasks for megatron-bridge 0.7.0 (NovaSky-AI#2042), which grows the base signature with a weight_dtype keyword: forward *args/**kwargs instead of pinning the two-argument shape. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Updated for the vLLM 0.26 bump (#1854, now on
The rest of the K2.5 bridge (mapping re-rooting via |
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.
What
KimiK25TextBridge: DeepSeek-V3 bridge adapted to the unified VL checkpoint (text_config+language_model.weight prefix); text-only training with the vision tower left frozen in the inference engine (language_model_only), with a clear error for full-VLM requests.KimiK25ForConditionalGenerationLoRA-capable (patch applied in the SkyRL worker extension import; the DeepSeek decoder already supports LoRA). The worker-side LoRA gate is an instance-level runtime Protocol check that requires everySupportsLoRAmember (is_3d_moe_weight,is_non_gated_moe,lora_skip_prefixestoo); we mirror the DeepSeek decoder's declarations and pin it with a protocol-membership test.HF_HOME& co) to Ray workers so model paths resolve identically on worker actors.Why
Kimi K2.5-family checkpoints (K2.6, K2.7-Code) are unified VL checkpoints whose language model is DeepSeek-V3 architecture; there is no upstream bridge for the arch name, so AutoBridge dispatch fails without this.
Stacked on 4/n (#2026) -- the GPU test exercises
normalize_moe_lora; the diff includes 4/n until it merges. Marked draft until then. Part of the Kimi K2.x series (follow-up to #1862).Made with Cursor