Symptom
FunctionGemmaExportDumpTest.exportAll_emitsContractShapesAndManifest and FunctionGemmaVmfbParityTest.vmfbTwoGraphKvLoopMatchesOracle fail on develop:
java.lang.ClassCastException: class sk.ainet.lang.tensor.storage.BufferHandle$Floats cannot be cast to class sk.ainet.lang.tensor.storage.BufferHandle$Owned
at sk.ainet.models.functiongemma.FunctionGemmaExportHarness.writeSafetensors(FunctionGemmaExportHarness.kt:471)
Cause
Since SKaiNET 0.53.0 (SKaiNET#1247) the engine's ConstantMaterialization hands external parameters over as whatever BufferHandle the source data has — BufferHandle.Floats for FloatArray-backed constants, Owned for byte-backed ones — and provides DefaultBufferResolver / BufferAccessor.readAllBytes() to read any of them. Gemma3nExportHarness was updated to the resolver; these still hard-cast to BufferHandle.Owned:
llm-inference/functiongemma/.../FunctionGemmaExportHarness.kt (writeSafetensors, writeSafetensorsInt8)
llm-inference/smollm2/.../SmolLm2ExportHarness.kt
llm-inference/whisper/src/jvmTest/.../WhisperExportHarness.kt (bytesOf, irpa storage segment — Owned/Borrowed only)
llm-inference/gemma/src/jvmTest/.../RealGemmaBakeIrpaTest.kt, llm-inference/llama/src/jvmTest/.../RealSmolLm2BakeIrpaTest.kt
Fix
Read every external parameter through DefaultBufferResolver().resolve(handle).use { it.readAllBytes() } (little-endian f32 bytes regardless of handle kind) at all five sites. No behaviour change for Owned handles; the bf16 / int8 conversions keep their exact arithmetic.
Also on develop: the API dumps of bert, gemma, gemma3n, gemma-iree and kgemma have drifted from the code (apiCheck red); refreshed in the same PR.
Symptom
FunctionGemmaExportDumpTest.exportAll_emitsContractShapesAndManifestandFunctionGemmaVmfbParityTest.vmfbTwoGraphKvLoopMatchesOraclefail ondevelop:Cause
Since SKaiNET 0.53.0 (SKaiNET#1247) the engine's
ConstantMaterializationhands external parameters over as whateverBufferHandlethe source data has —BufferHandle.Floatsfor FloatArray-backed constants,Ownedfor byte-backed ones — and providesDefaultBufferResolver/BufferAccessor.readAllBytes()to read any of them.Gemma3nExportHarnesswas updated to the resolver; these still hard-cast toBufferHandle.Owned:llm-inference/functiongemma/.../FunctionGemmaExportHarness.kt(writeSafetensors,writeSafetensorsInt8)llm-inference/smollm2/.../SmolLm2ExportHarness.ktllm-inference/whisper/src/jvmTest/.../WhisperExportHarness.kt(bytesOf, irpa storage segment —Owned/Borrowedonly)llm-inference/gemma/src/jvmTest/.../RealGemmaBakeIrpaTest.kt,llm-inference/llama/src/jvmTest/.../RealSmolLm2BakeIrpaTest.ktFix
Read every external parameter through
DefaultBufferResolver().resolve(handle).use { it.readAllBytes() }(little-endian f32 bytes regardless of handle kind) at all five sites. No behaviour change forOwnedhandles; the bf16 / int8 conversions keep their exact arithmetic.Also on
develop: the API dumps ofbert,gemma,gemma3n,gemma-ireeandkgemmahave drifted from the code (apiCheckred); refreshed in the same PR.