fix(gemma3n): stream export weights through the BufferResolver, drop the Owned cast (SKaiNET#1247) - #396
Merged
Conversation
…the Owned cast (SKaiNET#1247) writeSafetensors cast every ExternalParameterRef.source to BufferHandle.Owned. With SKaiNET#1247 the engine hands >=2 GiB FP32 constants over as an aliased FloatArray (BufferHandle.Floats) that never exists as one ByteArray — the tied embedding is exactly Int.MAX_VALUE + 1 bytes — so the cast threw ClassCastException the moment the strict conversion finally got that far. Reading through DefaultBufferResolver (present in the published engine) keeps the harness compiling against 0.52.0 and streams any handle in bounded chunks with the same chunked bf16 conversion. Verified: GEMMA3N_LAYERS=4 export against the #1247 engine branches emits gemma3n-gen.mlir + a 1546 MiB safetensors (124 params) — the first time this export has produced a servable module. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Sep 2, 2026
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.
Consumer-side half of SKaiNET#1247 (pairs with SKaiNET-developers/SKaiNET#1251).
Gemma3nExportHarness.writeSafetensorscast everyExternalParameterRef.sourcetoBufferHandle.Owned. With the #1247 engine fixes, ≥2 GiB FP32 constants arrive as an aliasedFloatArray(BufferHandle.Floats) that never exists as a singleByteArray— the tied embedding is exactlyInt.MAX_VALUE + 1bytes — so the cast threwClassCastExceptionthe moment strict conversion got that far.The harness now reads every handle through
DefaultBufferResolverin bounded chunks with the same chunked bf16 conversion.DefaultBufferResolverexists in the published 0.52.0 engine, so this compiles against current artifacts today and streamsFloatsat runtime once the engine ships it — no release ordering constraint.Verified via composite build against the #1247 engine branches:
GEMMA3N_LAYERS=4export emitsgemma3n-gen.mlir(zero failure comments, non-empty return) plus a 1546 MiB safetensors with 124 params — the first servable module this export has produced.