Repository navigation
Consume external weights one tensor at a time - #25
Draft
matthargett wants to merge 1 commit into
Draft
matthargett wants to merge 1 commit into
matthargett wants to merge 1 commit into
Conversation
Read validated SafeTensors headers and individual manifest spans, transferring each payload to an optional consuming sink. Preserve the inline resolver and packed/BF16 conversion contracts. Document that empty replacement payloads require caller-owned external storage. Validation: 17 external-weight tests pass, including consuming ownership, sink errors, malformed archive extents, manifest bounds, legacy resolution and packed storage cases.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is to get peak memory usage down and performance up on memory-constrained devices like Apple Watch and iPhone SE 2 (A13 like iPhone 11, but less physical memory).
Local-device graph compilers currently resolve an entire external weight archive into owned AST payloads before they can write backend storage. Large bundles briefly retain both representations. This adds an optional consuming sink and reads one validated tensor/span at a time; the existing inline resolver keeps its API and behavior.
The sink receives ownership of a tensor's bytes and returns its replacement AST payload. Returning empty bytes requires equivalent caller-owned external storage and does not produce a standalone resolved graph. SafeTensors bounds, dtype/shape, packed four-bit metadata, BF16 conversion and sanitized-name checks remain in force. Manifest spans keep their existing validation contract. The touched file's mixed line endings are normalized to LF.
Validation: 17 external-weight tests pass, including four new consuming ownership/error, malformed archive and manifest-span tests. This is setup-time storage work, with no inference kernels or network dependency. Draft prerequisite for the native-only RustNN work tracked in rebeckerspecialties/rustnn#38 (comment).