Skip to content

tensor_file: remove parse_safetensors and Weights::from_bytes - #121

Merged
ling0322 merged 1 commit into
mainfrom
drop-in-memory-safetensors
Oct 14, 2026
Merged

ling0322 merged 1 commit into
mainfrom
drop-in-memory-safetensors

Conversation

@ling0322

Copy link
Copy Markdown
Owner

Removes the in-memory safetensors path: parse_safetensors, Weights::from_bytes, and the private collect_bytes and each_copied behind them. Only tests used them. They now write their bytes to a temporary file and read it with read_safetensors / Weights::from_files, which is the mmap path models use.

Also fixes main: #112 added a Metal test that names &dyn ParamSource, which #118 removed. The two merged without a conflict, so the foundation test target on main does not compile.

Test changes

  • foundation.rs gains read_bytes and weights_from, which go through a TempFile. stored, stored_typed, source and the corrupt-file cases use them.
  • a_mapped_package_runs_like_one_read_into_memory now compares the mapped package against the same weight put on the card with Weights::from_tensors. It needs CUDA and was not run here.
  • says_that_low_vram_is_for_cuda_and_metal_alone calls Weights::empty directly. That is where the refusal is checked, so the empty_file helper is removed.

Testing

  • ./build/unittest: all pass.
  • cargo test: 374 passed, 0 failed.
  • Model tests (--ignored) were not run.

🤖 Generated with Claude Code

Nothing outside the tests read a package out of a buffer. The tests now write
their bytes to a temporary file and read it the way a model does, through the
mapping. Also fixes the foundation test target on main, which #112 left
naming the removed ParamSource.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ling0322
ling0322 force-pushed the drop-in-memory-safetensors branch from f4d0661 to 44db776 Compare October 14, 2026 03:08
@ling0322
ling0322 merged commit 084bc7c into main Oct 14, 2026
3 checks passed
@ling0322
ling0322 deleted the drop-in-memory-safetensors branch October 24, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant