[PR #91] [MERGED] GGUF reader: refuse a duplicate tensor name at open, naming the tensor and the file #2449

Closed
opened 2026-11-04 02:00:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/91
Author: @Avicennasis
Created: 9/28/2026
Status: ✅ Merged
Merged: 9/29/2026
Merged by: @Niko1221

Base: main ← Head: c/gguf-dup-name


📝 Commits (1)

  • c80131e gguf reader: a duplicate tensor name is refused at open, naming the tensor and the file

📊 Changes

3 files changed (+105 additions, -0 deletions)

View changed files

📝 CMakeLists.txt (+6 -0)
📝 include/strata/artifact/gguf_reader.hpp (+6 -0)
➕ src/artifact/gguf_reader_test.cpp (+93 -0)

📄 Description

One fail-closed change on the GGUF reader, with a test that runs without a model or a GPU. (Companion PR: setup names a missing or short shard and verify reads back the manifest sha256.)

gguf_reader.hpp: a duplicate tensor name is refused at open

GgufFile::find() is first-match over the tensor directory. A GGUF that carries one name twice therefore resolves that name to whichever entry came first; the other tensor's bytes are never read and nothing says so. GGUF has no index that could arbitrate between the two, so refusal is the whole fix: parse() keeps a set of the names it has seen and throws on the second sighting, naming both the tensor and the file:

GGUF: duplicate tensor name 'blk.0.attn_q.weight' in <path>

(llama.cpp's gguf_init_from_file refuses the same way.) find() itself is unchanged - the directory it walks is now unique.

Reproduction: gguf_reader_test (new, registered under STRATA_BUILD_TESTS beside strata-gguf, links only strata_artifact) writes a minimal GGUF v3 by hand - no metadata, two F32[8] tensors, 32-byte alignment - and opens it with the reader:

  • distinct names: opens, tensors().size() == 2, find() sees both;
  • the same name twice: refused at open; the error names the tensor and the file.

On main the second file opens and 3 of the 4 checks fail; with the change all 4 pass. The fixture was cross-checked against gguf-py's GGUFReader at the pinned llama.cpp commit and against strata-gguf (tensors 2, data_start 128, size 192). The file is closed before it is removed, for Windows.

What I ran, and where

Linux x86_64 (Ubuntu 24.04, AMD Ryzen 7 5800X - no AVX-512, no NVIDIA GPU), gcc 13.3.0, CMake 3.28.3, Python 3.12.3. The CUDA targets were not built (STRATA_ENABLE_CUDA=OFF); this is a claim about my machine, not yours.

  • cmake -B build-cpu -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=ON -DSTRATA_GGML_DIR=<llama.cpp at 3cf0325> - the published tree has no tests/, so I added an empty tests/CMakeLists.txt locally (not committed), and dequant_bf16_test links CUDA::cudart outside the CUDA guard, so a stub imported target was injected for configure only. Both are pre-existing; not touched here.
  • cmake --build build-cpu -j8 -- -k: every target built except dequant_bf16_test (cuda_runtime.h absent - expected without a toolkit; it is not a ctest).
  • ctest: 9 tests; 8 passed. gguf_reader_test passed (4/4 rows). expert_multi_test fails on this CPU with the kernel's own refusal (missing AVX512F ... AVX512-VBMI); the branch touches nothing under src/kernels.
  • git diff --check clean.

Branch is on c1e9033 (0.1.20); happy to rebase if it has moved by the time you look.


🔄 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/91 **Author:** [@Avicennasis](https://github.com/Avicennasis) **Created:** 9/28/2026 **Status:** ✅ Merged **Merged:** 9/29/2026 **Merged by:** [@Niko1221](https://github.com/Niko1221) **Base:** `main` ← **Head:** `c/gguf-dup-name` --- ### 📝 Commits (1) - [`c80131e`](https://github.com/Niko1221/Strata/commit/c80131ea670440d792c94c9e112005cd92bb1c14) gguf reader: a duplicate tensor name is refused at open, naming the tensor and the file ### 📊 Changes **3 files changed** (+105 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+6 -0) 📝 `include/strata/artifact/gguf_reader.hpp` (+6 -0) ➕ `src/artifact/gguf_reader_test.cpp` (+93 -0) </details> ### 📄 Description One fail-closed change on the GGUF reader, with a test that runs without a model or a GPU. (Companion PR: setup names a missing or short shard and `verify` reads back the manifest sha256.) ## `gguf_reader.hpp`: a duplicate tensor name is refused at open `GgufFile::find()` is first-match over the tensor directory. A GGUF that carries one name twice therefore resolves that name to whichever entry came first; the other tensor's bytes are never read and nothing says so. GGUF has no index that could arbitrate between the two, so refusal is the whole fix: `parse()` keeps a set of the names it has seen and throws on the second sighting, naming both the tensor and the file: ``` GGUF: duplicate tensor name 'blk.0.attn_q.weight' in <path> ``` (llama.cpp's `gguf_init_from_file` refuses the same way.) `find()` itself is unchanged - the directory it walks is now unique. Reproduction: `gguf_reader_test` (new, registered under `STRATA_BUILD_TESTS` beside `strata-gguf`, links only `strata_artifact`) writes a minimal GGUF v3 by hand - no metadata, two F32[8] tensors, 32-byte alignment - and opens it with the reader: - distinct names: opens, `tensors().size() == 2`, `find()` sees both; - the same name twice: refused at open; the error names the tensor and the file. On `main` the second file opens and 3 of the 4 checks fail; with the change all 4 pass. The fixture was cross-checked against gguf-py's `GGUFReader` at the pinned llama.cpp commit and against `strata-gguf` (`tensors 2, data_start 128, size 192`). The file is closed before it is removed, for Windows. ## What I ran, and where Linux x86_64 (Ubuntu 24.04, AMD Ryzen 7 5800X - no AVX-512, no NVIDIA GPU), gcc 13.3.0, CMake 3.28.3, Python 3.12.3. The CUDA targets were not built (`STRATA_ENABLE_CUDA=OFF`); this is a claim about my machine, not yours. - `cmake -B build-cpu -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=ON -DSTRATA_GGML_DIR=<llama.cpp at 3cf0325>` - the published tree has no `tests/`, so I added an empty `tests/CMakeLists.txt` locally (not committed), and `dequant_bf16_test` links `CUDA::cudart` outside the CUDA guard, so a stub imported target was injected for configure only. Both are pre-existing; not touched here. - `cmake --build build-cpu -j8 -- -k`: every target built except `dequant_bf16_test` (`cuda_runtime.h` absent - expected without a toolkit; it is not a ctest). - `ctest`: 9 tests; 8 passed. `gguf_reader_test` passed (4/4 rows). `expert_multi_test` fails on this CPU with the kernel's own refusal (`missing AVX512F ... AVX512-VBMI`); the branch touches nothing under `src/kernels`. - `git diff --check` clean. Branch is on `c1e9033` (0.1.20); happy to rebase if it has moved by the time you look. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:14 +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#2449
No description provided.