[PR #4348] [CLOSED] [Engine] GGUF reader: size the integer tensors, so a complete DeepSeek first shard is accepted and a cut one refused #5017

Closed
opened 2026-11-07 16:32:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4348
Author: @lu123bing
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: fix-gguf-integer-tensor-geometry


📝 Commits (1)

  • 7e508c8 gguf reader: size the integer tensors, so a complete DeepSeek first shard is accepted and a cut one refused

📊 Changes

3 files changed (+48 additions, -8 deletions)

View changed files

📝 tests/terminal/test_own_files.py (+22 -2)
📝 tools/gguf_reader.py (+2 -0)
📝 tools/test_setup_shard_check.py (+24 -6)

📄 Description

Problem and result

tools/gguf_reader.py sizes every tensor from BLOCK_GEOMETRY (elements per block, bytes per block), and that table has no row for the integer types GGML_TYPES already names (I8, I16, I32, I64). strata_control/gguf_preflight.py:165 reads "no geometry" as "unsupported file", so a complete GGUF whose tensor directory holds an integer tensor is refused:

  • setup's own-file fallback (setup.py:3088, own_gguf_is_whole → False) stops with "it may be cut short or another version";
  • the app's "use your own GGUF" reports my-own-model.gguf: it stores weights in a format Strata does not read;
  • tools/iq_pack.py:165 refuses the file as "unsupported or truncated tensor".

IST-DASLab's DeepSeek-V4.1 first shard stores its Engram hash parameters this way (tools/dsv41/pack_gguf.py, int_tensors_to_engram: engram_token_map I32, engram_primes / engram_offsets / engram_multipliers I64).

The same hole in the other direction: setup.check_shards decides whether a shard is whole with t.expected_bytes() or 0 (setup.py:3324), so a shard cut inside an integer tensor passes as whole and the engine fails much later, at the first tensor that runs past the end — the failure that check exists to catch.

After the change the reader sizes the four types, so the complete file is accepted and the cut one is refused.

#4256 reports this refusal from the fallback for an IST-DASLab first shard, names BLOCK_GEOMETRY as the suspect and records that he could not identify the tensor that triggers it. This does not depend on which shard it is, and it fixes the mechanism. That issue's own size stop for the pinned 0.2.6 files is handled separately by DSV41_NEW_SHARD1 (setup.py:710), which this leaves alone — the fallback still has to accept a complete file outside the pins, such as ISTA's own patch_chat_template.py output or a fine-tune. No new feature and no default change, so no scope note.

Not this change: #4237 reports the same DeepSeek set refused as incomplete_or_invalid_shard_set, which is the app's folder/name recognition; #4160 is a modified Qwen set refused as an unknown size. Both are different checks.

Approach

Four rows in BLOCK_GEOMETRY, one value per block, with the values tools/dsv41/ista_intake.py:112 already uses for the same types. The quantised encodings are untouched and an unknown type is still refused; the effect is limited to the four types, in the places that size a tensor from this table — the preflight in front of setup and the app, setup.whole_shard, setup.check_shards and the tools that read a tensor's size.

Validation

Environment: main at 5e8a4cca plus this branch, Linux, Python 3.14, no GPU. Commands run from the repository root.

Passed:

  • python -m pytest tests/terminal -q: 10 failed, 1868 passed, 49 skipped, 343 subtests passed, 21 min. The same 10 ids fail on a clean worktree of main without this branch, so they are this machine, not the change: a HIP library path expected in Windows form, a SYCL package choice, llama.cpp's gguf-py not installed, Strata-data/free-space detection, three TUI text assertions, three light-theme colour assertions, one telemetry message mismatch.
  • python -m pytest tests/terminal/test_own_files.py -q: 28 passed (the new IntegerTensors class is two of them).
  • python tools/test_setup_shard_check.py: 4 tests, OK (two new).
  • The new tests fail on the unpatched reader for the reason this PR claims: both IntegerTensors tests with ProfileError: GGUF tensor has an unsupported encoding or shape (strata_control/gguf_preflight.py:165), test_a_complete_gguf_with_integer_tensors_is_whole with own_gguf_is_whole → False, and test_a_shard_cut_inside_an_integer_tensor_is_still_refused with SystemExit not raised (setup.py:3324). With the rows they pass.
  • The new sizing test fails on a wrong row in either direction and for every one of the four types: with BLOCK_GEOMETRY["I32"] at (1, 9) and at (1, 2), and ["I8"] at (1, 4), it fails; the fixture's bytes never come from that table, so a changed row moves the expectation.
  • Direct before/after on tiny GGUF v3 files with an I32 and an I64 tensor (no weights, no download): inspect_metadata refuses the complete file before and reports {'F32': 1, 'I32': 1, 'I64': 1} after; check_shards accepts a copy cut 8 bytes inside the I64 tensor before and refuses it (is short: 240 of 256 bytes) after; models.plan_import reports my-own-model.gguf: it stores weights in a format Strata does not read before and no encoding issue after.

Failed:

None observed.

Not run:

The C++ builds and anything that runs an engine (CUDA, HIP, SYCL, Metal): no GPU here, and no C++ or engine file is touched. Real shard files: they are tens of GB, so the fixtures are the same v3 header and tensor directory, not the weights. Windows and macOS.

Limits

  • The C++ reader has its own table (include/strata/artifact/gguf_reader.hpp) with I8 but not I16/I32/I64, and src/core/native_dense.cpp:319 refuses a tensor it cannot size. This change stops the Python check in front of setup and the app from turning a valid file away; it does not make the engine read a type it does not read. F64 was already Python-only in the same table, so the asymmetry is older than this change.
  • tools/iq_pack.py shares that table and used "no geometry" as "unsupported tensor": a tensor of these types now gets past that look-up and classifies as native (tools/iq_pack.py:288). That tool builds the Qwen packs; this change does not make its output right for a file with integer tensors, and no such pack was built here.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4348 **Author:** [@lu123bing](https://github.com/lu123bing) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-gguf-integer-tensor-geometry` --- ### 📝 Commits (1) - [`7e508c8`](https://github.com/Niko1221/Strata/commit/7e508c8bc58a6fa5ca04a504c80bde7e6ca4a596) gguf reader: size the integer tensors, so a complete DeepSeek first shard is accepted and a cut one refused ### 📊 Changes **3 files changed** (+48 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `tests/terminal/test_own_files.py` (+22 -2) 📝 `tools/gguf_reader.py` (+2 -0) 📝 `tools/test_setup_shard_check.py` (+24 -6) </details> ### 📄 Description ## Problem and result `tools/gguf_reader.py` sizes every tensor from `BLOCK_GEOMETRY` (elements per block, bytes per block), and that table has no row for the integer types `GGML_TYPES` already names (I8, I16, I32, I64). `strata_control/gguf_preflight.py:165` reads "no geometry" as "unsupported file", so a complete GGUF whose tensor directory holds an integer tensor is refused: - `setup`'s own-file fallback (`setup.py:3088`, `own_gguf_is_whole` → `False`) stops with "it may be cut short or another version"; - the app's "use your own GGUF" reports `my-own-model.gguf: it stores weights in a format Strata does not read`; - `tools/iq_pack.py:165` refuses the file as "unsupported or truncated tensor". IST-DASLab's DeepSeek-V4.1 first shard stores its Engram hash parameters this way (`tools/dsv41/pack_gguf.py`, `int_tensors_to_engram`: `engram_token_map` I32, `engram_primes` / `engram_offsets` / `engram_multipliers` I64). The same hole in the other direction: `setup.check_shards` decides whether a shard is whole with `t.expected_bytes() or 0` (`setup.py:3324`), so a shard cut inside an integer tensor passes as whole and the engine fails much later, at the first tensor that runs past the end — the failure that check exists to catch. After the change the reader sizes the four types, so the complete file is accepted and the cut one is refused. ## Related discussion #4256 reports this refusal from the fallback for an IST-DASLab first shard, names `BLOCK_GEOMETRY` as the suspect and records that he could not identify the tensor that triggers it. This does not depend on which shard it is, and it fixes the mechanism. That issue's own size stop for the pinned 0.2.6 files is handled separately by `DSV41_NEW_SHARD1` (`setup.py:710`), which this leaves alone — the fallback still has to accept a complete file outside the pins, such as ISTA's own `patch_chat_template.py` output or a fine-tune. No new feature and no default change, so no scope note. Not this change: #4237 reports the same DeepSeek set refused as `incomplete_or_invalid_shard_set`, which is the app's folder/name recognition; #4160 is a modified Qwen set refused as an unknown size. Both are different checks. ## Approach Four rows in `BLOCK_GEOMETRY`, one value per block, with the values `tools/dsv41/ista_intake.py:112` already uses for the same types. The quantised encodings are untouched and an unknown type is still refused; the effect is limited to the four types, in the places that size a tensor from this table — the preflight in front of setup and the app, `setup.whole_shard`, `setup.check_shards` and the tools that read a tensor's size. ## Validation Environment: `main` at `5e8a4cca` plus this branch, Linux, Python 3.14, no GPU. Commands run from the repository root. **Passed:** - `python -m pytest tests/terminal -q`: 10 failed, 1868 passed, 49 skipped, 343 subtests passed, 21 min. The same 10 ids fail on a clean worktree of `main` without this branch, so they are this machine, not the change: a HIP library path expected in Windows form, a SYCL package choice, llama.cpp's `gguf-py` not installed, `Strata-data`/free-space detection, three TUI text assertions, three light-theme colour assertions, one telemetry message mismatch. - `python -m pytest tests/terminal/test_own_files.py -q`: 28 passed (the new `IntegerTensors` class is two of them). - `python tools/test_setup_shard_check.py`: 4 tests, OK (two new). - The new tests fail on the unpatched reader for the reason this PR claims: both `IntegerTensors` tests with `ProfileError: GGUF tensor has an unsupported encoding or shape` (`strata_control/gguf_preflight.py:165`), `test_a_complete_gguf_with_integer_tensors_is_whole` with `own_gguf_is_whole` → `False`, and `test_a_shard_cut_inside_an_integer_tensor_is_still_refused` with `SystemExit` not raised (`setup.py:3324`). With the rows they pass. - The new sizing test fails on a wrong row in either direction and for every one of the four types: with `BLOCK_GEOMETRY["I32"]` at `(1, 9)` and at `(1, 2)`, and `["I8"]` at `(1, 4)`, it fails; the fixture's bytes never come from that table, so a changed row moves the expectation. - Direct before/after on tiny GGUF v3 files with an I32 and an I64 tensor (no weights, no download): `inspect_metadata` refuses the complete file before and reports `{'F32': 1, 'I32': 1, 'I64': 1}` after; `check_shards` accepts a copy cut 8 bytes inside the I64 tensor before and refuses it (`is short: 240 of 256 bytes`) after; `models.plan_import` reports `my-own-model.gguf: it stores weights in a format Strata does not read` before and no encoding issue after. **Failed:** None observed. **Not run:** The C++ builds and anything that runs an engine (CUDA, HIP, SYCL, Metal): no GPU here, and no C++ or engine file is touched. Real shard files: they are tens of GB, so the fixtures are the same v3 header and tensor directory, not the weights. Windows and macOS. ## Limits - The C++ reader has its own table (`include/strata/artifact/gguf_reader.hpp`) with I8 but not I16/I32/I64, and `src/core/native_dense.cpp:319` refuses a tensor it cannot size. This change stops the Python check in front of setup and the app from turning a valid file away; it does not make the engine read a type it does not read. F64 was already Python-only in the same table, so the asymmetry is older than this change. - `tools/iq_pack.py` shares that table and used "no geometry" as "unsupported tensor": a tensor of these types now gets past that look-up and classifies as native (`tools/iq_pack.py:288`). That tool builds the Qwen packs; this change does not make its output right for a file with integer tensors, and no such pack was built here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:32:03 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5017
No description provided.