diff --git a/packages/runntime/src/zoo/embeddinggemma2/audioEncoder.ts b/packages/runntime/src/zoo/embeddinggemma2/audioEncoder.ts index 5949f3d6..6c7a3342 100644 --- a/packages/runntime/src/zoo/embeddinggemma2/audioEncoder.ts +++ b/packages/runntime/src/zoo/embeddinggemma2/audioEncoder.ts @@ -195,7 +195,8 @@ export async function encodeAudio( const { mels } = model.cfg; const tokens = audioTokens(samples.length); const frames = frameCount(samples.length); - const act = model.input_proj.weight.shape.dtype === 'f16' ? 'f16' : 'f32'; + // A norm scale, not a Linear weight: a quantized weight is quantW either way. + const act = model.embedding_pre_projection_norm.scale.shape.dtype === 'f16' ? 'f16' : 'f32'; const patches = convPatches(logMel(samples, frames, mels), frames, mels); const taps = convTaps(Math.ceil(frames / 2), mels / 2); const inputs: EmbeddingGemma2AudioInputs = { diff --git a/packages/runntime/src/zoo/embeddinggemma2/visionEncoder.ts b/packages/runntime/src/zoo/embeddinggemma2/visionEncoder.ts index aea62b5a..681f051d 100644 --- a/packages/runntime/src/zoo/embeddinggemma2/visionEncoder.ts +++ b/packages/runntime/src/zoo/embeddinggemma2/visionEncoder.ts @@ -87,7 +87,8 @@ export async function encodeImage( const { patch, pool, headDim, ropeTheta } = model.cfg; const [cols, rows] = patchGrid(image.width, image.height, maxTokens, patch, pool); const p = cols * rows; - const act = model.input_proj.weight.shape.dtype === 'f16' ? 'f16' : 'f32'; + // A norm scale, not a Linear weight: a quantized weight is quantW either way. + const act = model.embedding_pre_projection_norm.scale.shape.dtype === 'f16' ? 'f16' : 'f32'; const upload = (data: Float32Array, r: number, dtype: 'f32' | 'f16') => tensor(data, { elems: data.length, dtype, dims: [r, data.length / r] }); const xs = new Float32Array(p);