Skip to content

fix(asr/nemotron): native-Swift mel front-end to fix iPadOS cold-start zero output (#739)#744

Open
Alex-Wengg wants to merge 2 commits into
mainfrom
fix/739-nemotron-swift-mel
Open

fix(asr/nemotron): native-Swift mel front-end to fix iPadOS cold-start zero output (#739)#744
Alex-Wengg wants to merge 2 commits into
mainfrom
fix/739-nemotron-swift-mel

Conversation

@Alex-Wengg

Copy link
Copy Markdown
Member

Summary

Fixes #739StreamingNemotronAsrManager produces zero output on iPadOS cold start (empty transcript, works on macOS).

Root cause (verified, and it differs from the issue's stated theory): the ios17.slice_by_index: zero shape error / "Skipped adding default_function to entry point: main" warning comes from the CoreML preprocessor model's flexible RangeDim audio input, not the encoder. CoreML builds the ANE default_function against the range's 1-sample lower bound → mel extraction slices to zero frames → the preprocessor's ANE main entry point is never built. (Confirmed by loading each model on CPU_AND_NE: only the preprocessor warns; the encoder graph is clean. The issue's proposed encoder cache_len re-trace was a misdiagnosis — cache_len only feeds boolean masks, not a data-dependent slice.)

Fix: remove the CoreML preprocessor from both Nemotron streaming managers and compute log-mel natively in Swift (NemotronMelExtractor). No model re-conversion / HF re-upload needed.

Changes

  • NemotronMelExtractor — wraps the shared AudioMelSpectrogram, reproducing NeMo's AudioToMelSpectrogramPreprocessor exactly (n_fft=512, win=400, hop=160, 128 mels, symmetric Hann, preemph=0.97, normalize: NA → raw log-mel, no per-feature normalization — the one difference from UnifiedMelExtractor).
  • English (StreamingNemotronAsrManager + +Pipeline): swap preprocessor MLModel for the extractor.
  • Multilingual (StreamingNemotronMultilingualAsrManager + +Pipeline/+Buffers/+Shared): same swap, with two extractor instances (on-actor + concurrent triple-stage prefetch) so the extractor's non-thread-safe FFT buffers are never shared across the prefetch boundary; preprocessor dropped from SharedNemotronMultilingualModels.
  • Fail loudly: load-time encoder probe throws ASRError.encoderInstantiationFailed if the encoder returns all-zero output (instead of silently emitting empty transcripts).

Verification

  • Python parity: CoreML preprocessor == NeMo PyTorch raw log-mel (max |Δ| ≈ 9e-3); per-bin means ≈ −15 confirm it is not per-feature normalized.
  • English LibriSpeech test-clean (full, 2620 files): WER 560ms 2.71% · 1120ms 2.58% · 2240ms 2.64%.
  • Multilingual FLEURS (7 langs, full splits): AVG WER/CER 8.62 / 8.33 / 8.30% at 560/1120/2240ms; meets-or-beats NVIDIA's published [56,0] numbers on all published languages.
  • swift build passes; new unit tests for the extractor (shape/determinism/not-normalized) and the new error case. (Note: swift test needs full Xcode for XCTest — runs in CI; built/validated locally + via CLI benchmarks.)

Docs

  • New Sources/FluidAudio/ASR/Parakeet/Streaming/Nemotron/benchmark.md (English).
  • Refreshed Documentation/ASR/NemotronMultilingual.md to current tiers (560/1120/2240; dropped obsolete 320ms) with freshly measured numbers.

Not covered

  • On-device iPad cold-start ANEProgramProcessRequestDirect status=0x12 confirmation requires a physical iPad — not verifiable from a Mac. The mel-parity root-cause case (removing the RangeDim preprocessor) is solid; the probe guarantees the failure can no longer be silent.

…t zero output (#739)

Replace the CoreML preprocessor in both Nemotron streaming managers
(English + multilingual) with a native-Swift log-mel front-end
(NemotronMelExtractor). The CoreML preprocessor's flexible RangeDim audio
input made CoreML build the ANE default_function against a 1-sample lower
bound, raising "ios17.slice_by_index: zero shape error" and skipping the
ANE `main` entry point -- the warning behind the iPadOS cold-start
empty-transcript failure in #739.

NemotronMelExtractor reproduces NeMo's AudioToMelSpectrogramPreprocessor
exactly (n_fft=512, win=400, hop=160, 128 mels, symmetric Hann,
preemph=0.97, normalize: NA -- raw log-mel). Parity vs NeMo PyTorch:
max |delta| ~= 9e-3. The multilingual manager uses two extractor instances
so the on-actor path and the concurrent triple-stage prefetch task never
share the extractor's non-thread-safe FFT scratch buffers; the CoreML
preprocessor is dropped from SharedNemotronMultilingualModels (multi-stream
shares MLModel handles, each manager builds its own extractors).

Add a load-time encoder health probe that throws
ASRError.encoderInstantiationFailed if the encoder returns all-zero output,
so the iPad failure fails loudly instead of emitting empty transcripts.

Benchmarks (full sets, native-Swift mel):
- English LibriSpeech test-clean (2620 files): 560ms 2.71% / 1120ms 2.58% / 2240ms 2.64% WER
- Multilingual FLEURS (7 langs, full splits): AVG 8.62 / 8.33 / 8.30% at 560/1120/2240ms

Docs: add Sources/.../Streaming/Nemotron/benchmark.md (English); refresh
Documentation/ASR/NemotronMultilingual.md to current tiers (560/1120/2240).
…md; fix swift-format

- Move Sources/.../Streaming/Nemotron/benchmark.md content into
  Documentation/Benchmarks.md as a "Nemotron Speech Streaming 0.6B (English)"
  section (mirrors the Parakeet Unified section); delete the Sources file.
- Reformat KMeansClustering.swift `??` wrapping to satisfy the CI swift-format
  (Swift 6.1.3) check — pre-existing main drift surfaced because the format job
  reformats the whole tree.
@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

Sortformer High-Latency Benchmark Results

ES2004a Performance (30.4s latency config)

Metric Value Target Status
DER 30.3% <35%
Miss Rate 28.2% - -
False Alarm 0.9% - -
Speaker Error 1.2% - -
RTFx 8.7x >1.0x
Speakers 4/4 - -

Sortformer High-Latency • ES2004a • Runtime: 6m 10s • 2026-06-28T21:19:12.613Z

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

Supertonic3 Smoke Test ✅

Check Result
Build
Model download (incl. VectorEstimatorVariants/ int4 buckets)
Model load
Synthesis pipeline (--ve-variant int4)
Output WAV ✅ (364.7 KB)

Runtime: 0m44s

Note: CI VMs lack a physical Neural Engine; the ANE-bucketed VectorEstimator falls back to CPU here. This validates download + variant resolution + synthesis, not ANE residency/perf.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

PocketTTS Smoke Test ✅

Check Result
Build
Model download
Model load
Synthesis pipeline
Output WAV ✅ (161.3 KB)

Runtime: 0m5s

Note: PocketTTS uses CoreML MLState (macOS 15) KV cache + Mimi streaming state. CI VM lacks physical GPU — audio quality and performance may differ from Apple Silicon.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

Parakeet EOU Benchmark Results ✅

Status: Benchmark passed
Chunk Size: 320ms
Files Tested: 100/100

Performance Metrics

Metric Value Description
WER (Avg) 7.03% Average Word Error Rate
WER (Med) 4.17% Median Word Error Rate
RTFx 6.62x Real-time factor (higher = faster)
Total Audio 470.6s Total audio duration processed
Total Time 72.2s Total processing time

Streaming Metrics

Metric Value Description
Avg Chunk Time 0.072s Average chunk processing time
Max Chunk Time 0.144s Maximum chunk processing time
EOU Detections 0 Total End-of-Utterance detections

Test runtime: 1m22s • 06/28/2026, 04:58 PM EST

RTFx = Real-Time Factor (higher is better) • Processing includes: Model inference, audio preprocessing, state management, and file I/O

@github-actions

Copy link
Copy Markdown

VAD Benchmark Results

Performance Comparison

Dataset Accuracy Precision Recall F1-Score RTFx Files
MUSAN 92.0% 86.2% 100.0% 92.6% 499.3x faster 50
VOiCES 92.0% 86.2% 100.0% 92.6% 605.6x faster 50

Dataset Details

  • MUSAN: Music, Speech, and Noise dataset - standard VAD evaluation
  • VOiCES: Voices Obscured in Complex Environmental Settings - tests robustness in real-world conditions

✅: Average F1-Score above 70%

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

ASR Benchmark Results ✅

Status: All benchmarks passed

Parakeet v3 (multilingual)

Dataset WER Avg WER Med RTFx Status
test-clean 0.57% 0.00% 6.03x
test-other 1.19% 0.00% 3.34x

Parakeet v2 (English-optimized)

Dataset WER Avg WER Med RTFx Status
test-clean 0.80% 0.00% 5.89x
test-other 1.00% 0.00% 3.69x

Streaming (v3)

Metric Value Description
WER 0.00% Word Error Rate in streaming mode
RTFx 0.54x Streaming real-time factor
Avg Chunk Time 1.987s Average time to process each chunk
Max Chunk Time 3.239s Maximum chunk processing time
First Token 2.315s Latency to first transcription token
Total Chunks 31 Number of chunks processed

Streaming (v2)

Metric Value Description
WER 0.00% Word Error Rate in streaming mode
RTFx 0.62x Streaming real-time factor
Avg Chunk Time 1.447s Average time to process each chunk
Max Chunk Time 1.874s Maximum chunk processing time
First Token 1.404s Latency to first transcription token
Total Chunks 31 Number of chunks processed

Streaming tests use 5 files with 0.5s chunks to simulate real-time audio streaming

25 files per dataset • Test runtime: 12m0s • 06/28/2026, 05:08 PM EST

RTFx = Real-Time Factor (higher is better) • Calculated as: Total audio duration ÷ Total processing time
Processing time includes: Model inference on Apple Neural Engine, audio preprocessing, state resets between files, token-to-text conversion, and file I/O
Example: RTFx of 2.0x means 10 seconds of audio processed in 5 seconds (2x faster than real-time)

Expected RTFx Performance on Physical M1 Hardware:

• M1 Mac: ~28x (clean), ~25x (other)
• CI shows ~0.5-3x due to virtualization limitations

Testing methodology follows HuggingFace Open ASR Leaderboard

@github-actions

Copy link
Copy Markdown

✅ Nemotron Multilingual Benchmark — FLEURS

FLEURS en_us, chunk 2240ms, 100 samples, B1 fused decode path. Same English audio against both shipped models.

Model Language WER RTFx
latin/ (pruned 2828) English 7.84% 6.3x
multilingual/ (full 13087) English 7.91% 6.2x
Logs (tail)
[latin / English]

Language     | Prompt   | WER%   | CER%   | RTFx   | Duration  | Processed | Skipped
--------------------------------------------------------------------------------
en_us        | en-US    | 7.8    | 3.5    | 6.3    | 953.9s    | 100       | -
--------------------------------------------------------------------------------
AVERAGE      | —        | 7.8    | 3.5    | 6.3   


[multilingual / English]

Language     | Prompt   | WER%   | CER%   | RTFx   | Duration  | Processed | Skipped
--------------------------------------------------------------------------------
en_us        | en-US    | 7.9    | 3.6    | 6.2    | 953.9s    | 100       | -
--------------------------------------------------------------------------------
AVERAGE      | —        | 7.9    | 3.6    | 6.2   

@github-actions

Copy link
Copy Markdown

Offline VBx Pipeline Results

Speaker Diarization Performance (VBx Batch Mode)

Optimal clustering with Hungarian algorithm for maximum accuracy

Metric Value Target Status Description
DER 10.4% <20% Diarization Error Rate (lower is better)
RTFx 9.82x >1.0x Real-Time Factor (higher is faster)

Offline VBx Pipeline Timing Breakdown

Time spent in each stage of batch diarization

Stage Time (s) % Description
Model Download 18.321 17.1 Fetching diarization models
Model Compile 7.852 7.3 CoreML compilation
Audio Load 0.078 0.1 Loading audio file
Segmentation 27.763 26.0 VAD + speech detection
Embedding 106.588 99.8 Speaker embedding extraction
Clustering (VBx) 0.096 0.1 Hungarian algorithm + VBx clustering
Total 106.854 100 Full VBx pipeline

Speaker Diarization Research Comparison

Offline VBx achieves competitive accuracy with batch processing

Method DER Mode Description
FluidAudio (Offline) 10.4% VBx Batch On-device CoreML with optimal clustering
FluidAudio (Streaming) 17.7% Chunk-based First-occurrence speaker mapping
Research baseline 18-30% Various Standard dataset performance

Pipeline Details:

  • Mode: Offline VBx with Hungarian algorithm for optimal speaker-to-cluster assignment
  • Segmentation: VAD-based voice activity detection
  • Embeddings: WeSpeaker-compatible speaker embeddings
  • Clustering: PowerSet with VBx refinement
  • Accuracy: Higher than streaming due to optimal post-hoc mapping

🎯 Offline VBx Test • AMI Corpus ES2004a • 1049.0s meeting audio • 134.4s processing • Test runtime: 2m 20s • 06/28/2026, 05:15 PM EST

@github-actions

Copy link
Copy Markdown

✅ Nemotron Multilingual Benchmark — FLEURS

FLEURS en_us, chunk 2240ms, 100 samples, B1 fused decode path. Same English audio against both shipped models.

Model Language WER RTFx
latin/ (pruned 2828) English 7.84% 4.6x
multilingual/ (full 13087) English 7.91% 4.7x
Logs (tail)
[latin / English]

Language     | Prompt   | WER%   | CER%   | RTFx   | Duration  | Processed | Skipped
--------------------------------------------------------------------------------
en_us        | en-US    | 7.8    | 3.5    | 4.6    | 953.9s    | 100       | -
--------------------------------------------------------------------------------
AVERAGE      | —        | 7.8    | 3.5    | 4.6   


[multilingual / English]

Language     | Prompt   | WER%   | CER%   | RTFx   | Duration  | Processed | Skipped
--------------------------------------------------------------------------------
en_us        | en-US    | 7.9    | 3.6    | 4.7    | 953.9s    | 100       | -
--------------------------------------------------------------------------------
AVERAGE      | —        | 7.9    | 3.6    | 4.7   

@github-actions

Copy link
Copy Markdown

Speaker Diarization Benchmark Results

Speaker Diarization Performance

Evaluating "who spoke when" detection accuracy

Metric Value Target Status Description
DER 80.8% <30% ⚠️ Diarization Error Rate (lower is better)
JER 80.9% <25% ⚠️ Jaccard Error Rate
RTFx 29.91x >1.0x Real-Time Factor (higher is faster)

Diarization Pipeline Timing Breakdown

Time spent in each stage of speaker diarization

Stage Time (s) % Description
Model Download 11.208 31.9 Fetching diarization models
Model Compile 4.803 13.7 CoreML compilation
Audio Load 0.058 0.2 Loading audio file
Segmentation 10.522 30.0 Detecting speech regions
Embedding 17.536 50.0 Extracting speaker voices
Clustering 7.014 20.0 Grouping same speakers
Total 35.081 100 Full pipeline

Speaker Diarization Research Comparison

Research baselines typically achieve 18-30% DER on standard datasets

Method DER Notes
FluidAudio 80.8% On-device CoreML
Research baseline 18-30% Standard dataset performance

Note: RTFx shown above is from GitHub Actions runner. On Apple Silicon with ANE:

  • M2 MacBook Air (2022): Runs at 150 RTFx real-time
  • Performance scales with Apple Neural Engine capabilities

🎯 Speaker Diarization Test • AMI Corpus ES2004a • 1049.0s meeting audio • 35.1s diarization time • Test runtime: 2m 9s • 06/28/2026, 05:17 PM EST

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.

Nemotron streaming (int8) produces zero output on a cold start on iPadOS 26.5 (Apple M1); works on macOS (M1 Pro)

1 participant