Add Supertonic FP16 MLX export and native runner - #22063
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22063
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 39c750c with merge base cff6f4d ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
a31b87f to
27f7331
Compare
|
@claude review this code |
|
Claude finished @metascroy's task in 4m 41s —— View job Code Review — Supertonic FP16 MLX export and native runnerI reviewed the export pipeline (Python), the native runner (C++), and the build/CI wiring. Overall this is a high-quality, defensively-written contribution: the validation density in Correctness1. Dead latent-padding mask in const int64_t valid_latents =
(layout.waveform_samples + base_chunk_size*chunk_compress_factor - 1) /
(base_chunk_size*chunk_compress_factor); // == layout.latent_length, alwaysSince 2. Internal chunk padding retained on multi-chunk synthesis — 3. const float increment = durations[index] + inter_chunk_silence;
result += increment;
if (!std::isfinite(increment) || !std::isfinite(result)) { ... }The Parity between Python and C++ preprocessing4.
Licensing / attribution5. BSD/Meta headers on adapted MIT code Minor / nits
Things done well
None of the above are hard blockers for the one-shot single-chunk path this PR targets; items 1 and 2 are the ones I'd most want addressed or explicitly documented. |
Summary
Add an ExecuTorch MLX implementation of Supertonic 3, Supertone's on-device multilingual TTS model.
The Python model files translate the published ONNX architecture and weights into an ExecuTorch PTE. They are needed only when creating the PTE; the C++ runner does not use Python or the source ONNX model files.
This PR supports one-shot, batch-1, five-step synthesis on macOS arm64. It does not include model weights, generated PTEs, WAVs, a persistent server, benchmarks, or application integration.
What to review
The 49 files do not need equal review depth.
1. Create the PTE (Python, export time only)
examples/models/supertonic/loaders/checkpoint_loader.pyexamples/models/supertonic/model/duration_predictor.pyexamples/models/supertonic/model/text_encoder.pyexamples/models/supertonic/model/vector_estimator.pyexamples/models/supertonic/model/vocoder.pyexamples/models/supertonic/export/common.pyexamples/models/supertonic/export/export_supertonic.pyexamples/models/supertonic/source_transformations/mlx.pyThese files define the four Supertonic stages in PyTorch, copy and convert the ONNX weights, apply MLX-compatible graph rewrites, and export four PTE methods:
duration_predictor,text_encoder,vector_estimator, andvocoder.Review the layer/weight mapping, equivalent outputs, dynamic bounds, FP16 conversion, metadata, and MLX delegation. The highest-signal tests are
test_checkpoint_loader.py,test_stage_parity.py, andtest_mlx_pipeline.py.2. Run the PTE (C++)
examples/models/supertonic/runtime/supertonic_runner.cppexamples/models/supertonic/runtime/text_processor.cppexamples/models/supertonic/runtime/style_loader.cppexamples/models/supertonic/runtime/wav_writer.cppexamples/models/supertonic/runtime/main.cppThese files load the PTE, call its four methods, preprocess and chunk text, run five generation steps, trim the waveform, and write a WAV file. Review the PTE compatibility checks, Unicode handling, tensor flow, and output validation.
The highest-signal tests are
examples/models/supertonic/runtime/tests/supertonic_runtime_test.cppandexamples/models/supertonic/runtime/tests/run_integration.cmake.3. Build and CI
examples/models/supertonic/CMakeLists.txtexamples/models/supertonic/CMakePresets.json.github/workflows/mlx.ymlexamples/models/supertonic/README.mdexamples/models/supertonic/NOTICEReview the macOS arm64 restriction, MLX runtime files, pinned-asset CI flow, usage, and licensing. The remaining unit tests, package files, and root README/Makefile entries are support changes that can be skimmed.
Runtime files
After export, synthesis needs only
supertonic_runner,mlx.metallib, the exported PTE,unicode_indexer.json, and one voice-style JSON file.Validation
45.9 ms, RTF0.0244(40.9xreal time).0.999603; SQNR:30.95 dB.Provenance
7e2804f96016a7028cb1ed627353c61c1e9dd281(MIT).Supertone/supertonic-3at3cadd1ee6394adea1bd021217a0e650ede09a323(BigScience Open RAIL-M).