Native Transformers text-backbone support proposal (#48721)

#42
by malaiwah - opened

Hello DeepSeek team and community,

I have an open community proposal for native Transformers support for the DeepSeek-V4.1-Flash text backbone:

Would someone from DeepSeek be willing to review the architecture and checkpoint-loading semantics? This is an unmerged proposal, not support already shipped in a Transformers release, and not an officially endorsed integration.

Scope

The implementation covers the composite/text configuration, published checkpoint-name conversion, FP8/packed-FP4 weight loading, Engram row lookup, single-pass mHC, CSA2 Full/Reindex/Reuse source sharing, hierarchical indexing, and cached text generation. It follows the existing Transformers model, quantizer and expert-parallel conventions.

Not included: the vision tower/processor/multimodal wrapper, DSpark/MTP speculative decoding, a tool-calling server, or bounded NVMe expert/Engram streaming. The release's Python/Rust prompt encoders are still needed; loading the model does not supply a missing Jinja chat template.

Evidence and limits

The PR links released-checkpoint loading/generation runs, 8×H200 expert-parallel measurements (about 327 ms/token in the measured batch-1 greedy setup), and passcode retrieval at approximately 262k, 524k and 1,048k prompt tokens. These are specific measurements, not a comprehensive quality benchmark or proof of every backend/batch mode.

The numerical architecture comparison is a reduced five-layer, random-weight FP32 CPU run with local kernel adaptations, not full-checkpoint numerical parity. At prefill 200 + 24 teacher-forced decode steps it measured maximum absolute logit differences of 5.461e-4 with activation fake quantization and 8.404e-5 with it disabled, with 100% sampled argmax agreement. Engram is tested separately rather than enabled in that full-model comparison.

We also reproduced the reference index-key ownership issue already addressed by @ZenAlexa 's PR #12. Thank you for the official-kernel H100 checks there. Our complementary CPU reference-model self-consistency reproduction and scripts are in discussion #41; we have supported the existing PR instead of opening a duplicate.

Could you review Full/Reindex/Reuse ownership, hierarchical visibility, QAT placement, and the Engram/checkpoint mapping against the intended implementation? A canonical layer trace or additional reference test cases would be especially helpful.

malaiwah changed discussion title from Native Transformers text-backbone support proposal: request for DeepSeek review (#48721) to Native Transformers text-backbone support proposal (#48721)

I made some updates to the repo, work is still in progress.

Few more things fixed in Transformers commit 62d7ebd: padding-aware compressed attention, preservation of composite quantization metadata in bare text loads, and atomic refusal of unsupported CSA

Vision follow-up opened as #48768: https://github.com/huggingface/transformers/pull/48768

It is a draft dependent on #48721, with a vision-only diff so reviewers can isolate the addition. The author has reviewed all code; AI-assisted provenance is disclosed. The existing text PR remains separate.

The vision implementation has 296 passing model/processor tests and reduced-model reference checks.

Holy AI agent
We can see you're using HF CLI with a coding agent (and you speak like one)

Holy AI agent
We can see you're using HF CLI with a coding agent (and you speak like one)

And I need your clothes, your boots and your motorcycle...

Yes, there is a bit of that, but I still come behind and review as a mere human.

Sign up or log in to comment