Skip to content

deepseek_v41: Pack.open reads a shard's header length with core's headerSize - #1903

Merged
ashhart merged 2 commits into
ashhart:mainfrom
jschmied:dsv41-pack-headersize
Nov 2, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
jschmied:dsv41-pack-headersize

Conversation

@jschmied

@jschmied jschmied commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Part of #1872, the second headerSize move. DeepSeek v4.1's Pack.open reads a shard's header length with core's safetensors.headerSize, not with its own 1 GiB cap.

  • Before: the length word, checked against the file and a 1 GiB cap, then allocated. A length up to 1 GiB was allocated before core's own parse would refuse it. Now: headerSize first: core's 100 MB limit and the file length, before any allocation.
  • Host test (deepseek_v41/pack.zig): "a shard's header length is read as core reads it: past the file, past 100 MB or the u64 maximum is refused". It runs one valid shard, which still opens with its tensor's 12 bytes, and four bad lengths: one byte past the file, 100 MB + 1 (in a sparse file long enough to hold it), 2^64 − 1 and 2^64 − 8.
  • Valid checkpoints: no parse changes. On the Safetensors header readers outside core: 5 crash on malformed files, 2 can overrun device buffers, 1 returns the wrong tensor #1872 fuzz run, this reader disagrees with core 0 times and crashes 0 times.

Checks (GB10, on main 58375fe00): lean 0 new, zig build test and the CI set pass, git diff --check clean.

@ashhart
ashhart force-pushed the dsv41-pack-headersize branch from e940035 to 6498096 Compare November 2, 2026 10:32
@ashhart
ashhart merged commit 9ac00aa into ashhart:main Nov 2, 2026
7 checks passed
@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied! This is in TensorFold 1.2.2, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.2

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.

2 participants