Skip to content

refactor(zoo): move the EmbeddingGemma 2 state dict hooks onto the shared weight helpers - #79

Merged
chmjkb merged 8 commits into
mainfrom
@chmjkb/hooks-embeddinggemma2-depthart
Nov 2, 2026
Merged

chmjkb merged 8 commits into
mainfrom
@chmjkb/hooks-embeddinggemma2-depthart

Conversation

@chmjkb

@chmjkb chmjkb commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Moves the EmbeddingGemma 2 state dict hooks onto the shared weight helpers and adds permuteRows. The last hook migration of phase 1 in #70.

  • permuteRows(t, order): row i of the result is row order[i] of t, like torch t[order]. Lazy, keeps dtype and byteLength. Throws CHECKPOINT_MISMATCH when order is not a permutation.
  • EmbeddingGemma 2 (+71 / −122):
    • Fused q/k/v (text, vision, audio) is concatRows. The rope reorder is permuteRows with a ropeOrder(rows, block) index list, replacing interleaveHeads.
    • qkv_norm tiles the permuted norms with concatRows, plus ones for v. byteLength still counts each norm once.
    • PLE projection and the audio post norm use scaleWeight. The vision position table is splitRows + reshapeWeight. The audio convs are reshapeWeight, permuteRows and transposeWeight.
    • The weightless-norm ones are f16 halfwords (exact).
    • Clip bounds, layer_scalar, rel and q_scale stay f32: CPU code and the attention kernel read them as f32.
  • depthart: nothing fits the helpers (BatchNorm folds, a three-branch conv merge, per-channel tensor scales, -exp(x)), so it only gets one-line comments saying why each stays f32.

Names, shapes and byteLengths reaching the models are unchanged.

Introduces a breaking change?

  • Yes
  • No

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Documentation update (improves or adds clarity to existing documentation)
  • Performance (kernel tuning, graph building, anything related to performance)
  • Other (chores, tests, code style improvements etc.)

Testing instructions

  1. pnpm typecheck && pnpm lint && pnpm --filter runntime test:unit (941 pass)
  2. New test/zoo/embeddinggemma2/stateDictHooks.test.ts: all three towers on F32 and F16 synthetic checkpoints, values against hand-worked math including the rope row order. permuteRows cases in test/core/weights/transforms.test.ts.
  3. pnpm --filter runntime test:gpu: 1439 passed, 16 expected failures. The zoo leak tests bind random weights, so they don't run these hooks.

Related issues

Part of #70. Stacked on #78.

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Additional notes

@chmjkb chmjkb added core Engine: graph ops, dispatch, buffer pool, weight loading zoo Task runners and model loaders in src/zoo labels Oct 28, 2026
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-moonshine-privacy-filter branch from a6e580c to c2f4e66 Compare October 28, 2026 09:16
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-embeddinggemma2-depthart branch 2 times, most recently from 2bc8d21 to 239dbf3 Compare October 28, 2026 10:49
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-moonshine-privacy-filter branch from c2f4e66 to 1930710 Compare October 28, 2026 10:49
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-embeddinggemma2-depthart branch from 239dbf3 to dc28153 Compare October 28, 2026 10:58
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-moonshine-privacy-filter branch from 1930710 to e4659b0 Compare October 28, 2026 10:58
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-moonshine-privacy-filter branch from e4659b0 to 52294eb Compare October 30, 2026 11:26
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-embeddinggemma2-depthart branch from dc28153 to 2bd5993 Compare October 30, 2026 11:26
@xxpopielxx xxpopielxx mentioned this pull request Oct 30, 2026
Closed
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-moonshine-privacy-filter branch from 52294eb to 5ada244 Compare October 30, 2026 12:47
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-embeddinggemma2-depthart branch from 2bd5993 to 54465a7 Compare October 30, 2026 12:47
Base automatically changed from @chmjkb/hooks-moonshine-privacy-filter to main October 30, 2026 12:52
@chmjkb
chmjkb force-pushed the @chmjkb/hooks-embeddinggemma2-depthart branch from 54465a7 to 38fa2f7 Compare October 30, 2026 13:26
@chmjkb
chmjkb requested a review from xxpopielxx October 30, 2026 13:26
@chmjkb
chmjkb merged commit 262337a into main Nov 2, 2026
2 checks passed
@chmjkb
chmjkb deleted the @chmjkb/hooks-embeddinggemma2-depthart branch November 2, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Engine: graph ops, dispatch, buffer pool, weight loading zoo Task runners and model loaders in src/zoo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants