Skip to content

Batch tensor I/O in checkpoint serialization - #76

Closed
sharmis-tp wants to merge 1 commit into
CanReader:masterfrom
sharmis-tp:fix/checkpoint-bulk-io
Closed

sharmis-tp wants to merge 1 commit into
CanReader:masterfrom
sharmis-tp:fix/checkpoint-bulk-io

Conversation

@sharmis-tp

Copy link
Copy Markdown
Contributor

Closes #54

Problem

save_tensors and load_tensors write and read each f32 value individually -- one write_all(&value.to_le_bytes()) or read_exact(&mut [0u8; 4]) per element. On large models this is a lot of tiny calls even with buffered I/O.

Fix

Collect each tensor's values into a single byte buffer and issue one write_all / read_exact per tensor. The on-disk format is unchanged (same little-endian f32 layout).

Test plan

  • All existing checkpoint round-trip and robustness tests pass unchanged -- the file format is identical.
  • Full test suite: 41 tests pass, 0 failures.

@CanReader
CanReader force-pushed the fix/checkpoint-bulk-io branch from 124a0b8 to 5cc8feb Compare November 12, 2026 08:57
@CanReader CanReader closed this Nov 12, 2026
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.

Checkpoints are written and read 4 bytes at a time

2 participants