Skip to content

feat(models): DeepSeek-V4-Flash architecture module + config fields (DSV4 Phase 0) - #65

Merged
ezutfen merged 9 commits into
mainfrom
feat/dsv4-flash-arch-support
Jul 13, 2026
Merged

feat(models): DeepSeek-V4-Flash architecture module + config fields (DSV4 Phase 0)#65
ezutfen merged 9 commits into
mainfrom
feat/dsv4-flash-arch-support

Conversation

@ezutfen

@ezutfen ezutfen commented Jul 13, 2026

Copy link
Copy Markdown

Summary

First phase of DeepSeek-V4-Flash support. Extends ModelConfig with 17 V4-Flash architecture fields and rewrites the deepseek_v4 architecture module to match the real model's tensor inventory.

Changes

Config (config.rs, parser.rs)

  • 17 new fields: HC (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)
  • All fields parsed from config.json with correct V4-Flash key names

Architecture (deepseek_v4.rs)

  • Corrected tensor key mappings: wq_a/wq_b (low-rank Q), wkv (fused single-head KV), wo_a (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 (size=128), partial rotary (last 64/512 dims)
  • Router type reflects sqrtsoftplus + noaux_tc scoring

Tests

  • 7 new V4-Flash tests: detection, config field parsing, tensor key resolution, MoE properties, MLA geometry, sliding window, RoPE fraction
  • Updated 2 existing V4 detect tests for corrected tensor keys

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):

lib tests:     426 passed, 0 failed
integration:    97 passed, 0 failed  (includes 7 new V4-Flash tests)
GGUF tests:     32 passed, 0 failed

ezutfen and others added 9 commits July 12, 2026 21:49
…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)
@ezutfen
ezutfen merged commit 81ff290 into main Jul 13, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant