Skip to content

feat(xla): support Gemma3n audio with dense PLE prefill #878

Description

@inureyes

Parent and dependencies

Problem

Gemma3n audio combines a specialized mel/Conformer encoder with the already-specialized Gemma3n AltUp/Laurel/dense-PLE language path. The audio frame mask drives convolutional subsampling and chunked local attention; the resulting projected tokens and per-layer inputs must align with expanded prompt positions before #876 seeds KV caches.

A host-only encoder fallback would leave a substantial second compute graph/runtime and would not complete the epic's OpenXLA parity target.

Goal

Execute the qualified Gemma3n audio encoder and multimodal projection through StableHLO/IREE, feed exact merged embeddings plus dense PLE to #876, and serve bounded audio requests through CLI and continuous batching.

Required implementation

  • Keep waveform decode/resample and mel extraction in the bounded feat(xla): add bounded audio preprocessing and serving plumbing #873 host stage unless a measured, independently validated IREE front end is proposed. The audio.main graph accepts canonical mel features and mask/actual-frame metadata from feat(vlm): add a token-exact Gemma3n audio reference path #875.
  • Define static frame buckets up to the pinned checkpoint's duration limit. Include mel bins, frame policy, convolution shapes/strides/padding, hidden size, Conformer depth, chunk/context sizes, projection/pooling config, and dtype in artifact identity.
  • Emit both subsample convolution blocks with manual padding, cumulative group normalization, ReLU, mask/length propagation, and output projection exactly.
  • Emit all Conformer components from feat(vlm): add a token-exact Gemma3n audio reference path #875: feed-forward halves, chunked local attention, relative position projection/shift, per-dimension query scaling, logit softcap, light causal/depthwise convolution, residuals, clipping behavior relevant to inference, and final normalization/pooling/projection.
  • Carry masks through every stage; padded mel frames and padded output tokens must not contribute to cumulative statistics, attention, pooling, placeholder count, or PLE generation.
  • Produce projected audio tokens plus explicit per-clip output lengths. Apply the exact feat(vlm): add a token-exact Gemma3n audio reference path #875 placeholder expansion/replacement and construct the post-scale merged embeddings and dense per-layer-input tensor required by prefill_embeddings_ple.main.
  • Preserve multiple-clip order and request-scoped PLE. Submit effective expanded length to feat(xla): parameterize context and multimodal prefill capacity #857 admission, then release mel/encoder/projected/PLE buffers after successful prefill or on cancellation/error.
  • Load audio weights conditionally. Capability is true only when the checkpoint contains compatible audio config/weights, audio.main, and the feat(xla): add the Gemma3n text backbone and dense PLE prefill #876 language bundle. Text/image-only checkpoints must not pay the audio load/memory cost.
  • Integrate CLI/server audio, mixed image/audio if qualified by feat(vlm): add a token-exact Gemma3n audio reference path #875, cancellation, metrics, and slot reset. No audio/PLE state may survive slot reuse.
  • Do not retain or invoke a full MLX Gemma3n decoder/audio tower on the production XLA path.

Non-goals

  • Gemma4 audio or Phi4MM adapters.
  • Speech output/streaming audio input.
  • Claiming arbitrary Gemma3n checkpoint compatibility without the pinned processor/config oracle.

Validation

  • Compare every stage selected by feat(vlm): add a token-exact Gemma3n audio reference path #875: mel/mask input, both subsample blocks/cumulative stats, relative-position and chunk masks, selected Conformer blocks, pooled/projected audio tokens, placeholder merge, dense PLE, selected Gemma3n language layers, KV/logits, and greedy tokens.
  • Cover duration/frame bucket boundaries, padded batches, one/multiple clips, malformed masks, all-padded rejection, context overflow after audio expansion, audio-only, text/image-only, qualified mixed media, cancellation, and slot reuse.
  • Interleave requests with different clip lengths and modalities; prove masks, effective lengths, and dense PLE remain slot-local.
  • Run deterministic ASR through CLI and streaming server on a production-relevant IREE target with token-exact output.
  • Run feat(vlm): add a token-exact Gemma3n audio reference path #875/feat(xla): add the Gemma3n text backbone and dense PLE prefill #876 and all existing Gemma3n/text/image/XLA gates.

Acceptance criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:architectureArchitecture and code structure changesarea:inferenceGeneration, sampling, decoding (incl. speculative, DRY)area:modelsModel architectures, weights, loading, metadatapriority:lowLow prioritystatus:blockedBlocked by dependencies or other issuestype:enhancementNew features, capabilities, or significant additions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions