Investigation: DeepSeek-V4-Flash onboarding blocked on missing HF reference#213
Conversation
|
@copilot you can find model architecture here: https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash/blob/main/inference/model.py |
Thanks, I've now read
A responsible implementation is multi-session and needs new reusable components (CSA, HCA, mHC, Compressor, Indexer), plus a custom golden-tensor harness driven by the reference engine on tiny configs. Before I start that, could you confirm which of the 3 paths in the PR description you want? Specifically:
I'd like to avoid landing either an unverified graph builder or a partial stub without your go-ahead on scope. |
|
@copilot as long as the model is representable in onnx, you can implement the new components in mobius. If there are constructs not representable (maybe sparse attention? Is that correct?), please comment here. A reference is xadupre/mbext#330 which seems to do the job. Feel free to use it as reference or spot any issues if there are. |
Thanks for the green light. Quick assessment on ONNX representability and a flag on the mbext reference: ONNX representability — everything maps, with one perf caveat:
Nothing in the V4 forward path is ONNX-non-representable. The only thing the reference does that we cannot match 1:1 is the fused FP4/FP8 gemm + fused sparse-attn kernels, and that's a perf gap, not a correctness gap. Concern about the mbext reference (xadupre/mbext#330): that PR routes
A V3 graph loaded with V4 weights will produce wrong logits. So I'd treat that PR as a config-aliasing stub for genai builder, not a parity reference for mobius. Worth flagging back to them too. Proposed plan for this PR (multi-session, will land in pieces):
Before I start cutting code: do you want all of (1)–(4) in this one PR, or should I split it (e.g. components first in a separate PR, then the model + verification harness)? Given the size of the diff a split would be much easier to review, but happy either way. |
Performance Comparison
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@copilot check if this is done is main or if anything is missing |
Done in
Deferred follow-ups (explicitly documented in the PR description and
So the onboarding itself is complete; the remaining items are the sparse-attention / quantization follow-ups called out at merge time. This PR can be closed. Nothing to do here. |
Onboarding
deepseek-ai/DeepSeek-V4-Flash(model_type: deepseek_v4) as requested in the issue. After investigation, no code changes are proposed in this PR — the task cannot be completed as a minimal, verifiable change given the current state of the upstream model. Details below for reviewer decision on scope.Architectural delta vs. existing
deepseek.py(V2/V3)From
config.jsonon the HF repo, V4 introduces components with no precedent in mobius:compress_ratioslist, plusindex_head_dim,index_n_heads,index_topk,compress_rope_theta. Not expressible via the existingDeepSeekMLAcomponent.hc_eps,hc_mult,hc_sinkhorn_iters,num_hash_layers(Sinkhorn-normalized routing between layers).o_lora_rank=1024,o_groups=8.scoring_func: "sqrtsoftplus"(current gate supportssoftmax/sigmoidonly).swiglu_limit: 10.0.Blocker: no HuggingFace
transformersreferenceThe HF repo ships weights (46 shards), a technical-report PDF, and a standalone
inference/model.py+ customkernel.py. It does not shipmodeling_deepseek_v4.py/configuration_deepseek_v4.py, anddeepseek_v4is not registered intransformers.AutoConfig.from_pretrained(..., trust_remote_code=True)fails.Consequences for the mobius onboarding pattern:
_registry.pykeys on HFmodel_type→ requires an HF config class.tests/integration_test.pyrequires parity withAutoModelForCausalLMatatol=1e-4→ no reference to compare against.preprocess_weights) has no canonical HF state_dict to target; only the custom inference engine's naming exists.A scaffold (config + registry + graph builder) is technically possible but would require inventing implementations of CSA/HCA/mHC/sqrtsoftplus/Sinkhorn hyper-connections with no way to verify correctness against a reference, violating the repo's root-cause-before-remedy rule and risking silent incorrect output from
build("deepseek-ai/DeepSeek-V4-Flash").Paths forward (need reviewer input)
transformerssupport to land, then port against it (the V3 pattern).inference/model.py, building a custom golden-output harness that runs the reference engine on tiny inputs. Multi-session effort; new components required.Please confirm which path before I proceed.