Skip to content

tflite: fix the 172 Hz buzz in the w8a8 SAME-S decoder - #125

Merged
Cortexelus merged 1 commit into
mainfrom
fix/tflite-same-s-172hz-buzz
Oct 29, 2026
Merged

Cortexelus merged 1 commit into
mainfrom
fix/tflite-same-s-172hz-buzz

Conversation

@Cortexelus

Copy link
Copy Markdown
Collaborator

The w8a8 SAME-S decoder emits a faint 172 Hz tone (= 44100/256) with harmonics in quiet passages. It's the output-mapping conv: tflite quantizes conv activations per-tensor, so quiet sections hit a coarse grid and the unpatched 256-sample audio patches form a periodic staircase.

Reformulating the k=3 mapping conv as im2col + a pointwise matmul (bit-identical to the conv, 1e-6) makes the converter emit a FULLY_CONNECTED, which the dynamic-int8 path scales per-token — the grid adapts to the quiet level and the buzz is gone, at full int8 speed.

  • 172 Hz in a quiet passage: −73 → −92 dBFS (fp32 −98)
  • full-clip corr to fp32: 0.9997
  • decode speed within ~1% of the original (vs +7% for a w8a32 fallback)
  • fp32 path bit-identical; decoder-only, no graph/API change; baked 0.977 output limiter preserved

Validated across 8 prompts × 3–40 s (incl. chunking): the new decoder is ≥ the old everywhere on fidelity and on the 172 Hz metric, finite, no clipping. The updated dec_w8a8.tflite is live on HuggingFace; the previous build is archived at tflite/same-s/legacy/dec_w8a8-hasbuzz-2026-09-01.tflite.

🤖 Generated with Claude Code

The int8 (w8a8) SAME-S decoder added a faint 172 Hz tone (= 44100/256) with
harmonics, audible in quiet passages. Cause: the output-mapping Conv1d (768->512,
k=3) is quantized with a per-TENSOR dynamic-int8 activation scale, so quiet
sections land on a coarse grid and the unpatched 256-sample patches become a
periodic staircase.

Fix: express the mapping as im2col + a pointwise matmul (numerically identical to
the conv, 1e-6), which the converter emits as a FULLY_CONNECTED. Dynamic int8
scales FCs PER-TOKEN, so the quiet grid adapts and the buzz is gone -- at full
int8 speed (the FC stays int8; decode within ~1% of the conv).

Decoder-only, no graph/API change; the fp32 path is bit-identical. Measured 172 Hz
in a quiet passage: -73 -> -92 dBFS (fp32 -98); full-clip corr to fp32 0.9997.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Cortexelus
Cortexelus merged commit 4bf31f7 into main Oct 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant