mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #92] [MERGED] setup: name a missing or short shard with its numbers; verify reads back the manifest sha256 #2451
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2451
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/92
Author: @Avicennasis
Created: 9/28/2026
Status: ✅ Merged
Merged: 9/29/2026
Merged by: @Niko1221
Base:
main← Head:c/shard-triage📝 Commits (2)
a349ec3setup: a missing or short shard is named with its numbers before anything reads it5427527strata_pack verify: read back the source sha256 the manifest recorded📊 Changes
3 files changed (+153 additions, -4 deletions)
View changed files
📝
setup.py(+25 -4)📝
tools/strata_pack.py(+9 -0)➕
tools/test_shards.py(+119 -0)📄 Description
Two fail-closed changes on the setup/verify seam, one per commit, each with a test that runs without a model or a GPU. (Companion PR: the GGUF reader refuses a duplicate tensor name.)
setup.py: a missing or short shard is named with its numbers before anything reads itSetup checked a shard by presence only (
missing <path>), and a download byContent-Lengthonly. A shard copied short into--gguf-dir, a.partrenamed by hand, or a download an older setup finished without a.donemark passed as a model file; the failure came later, from the packer or the engine, at the first tensor past the end, naming neither the file nor the shortfall.check_shards()reads each shard's header (the tensor directory, not the data - milliseconds on the 34 GB shard) and compares the file's length with what that directory needs,data_start + max(offset + bytes):A header that does not parse is refused by name (
... is not a whole GGUF shard (...)); a missing file staysmissing <path>.download()'s "could not finish" line now states the bytes on disk and the bytes the server announced instead of just the name. A tensor of a type the Python reader has no geometry for counts as 0 bytes, so the check can only under-estimate: it never refuses a whole file.Test:
tools/test_shards.py(python -m unittest tools.test_shards, unittest liketools/test_calibrate.py), over a minimal GGUF written by hand: whole shards pass; a missing, a short and a header-truncated shard each stop setup with the file named and, for the short one, both sizes and the difference.strata_pack.py verify: read back the source sha256 the manifest recordedbuildwritessource.shard1_sha256/shard2_sha256intomanifest.json(unless--skip-hash, which is how setup builds), and nothing read them back - 0 readers insrc/,serve/,setup.py,tools/. A pack verified against a different shard than it was built from reported tensor MISMATCHes, or passed under--limit.A full
verify(no--limit) now hashes the shard it is handed first and fails naming both digests when they differ:A manifest without the field (setup's packs) and a
--limitrun are unchanged, so the quick check stays quick. Shard 2's hash is recorded but not checked here:verifyis not handed that file. Same test module: a matching hash passes, a wrong one fails naming both, an absent hash or--limitskips. Onmainthe wrong-hash case returns 0.Not in this PR, noted for later: the download itself still has no hash to check against - the manifest's hashes are computed from the downloaded file, so they cannot validate it. Hugging Face exposes the LFS object's sha256 on the resolve URL (
X-Linked-Etag); hashing the stream as it is written would make that a free check, but resume needs the partial re-hashed and the HTTP path mocked in a test, so it is a separate change.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.python -m unittest tools.test_shards: 7 tests OK. Against an export ofmainwith the same test file: 1 failure (wrong-hash verify returns 0), 4 errors (check_shardsdoes not exist).python -m unittest tools.test_calibrate10 OK;serve.test_server26 OK;tools.test_iq_pack8 OK (withSTRATA_GGUF_PYpointing at the pinned llama.cpp).git diff --checkclean.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.