Skip to content

fix(gemma3n): stream export weights through the BufferResolver, drop the Owned cast (SKaiNET#1247) - #396

Merged
michalharakal merged 1 commit into
developfrom
feat/1247-export-resolver-streaming
Sep 2, 2026
Merged

michalharakal merged 1 commit into
developfrom
feat/1247-export-resolver-streaming

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Consumer-side half of SKaiNET#1247 (pairs with SKaiNET-developers/SKaiNET#1251).

Gemma3nExportHarness.writeSafetensors cast every ExternalParameterRef.source to BufferHandle.Owned. With the #1247 engine fixes, ≥2 GiB FP32 constants arrive as an aliased FloatArray (BufferHandle.Floats) that never exists as a single ByteArray — the tied embedding is exactly Int.MAX_VALUE + 1 bytes — so the cast threw ClassCastException the moment strict conversion got that far.

The harness now reads every handle through DefaultBufferResolver in bounded chunks with the same chunked bf16 conversion. DefaultBufferResolver exists in the published 0.52.0 engine, so this compiles against current artifacts today and streams Floats at runtime once the engine ships it — no release ordering constraint.

Verified via composite build against the #1247 engine branches: GEMMA3N_LAYERS=4 export emits gemma3n-gen.mlir (zero failure comments, non-empty return) plus a 1546 MiB safetensors with 124 params — the first servable module this export has produced.

…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>
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.

1 participant