Skip to content

native frontend: mount resample and mel stages cooperatively on Flashkern #172

Description

@sydneyrenee

Problem

AUDIO_PHASE_FRONTEND currently executes the entire resampler/frontend synchronously on lane zero. run_audio_program_stage returns immediately for every other lane, then calls prepare_audio_conformer, which runs resampling, frame geometry, and the full mel frontend serially.

Paired leaves exist, and the workspace aliases some dead planes correctly, but the execution is not a cooperative Flashkern program. Additional violations:

  • non-Apple sgemm_rm is a scalar C++ triple loop;
  • mounted frontend assembly calls per-element logf;
  • DFT/power and mel/stat planes materialize more broadly than the register-FIFO contract requires.

Required stage graph

Mount validated generations for:

  1. polyphase resampling over output ranges;
  2. preemphasis/window/gather over frame bands;
  3. DFT through an explicit Accelerate/AMX seam on Apple or supported architecture leaf;
  4. power conversion, aliasing dead STFT-real storage where valid;
  5. mel projection through an explicit dense seam;
  6. log guard;
  7. per-feature statistics and ddof=1 normalization;
  8. exact BF16 publication directly into the Conformer consumer layout.

Lanes claim disjoint frame/bin tiles. Lane-zero work is limited to bounded phase transitions and plan-state publication.

Materialization law

A plane is allowed only when data must survive:

  • a team barrier;
  • DFT/mel opaque matrix seam;
  • fan-out to multiple later consumers;
  • continuation suspension;
  • published Conformer input.

A C++ function or reference-module boundary is not sufficient. Scratch aliases immediately after the last consumer.

Work

  • Split AUDIO_PHASE_FRONTEND into retained program phases.
  • Bind all immutable FFT/window/mel tables at plan construction.
  • Remove scalar product fallback; unsupported ISA fails readiness.
  • Replace per-element libm calls with faithful paired SIMD/assembly math under frozen traces.
  • Write normalized valid rows directly in the layout Conformer consumes.
  • Preserve the implemented padding, frame-count, normalization, log-guard, and rounding semantics. Do not invent a dither stage: this frontend has no production dither source.

Acceptance

  • Frontend uses all eligible lanes for representative utterances.
  • No production scalar matrix fallback or hot libm call remains.
  • No payload transpose/crop copy exists between frontend and Conformer.
  • Plane lifetimes and legal barriers are documented and asserted.
  • Frozen resample/mel traces pass across tails, rates, silence, padding, normalization, and rounding.
  • AArch64 and x86_64/Rosetta pass.
  • Real-checkpoint first and retained-context audio turns pass.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions