Repository navigation
feat(storage): lossless repackTo and explicit lossy requantizeTo (SKEEP-008 phase B1) - #1470
Merged
Merged
Conversation
…EP-008 B1, #1433) TensorStorage.repackTo now does the lossless re-encodings instead of always throwing: any packed encoding TensorStorageFactory.toTensorData can decode -> Dense(4), and narrow dense (Dense(2) FP16/BF16) -> Dense(4), decoded to FP32 bit-exactly. A lossy direction still throws, now naming requantizeTo. requantizeTo is the visible lossy call: targets are exactly Requantizers.supported (the set a loader's EncodingRequest.RequantizeTo accepts), the target and shape are validated before the buffer is read (Requantizers.validateShape, shared with quantize), a packed source is dequantized to FP32 first, and the result is owned packed host storage. Both gain a BufferResolver overload for FileBacked/Aliased sources. TensorStorageFactory.toTensorData learns the remaining packed decoders (Q4_0, Q5_0, Q5_1, Q5_K, Q6_K, BITNET_PLANES, BITNET_B1_58), so repackTo covers every packed encoding with a dequantizer. SKEEP-008 records that narrow-dense widening yields dtype FP32.
|
📖 Documentation Preview The documentation has been built successfully for this PR. Generated Files:
Artifacts:
This comment will be updated automatically when the PR is updated. |
aharakal
approved these changes
Nov 5, 2026
This was referenced Nov 6, 2026
Merged
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.
Part of #1433, implementing rollout phase B1 of SKEEP-008 (
docs/modules/skeep/pages/008-precision-and-encoding-conversion.adoc). Independent of phase A1 (#1469).What
TensorStorage.repackTostops being an always-throwing stub and does the lossless re-encodings: any packed encodingTensorStorageFactory.toTensorDatacan decode →Dense(4), and narrow dense (Dense(2)FP16/BF16) →Dense(4). Decoding is bit-exact (every 16-bit float and every dequantized block value is exactly representable in FP32); the result is owned dense FP32 host storage. A lossy direction still throws — but the message now namesrequantizeTo.TensorStorage.requantizeTo(new) is the visible lossy call: supported targets are exactlyRequantizers.supported— the same set a loader'sEncodingRequest.RequantizeToaccepts — so the two conversion paths cannot drift. Target and shape are validated before the buffer is read (newRequantizers.validateShape, shared withquantize), a packed source is dequantized to FP32 first, and the result is owned packed host storage. Both methods gain aBufferResolveroverload forFileBacked/Aliasedsources, mirroringcopyMaterialize.TensorStorageFactory.toTensorDatalearns the remaining packed decoders (Q4_0, Q5_0, Q5_1, Q5_K, Q6_K, BITNET_PLANES, BITNET_B1_58 — all via their existingfromRawBytes), sorepackTo(Dense(4))covers every packed encoding with a dequantizer, per the SKEEP's acceptance criteria.Dense(4)buffer tagged FP16/BF16 has no defined byte layout anywhere in the codebase.Tests
RepackRequantizeTest(lang-core commonTest, 12 tests): bit-exactrepackTo(Dense(4))round-trips from Q8_0/Q4_0/BITNET_PLANES and from Dense(2) FP16; the lossy direction throws namingrequantizeTo;requantizeTobyte-exact parity withRequantizers.quantizefor Q8_0/Q4_0/BITNET_PLANES; packed→packed goes through dequantize; unsupported target fails with the loader's message; and a non-blocking shape fails before the buffer is read (proven with an unreadable device-resident buffer)../gradlew :skainet-lang:skainet-lang-core:jvmTest macosArm64Test apiCheck checkUnmarkedStubs— green (additive API,skainet-lang-core.apiregenerated).