[PR #5075] [CLOSED] [Other] quant_formats --hf: give the header its file size for the bounds checks #5302

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5075
Author: @Tsury
Created: 11/3/2026
Status: ❌ Closed

Base: main ← Head: fix-quant-formats-hf


📝 Commits (1)

  • edd81a4 quant_formats --hf: give the header its file size for the bounds checks

📊 Changes

2 files changed (+74 additions, -3 deletions)

View changed files

📝 tools/quant_formats.py (+7 -3)
➕ tools/test_quant_formats_hf.py (+67 -0)

📄 Description

Problem and result

On v0.2.10 (ffa80d73), tools/quant_formats.py --hf REPO REV DIR fails on every repository before it prints anything:

  File "tools/gguf_reader.py", line 109, in _read
    left = self._size - self._pos
AttributeError: 'Header' object has no attribute '_size'

gguf_reader's header bounds checks (c15a90b2) read self._size and self._pos, which GGUFFile.__init__ sets from the open file. quant_formats.Header reuses the parser over HTTP range requests and has its own __init__, which never set them. Local paths are not affected (they use GGUFFile).

After this change, Header takes the file's size from the Hugging Face tree entry (size, which the listing already returns), so the same bounds checks apply to a remote header: a complete header parses, and a cut one is refused with a ValueError that names the file, as GGUFFile does.

Validation

On ffa80d73 + this change, Linux, Python 3.14:

  • Passed: python3 tools/quant_formats.py --hf huihui-ai/Huihui-Qwen3.8-Flash-Next-abliterated-v2-GGUF 411f1f7349c9711e6f75aa8d20e1612eb3a4d55d unsloth-UD-Q4_K_XL-V2 prints the role table (routed gate/up Q4_K with Q5_K in layer 2, down Q5_1 with Q8_0 in layers 2, 4, 30, 46, 47; PLE table IQ4_NL 26.82 GiB). Before the change: the error above.
  • Passed: python -m unittest tools.test_quant_formats_hf (new, 2 tests): it fails with the same AttributeError without the change.
  • Passed: python -m unittest tools.test_gguf_reader_malformed.
  • Not run: no engine, setup or GPU path changes.

🤖 Generated with Claude Code


🔄 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/5075 **Author:** [@Tsury](https://github.com/Tsury) **Created:** 11/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-quant-formats-hf` --- ### 📝 Commits (1) - [`edd81a4`](https://github.com/Niko1221/Strata/commit/edd81a41b1c9cb3521b9ca38264cd7a02335d6a5) quant_formats --hf: give the header its file size for the bounds checks ### 📊 Changes **2 files changed** (+74 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `tools/quant_formats.py` (+7 -3) ➕ `tools/test_quant_formats_hf.py` (+67 -0) </details> ### 📄 Description ## Problem and result On v0.2.10 (ffa80d73), `tools/quant_formats.py --hf REPO REV DIR` fails on every repository before it prints anything: ``` File "tools/gguf_reader.py", line 109, in _read left = self._size - self._pos AttributeError: 'Header' object has no attribute '_size' ``` `gguf_reader`'s header bounds checks (c15a90b2) read `self._size` and `self._pos`, which `GGUFFile.__init__` sets from the open file. `quant_formats.Header` reuses the parser over HTTP range requests and has its own `__init__`, which never set them. Local paths are not affected (they use `GGUFFile`). After this change, `Header` takes the file's size from the Hugging Face tree entry (`size`, which the listing already returns), so the same bounds checks apply to a remote header: a complete header parses, and a cut one is refused with a `ValueError` that names the file, as `GGUFFile` does. ## Validation On ffa80d73 + this change, Linux, Python 3.14: - **Passed:** `python3 tools/quant_formats.py --hf huihui-ai/Huihui-Qwen3.8-Flash-Next-abliterated-v2-GGUF 411f1f7349c9711e6f75aa8d20e1612eb3a4d55d unsloth-UD-Q4_K_XL-V2` prints the role table (routed gate/up Q4_K with Q5_K in layer 2, down Q5_1 with Q8_0 in layers 2, 4, 30, 46, 47; PLE table IQ4_NL 26.82 GiB). Before the change: the error above. - **Passed:** `python -m unittest tools.test_quant_formats_hf` (new, 2 tests): it fails with the same `AttributeError` without the change. - **Passed:** `python -m unittest tools.test_gguf_reader_malformed`. - **Not run:** no engine, setup or GPU path changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:34:12 +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#5302
No description provided.