functiongemma export: write externals from any BufferHandle (Owned or Floats) — fixes #405 - #414
Merged
Merged
Conversation
… Floats) — fixes the ClassCastException on the 0.53.0 engine loader (#405) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
michalharakal
force-pushed
the
functiongemma-export-floats-cast
branch
from
September 3, 2026 21:43
15e1ef3 to
6686107
Compare
…rt-floats-cast # Conflicts: # llm-inference/functiongemma/src/jvmMain/kotlin/sk/ainet/models/functiongemma/FunctionGemmaExportHarness.kt
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.
Fixes #405.
FunctionGemmaExportHarness.writeSafetensorsandwriteQuantizedSafetensorscast every external toBufferHandle.Owned; with the 0.53.0 engine loader the large constants (the 262144×640 tied embedding) arrive asBufferHandle.Floats, so everyFunctionGemmaExportClirun died withClassCastException: BufferHandle$Floats cannot be cast to BufferHandle$Owned— the cast #396 removed from the Gemma 3n harness was still here.Change
writeHandle(os, handle, bf16): streams any handle as raw f32 or truncating bf16 (core parity) in 1 MiB chunks, dispatching on the subtype.ownedBytes(handle): little-endian bytes + base offset for the quantizer, which reads rows by byte offset (aFloatshandle is materialised once).Ownedhandles is byte-identical to before.Verification
:llm-inference:functiongemma:compileKotlinJvmgreen.[32691, 10492, 23688, 6824, …]).