feat: add Qwen3-ForcedAligner-0.6B CoreML conversion and inference#21
Open
Alex-Wengg wants to merge 3 commits intomainfrom
Open
feat: add Qwen3-ForcedAligner-0.6B CoreML conversion and inference#21Alex-Wengg wants to merge 3 commits intomainfrom
Alex-Wengg wants to merge 3 commits intomainfrom
Conversation
Add CoreML conversion pipeline for Qwen3-ForcedAligner-0.6B, a non-autoregressive forced alignment model that produces per-word timestamps from audio + text. The pipeline splits the model into 5 CoreML components: - Audio conv frontend (per-chunk mel → conv features) - Audio transformer (cross-chunk bidirectional attention + projection) - Token embedding (vocab → hidden states) - Decoder prefill (28-layer Qwen3 decoder, single NAR pass) - LM head (hidden states → 5000 timestamp bins) Key design decisions: - Audio encoder split into conv + transformer to preserve cross-chunk attention (monolithic per-chunk approach had 20.7ms AAS vs 4.4ms split) - MRoPE cos/sin computed outside the model for flexibility - Last mel chunk trimmed after conv to remove padding artifacts - Decoder and LM head use FLOAT32 precision to avoid FP16 overflow Parity vs PyTorch (3 LibriSpeech test-clean samples, 54 boundaries): - AAS: 4.4ms, within 20ms: 95.4%, within 80ms: 99.1% Co-Authored-By: Claude <noreply@anthropic.com>
The inference script supports two audio encoder paths with auto-detection. Split encoder (audio_conv + audio_transformer) preserves cross-chunk attention for 4.4ms AAS. Monolithic encoder (audio_encoder) is faster but lacks cross-chunk attention (20.7ms AAS). Added comparison table and updated architecture, I/O shapes, inference pipeline, conversion, and parity sections.
Document 5 bugs encountered during FluidAudio Swift integration: MLMultiArray stride issues, encoder 3D shape, Slaney vs HTK mel, STFT center padding, and MRoPE position clamping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Files
convert-coreml.pyindividual_components.pyrun_coreml_inference.pycompare-models.pypyproject.toml/uv.lockREADME.mdproblems_encountered.mdCoreML Components (5 models)
[1, 128, 100]mel[1, 13, 1024]conv features[1, 256, 1024]features[1, 256, 1024]embeddings[1, seq, int32][1, seq, 1024][1, 1024, 1024]+ RoPE[1, 1024, 1024][1, seq, 1024][1, seq, 5000]timestampsParity vs PyTorch (3 LibriSpeech test-clean samples, 54 word boundaries)
Test plan
cd models/stt/qwen3-forced-aligner-0.6b/coreml && uv syncuv run python convert-coreml.py— convert all 5 componentsuv run python compare-models.py --num-files 3— generate PyTorch referenceuv run python run_coreml_inference.py compare— verify CoreML vs PyTorch parity🤖 Generated with Claude Code