mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1859] [CLOSED] weights: add an opt-in read-only safetensors source (no engine changes) #3723
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#3723
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/1859
Author: @spideytznn
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:contribute/safetensors-reader📝 Commits (1)
4b87951weights: add a standalone read-only safetensors source with adversarial tests📊 Changes
12 files changed (+26435 additions, -0 deletions)
View changed files
➕
docs/SAFETENSORS_SOURCE.md(+74 -0)➕
include/strata/weights/safetensors.hpp(+76 -0)➕
native_safetensors/CMakeLists.txt(+39 -0)➕
src/weights/json_checked.hpp(+66 -0)➕
src/weights/safetensors.cpp(+286 -0)➕
src/weights/source_inspect.cpp(+69 -0)➕
src/weights/source_test.cpp(+81 -0)➕
third_party/nlohmann/.gitattributes(+3 -0)➕
third_party/nlohmann/LICENSE.MIT(+21 -0)➕
third_party/nlohmann/README.md(+20 -0)➕
third_party/nlohmann/json.hpp(+25526 -0)➕
tools/test_safetensors_reader.py(+174 -0)📄 Description
Original NVIDIA ModelOpt NVFP4 checkpoints cannot currently be consumed as safetensors by Strata's weight-source interface. This first patch provides a read-only source and standalone inspector, ahead of model/layout and runtime integration. It is related to #1858; the complete experimental implementation and its measured limits are linked there.
The source validates the index and all shard headers, retains physical shapes and absolute byte ranges, performs bounded coalesced reads into caller-owned spans, accounts for bytes by family, and can seal expert/MTP reads or close all resident startup handles. It rejects malformed descriptors, duplicate JSON keys, unsafe paths, index mismatches and out-of-bounds reads. nlohmann/json 3.12.0 is vendored with its MIT license and hash; configuration downloads nothing.
This is explicitly opt-in through
cmake -S native_safetensors .... All 12 changed paths are additions. The root CMake file, every existing engine/backend/setup file, CLI and runtime default are unchanged byte-for-byte against the tested upstream baselinefb58e0dbc8399662c0e47c76578c6e878b14f6cf. No complete inference or speed improvement is claimed by this patch; NVFP4 layout binding, CUDA execution, scheduling and server integration are separate follow-ups.Validation on Windows, MSVC 19.44.35228 / Python 3.13.15:
/W4 /WX; CTest passes 2/2 in each configuration.No CUDA, HIP or SYCL backend files are touched or built. Linux execution has not been validated. Build commands, behavior and limitations are documented in
docs/SAFETENSORS_SOURCE.md.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.