Skip to content

feat(examples): kws_raw raw-waveform + in-model downsample parity demo (Stage 3 PR-B)#256

Merged
LeoBuron merged 7 commits into
developfrom
examples-kws-raw
Jun 26, 2026
Merged

feat(examples): kws_raw raw-waveform + in-model downsample parity demo (Stage 3 PR-B)#256
LeoBuron merged 7 commits into
developfrom
examples-kws-raw

Conversation

@LeoBuron

Copy link
Copy Markdown
Member

Adds examples/kws_raw/ — SpeechCommands keyword spotting on the raw 16 kHz waveform with in-model downsampling. Completes Stage 3 of the 1D-CNN example suite (PR-B; reuses the shared loader from PR-A #255).

Model: AvgPool1d(K=16,S=16) (16 kHz→1 kHz decimation) → 3×Conv1d(K3,SAME)+ReLU+MaxPool(4)AdaptiveAvgPool1d(1)LayerNorm(64)Linear. Lengths 16000→1000→250→62→15→1.

Gate: BIT_PARITY=1 C int32 predictions bit-identical to PyTorch (2483/2483), diverse across all 6 classes — a real §11.3 proof that AvgPool1d over [1,16000], the Conv chain, and the C LayerNorm all reproduce PyTorch bit-for-bit. First example/integration exercise of the framework's LayerNorm.

Convergence note: raw waveforms don't train at the MFCC settings (lr=0.001/15ep → the reference collapses to one class, which would make the gate degenerate). Fixed with a rate-agnostic LayerNorm(64) (the framework's only bit-parity-covered normalizer; BatchNorm is not) + lr=0.005 / 20 epochs → test_acc 0.588 with predictions across all 6 classes. kws_mfcc is unchanged.

CI: per-example processed-.npy cache (gates prepare on cache-hit) + shared raw-download cache (from PR-A); int32-exact diff; 6-class only (35-class is local-only, compiled by the build-all rot guard).

🤖 Generated with Claude Code

LeoBuron added 7 commits June 26, 2026 19:30
…ence

The raw model at the spec lr=0.001/15ep never escapes random init (flat loss,
all-class-0 predictions) → a degenerate bit-parity gate. Add a rate-agnostic
LayerNorm(64) on the pooled features before fc and tune to lr=0.005 / 20 epochs:
the model now reaches test_acc 0.588 with predictions spread across all 6 classes,
making the AvgPool[1,16000] §11.3 bit-parity proof meaningful (C reproduces the
diverse PyTorch predictions exactly: 2483/2483 int32-identical).

LayerNorm is the framework's only bit-parity-covered normalizer (BatchNorm is not),
so the gate is preserved. C model: MODEL_SIZE 14->15, layerNormLayerInit at model[12]
(normalizedShape=[64], eps 1e-5 = PyTorch default), 5-entry state-dict (+ln gamma/beta),
+LayerNormApi/LayerNorm link libs. kws_mfcc (shipped) is unchanged.
@LeoBuron LeoBuron merged commit 14b5fb7 into develop Jun 26, 2026
8 checks passed
@LeoBuron LeoBuron deleted the examples-kws-raw branch June 26, 2026 18:47
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