Repository navigation
feat(deepseek): carry V4.1 native source and mapped PLE replay - #3613
Merged
Qubitium merged 1 commit intoNov 9, 2026
Merged
Conversation
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
Qubitium
force-pushed
the
upstream/33-v41-native-source-20261108
branch
from
November 9, 2026 09:58
19cdbb7 to
a0f2404
Compare
Qubitium
reviewed
Nov 9, 2026
Qubitium
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed against current main.
The V4.1 source layer is bounded and fails closed where it matters:
V41Sourcevalidatesmodel_typeand every shard basename/presence, refuses full-tensor PLE loads (engram.embedmust go throughMappedPLETable), and reads one tensor at a time withcopy=True.- Scaled tensors are handled narrowly: INT8 is only accepted for
(layers|mtp).<n>.ffn.experts.<e>.w[123].weightand dequantized through the DeepSeek FP4 expert helper; FP8 requires a block-32 scale grid and is expanded in 32-row chunks so a whole matrix never inflates to FP32 at once. packed_projectionrestricts EXL3 reload to routed projections, bounds layer/expert ids, requires exactly the four packed buffers, and validates trellis/suh/svh/mcg dtype and geometry before reconstruction.MappedPLETablemmaps FP8 E4M3 values plus E8M0 scales read-only, bounds the safetensors header and gather row count, validates payload extents/overlap, returns owned row bytes, and supports separate value/scale shards plusprefetch/release/close.v41_replay,v41_native, and thedeepseek_v41definition carry the mapped PLE replay and native block contracts.
Validation note: this layer adds no tests of its own. ple_mmap, v41_replay, and v41_source import cleanly; v41_native and deepseek_v41 require the Transformers release that ships deepseek_v41 and are not registered by this PR, so they remain dormant on the installed Transformers 5.22.1. Cleanup was import ordering only.
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
Carry the V4.1-specific architecture contract, packed source execution, one-tensor source reads, memory-mapped PLE gathers, native attention/index selection, RMS normalization and explicit mHC/window replay state. This family remains an explicit calibration API, without a new automatic MODEL_MAP registration.
This is layer 33/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3612. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream
main.Incremental change: 7 files, +1009/−0 lines, including carried tests and the mechanism reference. No merge is automatic. Review value and API shape first; substantial rework can follow that feedback.
Flow and existing-code boundary
flowchart TD S0["MappedPLETable"] M0_0["MappedPLETable.__init__"] M0_1["MappedPLETable.__enter__"] S1["V41Source"] M1_0["V41Source.__init__"] M1_1["V41Source.load_dspark_input"] M1_2["V41Source.load_main_input"] S2["V41NativeLinear"] M2_0["V41NativeLinear.__init__"] M2_1["V41NativeLinear.forward"] S3["V41ReplayBatch"] M3_0["V41ReplayBatch.prepare"] E["Captured, IndexError, RuntimeError, ValueError"] S0 -. "exposes" .-> M0_0 S0 -. "exposes" .-> M0_1 S0 -->|"raises on rejected input/state"| E S1 -. "exposes" .-> M1_0 S1 -. "exposes" .-> M1_1 S1 -. "exposes" .-> M1_2 S1 -->|"calls where selected"| S2 S1 -->|"raises on rejected input/state"| E S2 -. "exposes" .-> M2_0 S2 -. "exposes" .-> M2_1 S2 -->|"raises on rejected input/state"| E S3 -. "exposes" .-> M3_0 S3 -->|"raises on rejected input/state"| E style E fill:#fee,stroke:#b22gptqmodel/utils/ple_mmap.py:15:MappedPLETablegptqmodel/utils/v41_source.py:45:V41Sourcegptqmodel/utils/v41_native.py:212:V41NativeLineargptqmodel/utils/v41_replay.py:26:V41ReplayBatchCommitted reference: docs/v41-native-source.md, linked from README. Class entry points/calls and rejected-state paths describe code present in this branch, rather than planned integrations.
Validation
Carried test files: No standalone test file existed in the fork for this helper; retained original implementation and documented the structural checks.
This packaging pass checked Python parsing, whitespace, dependency order and balanced Mermaid blocks. The author reports successful prior use of these features. Per the requested resource limit and feedback-first scope, existing model quantization, GPU/ROCm tests, heavyweight CPU workloads and full model benchmarks were not rerun; no new performance or model-accuracy claim is made. Tests accompanying earlier stack layers retain their previously reported results.
V4.1 remains an explicit native calibration/replay API and is not added to MODEL_MAP. The source requires its native/reference implementation; upstream inventory documentation alone does not provide that runtime.