ncnn技术总结 #6863
Krystal579-max
started this conversation in
General
ncnn技术总结
#6863
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I am excited to share a project that ports the Qwen3-TTS model to the ncnn inference framework, enabling efficient deployment on edge devices.
Project Overview
The goal was to move Qwen3-TTS from a Python/PyTorch environment to a pure C++ environment using the ncnn library. This removes dependencies like Python and Torch, significantly reducing runtime overhead and memory usage, making it suitable for embedded systems.
Key Technical Steps
Used pnnx to convert the PyTorch model to ncnn’s .param and .bin format.
Ensured all operators (Attention, LayerNorm, etc.) are supported by ncnn.
Implemented the Autoregressive decoding loop (similar to LLM text generation) in C++.
Handled KV Cache management to optimize generation speed.
Manually ported the Tokenizer logic to avoid heavy dependencies.
Configured CMakeLists.txt to support both Linux (GCC/Clang) and Windows (MSVC).
Verified compilation on Ubuntu 20.04 and Windows 10.
Compared the output waveforms of the ncnn version against the original PyTorch model.
Achieved an MSE < 1e-5, ensuring audio quality remains identical.
Performance
Platform: Intel i5 CPU
Speed: Real-Time Factor (RTF) approx 0.1 on CPU (generates 10s audio in 1s).
Size: No external dependencies besides ncnn.
Repository
The source code, build instructions, and conversion scripts here:
[https://github.com/Krystal579-max/Qwen3-TTS-ncnn.git]
Acknowledgments
Big thanks to the Qwen team for the amazing model, and the ncnn community (https://github.com/Krystal579-max/Qwen3-TTS-ncnn.git) for the excellent reference implementation.
Let me know if you encounter any issues or have suggestions for optimization!
All reactions