Summary
The FunctionGemma-270M compiled export emits the tied vocab embedding as two independent weight globals, roughly doubling the archive and every in-memory copy during export.
Evidence
Parsed from /tmp/fgemma-export/gemma-gen.mlir (produced by FunctionGemmaExport.export):
globals: 324 total elements: 436,111,680 = 1.62 GiB FP32 (832 MiB bf16)
top globals by size:
t2044 262153x640 167,777,920 (38.5%)
t0 262153x640 167,777,920 (38.5%)
t98 2048x640 1,310,720 ( 0.3%)
...
t0 (input token embedding) and t2044 (output logit projection) are the same tied weight, emitted twice. Together they are 77% of the archive. The 832 MiB figure matches the on-disk gemma.safetensors exactly (872,248,326 bytes), so this is measured, not estimated.
The model itself is ~268.3M params; the archive carries 436.1M elements. The 167.8M difference is exactly the duplicate.
Impact
Suggested fix
Emit the tied embedding once and have both consumers reference the same util.global / external parameter. Gemma ties token_embd to the output head by construction, so the second materialization carries no information.
Worth confirming first whether the duplication originates in the DSL graph (two distinct nodes holding the same tensor) or in the StableHLO externalization step assigning two parameter keys to one buffer — the fix differs.
Related
🤖 Generated with Claude Code
Summary
The FunctionGemma-270M compiled export emits the tied vocab embedding as two independent weight globals, roughly doubling the archive and every in-memory copy during export.
Evidence
Parsed from
/tmp/fgemma-export/gemma-gen.mlir(produced byFunctionGemmaExport.export):t0(input token embedding) andt2044(output logit projection) are the same tied weight, emitted twice. Together they are 77% of the archive. The 832 MiB figure matches the on-diskgemma.safetensorsexactly (872,248,326 bytes), so this is measured, not estimated.The model itself is ~268.3M params; the archive carries 436.1M elements. The 167.8M difference is exactly the duplicate.
Impact
Suggested fix
Emit the tied embedding once and have both consumers reference the same
util.global/ external parameter. Gemma tiestoken_embdto the output head by construction, so the second materialization carries no information.Worth confirming first whether the duplication originates in the DSL graph (two distinct nodes holding the same tensor) or in the StableHLO externalization step assigning two parameter keys to one buffer — the fix differs.
Related
FunctionGemmaExport.kt)embedConstantstrace fidelity🤖 Generated with Claude Code