feat(models): DeepSeek-V4-Flash architecture module + config fields (DSV4 Phase 0) - #65
Merged
Merged
Conversation
…DSV4 Phase 0) Add full config parsing for DeepSeek-V4-Flash fields to ModelConfig: - HC (Hyper-Connections): hc_mult, hc_sinkhorn_iters, hc_eps - CSA attention: compress_ratios, compress_rope_theta, index_head_dim, index_n_heads, index_topk, o_groups, o_lora_rank - MoE: scoring_func, topk_method, swiglu_limit, expert_dtype, routed_scaling_factor, num_hash_layers - MTP: num_nextn_predict_layers Rewrite deepseek_v4.rs arch module to match real V4-Flash tensor inventory: - Correct tensor key mappings: wq_a/wq_b (low-rank Q), wkv (fused KV), wo_a/wo_b (grouped low-rank O), q_norm/kv_norm - MoE: ffn.gate.weight, experts.E.w1/w2/w3, shared_experts.w1/w2/w3 - MLA geometry: head_dim=512, qk_rope=64, qk_nope=448 - Sliding window always on (window=128) - Partial rotary: only last 64/512 dims get RoPE - Router type reflects sqrtsoftplus + noaux_tc scoring Update all ModelConfig construction sites (parser, orient, granite, gemma3, test_expert_endpoint) with the 17 new Option fields defaulting to None. Add 7 V4-Flash tests: detection, config field parsing, tensor key resolution, MoE properties, MLA geometry, sliding window, RoPE fraction. Implementation plan: docs/dsv4-flash-implementation-plan.md (10 phases, 12-18 sessions estimated for CPU parity through distributed deployment)
This was referenced Jul 13, 2026
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
First phase of DeepSeek-V4-Flash support. Extends
ModelConfigwith 17 V4-Flash architecture fields and rewrites thedeepseek_v4architecture module to match the real model's tensor inventory.Changes
Config (
config.rs,parser.rs)hc_mult,hc_sinkhorn_iters,hc_eps), CSA attention (compress_ratios,compress_rope_theta,index_head_dim,index_n_heads,index_topk,o_groups,o_lora_rank), MoE (scoring_func,topk_method,swiglu_limit,expert_dtype,routed_scaling_factor,num_hash_layers), MTP (num_nextn_predict_layers)Architecture (
deepseek_v4.rs)wq_a/wq_b(low-rank Q),wkv(fused single-head KV),wo_a(grouped low-rank O),q_norm/kv_normffn.gate.weight,experts.E.w1/w2/w3,shared_experts.w1/w2/w3head_dim=512,qk_rope=64,qk_nope=448sqrtsoftplus+noaux_tcscoringTests
Docs
docs/dsv4-flash-implementation-plan.md— full 10-phase plan (12-18 sessions for CPU parity through distributed deployment)Verification
Build + test on Valinor (RTX 3060, CachyOS, Rust 1.97.0):