Repository navigation
feat(dictation): add pure-Rust ONNX backend for Cleanup Tagger v2 on Windows and Linux - #3078
Merged
Merged
Conversation
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.
Adds a cross-platform pure-Rust CPU ONNX backend (
tract-onnx) for Cleanup Tagger v2 so Windows and Linux run the same 4-head tagger pipeline (bpe,decode,render,itn,post) as macOS Core ML, instead of returning the transcript unchanged.Before / After
src/dictation/cleanup/v2/only ran under#[cfg(target_os = "macos")](Core ML), andFeature::CleanupTaggerV2was gated toMACOS. Windows and Linux skipped v2 completely.cleanup_tagger_v2.int8.onnx(preferred, 32.5 MB) orcleanup_tagger_v2.onnxalongsidetokenizer.jsonand optionalruntime.jsonfrom<models>/cleanup-v2/(orHEX_CLEANUP_V2_DIR) throughsrc/dictation/cleanup/v2/onnx.rsusingtract-onnx(default-features = false, zero C++/DLL/VCRUNTIME dependencies, Nix-offline compatible). macOS Core ML (runtime::CoreMlV2) is untouched and does not linktract-onnxin non-test builds.Implementation details
DynamicQuantizeLinearquantizes activations per-tensor, which lets GeGLU outlier channels collapse normal token activations to the zero point. FoldingDynamicQuantizeLinear -> MatMulInteger -> Cast -> Mulwith constant INT8/UINT8 weights intof32MatMulon load matches Core ML's weight-only quantization while keeping the 32.5 MB on-disk artifact.Skip::NotInstalledwithout blocking or crashing; Windows and Linux dictation loops callcleanup::prepare()on startup and hotkey press to warm the model in the background;labs.unload_idleandreconcilerelease it.Feature::CleanupTaggerV2fromMACOStoEVERY(stillDevaudience, off by default) and surfaced it in Labs on Windows and Linux developer builds.Measured parity & latency (
cleanup_tagger_v2.int8.onnx, release CPU)model-parity.json)model-parity.json)"21st."matching PyTorch/ORT FP32 vs Core ML's"20 first.")Verification
HEX_UPDATE_LABS_JSON=1 scripts/check labs::web(2/2 passed)scripts/check labs control::settings(102/102 passed)scripts/check dictation::cleanup(110/110 passed)scripts/check rune_ui(648/648 passed)cargo clippy --locked --bin hex -- -D warnings(clean)python3 scripts/code-shape.py(no hard problems)the_real_v2_onnx_model_answers_as_the_reference_recorded) and macOS Core ML (the_real_v2_model_answers_as_the_reference_recorded)