feat: optimize ONNX peak RSS with mmap'd external-data weights - #138
Conversation
|
Thanks @Avadhut2 for the PR and for identifying the ONNX external-data approach. It produced a meaningful peak-memory improvement, and the follow-up needed for merge is now complete. What changed:
Compared with the existing inline ONNX files, load-peak RSS was reduced by moving non-empty tensor weights into 64 KiB-aligned external-data sidecars. This lets ONNX Runtime map or read the weights separately from the graph protobuf, avoiding an additional large inline tensor payload during session initialization. Model architecture and precision were unchanged. Measured load-peak RSS reductions:
WER parity on the same 50-utterance FLEURS English slice:
Validation:
These results support keeping Parakeet as the general ASR default. Canary remains opt-in for its smaller bundle and multilingual transcription/translation support. Thanks again for the contribution. I am merging with a normal merge commit so the original author commit remains in the project history. |
Summary
Optimizes ONNX peak RSS on memory-constrained devices by memory-mapping external data.
What Changed
scripts/export_external_data.pyto extract and 4096-byte page-align heavy ONNX tensors.models.mdexplaining how to bundle memory-mapped heavy models.AGENTS.mdwith guidelines making external data mandatory for models >= 100MB.Test Plan
threshold=0..onnx.datapayload offset alignments to 4096-byte boundaries.session.use_device_allocator_for_initializersproperly loads aligned format into mapped memory natively.