Dia-TTS-Server icon indicating copy to clipboard operation
Dia-TTS-Server copied to clipboard

Humble Request!

Open danhigham opened this issue 1 year ago • 5 comments

Hello! This is an awesome project and right out of the gate is getting amazing results! One thing that would be really cool, would be the ability to use more than one GPU for chunked encoding. I would love to help anyway I can, but I would definitely need an outline of how I could do this and then submit you a PR.

danhigham avatar Apr 29 '25 22:04 danhigham

@danhigham that sould already be possible! its simply not exposed by the API. Same goes for torch.compiling the model ;)

l4b4r4b4b4 avatar Apr 30 '25 10:04 l4b4r4b4b4

@l4b4r4b4b4 Any hints as to how to achieve this would be gratefully received. 😃

danhigham avatar Apr 30 '25 21:04 danhigham

Thanks for the great ideas on using multiple GPUs. Speeding up generation is definitely something I want to look into for the next version, as it could make a big difference.

Right now, the server code is set up to load just one copy of the model globally. Getting it to run across multiple GPUs for parallel chunk processing isn't a quick switch – it needs some deeper changes to how the model is handled.

I've brainstormed two ways this could be done:

Integrated parallelism: This means changing the main server code (engine.py and server.py) quite a bit. I'd need to remove the single global model instance and build a new system inside the server to load and manage multiple model copies, potentially even more than one per GPU. This keeps everything in one place but requires significant refactoring of the current structure.

Orchestration: This approach avoids changing the current server code much. I could run multiple, separate instances of the existing server, each locked to a specific GPU using standard tools (CUDA_VISIBLE_DEVICES). Then, I'd create a new, separate "coordinator" script that takes the user's request, splits the text, sends chunks to the different running servers, and stitches the audio back together. From the client's perspective everything remains the same. This coordinator will act as a regular server using the same port, endpoints and parameters.

Both options are pretty involved and would take significant time and effort to build and test properly. I think the second approach is better. It's definitely a valuable direction for future improvements, though. Thanks again for the input.

devnen avatar Apr 30 '25 21:04 devnen

I actually dont think multi GPU is something you want, as the model fits on a single GPU with ~6 GB VRAM. So putting it on multiple GPU devices just adds communication overhead => Slower inference.

@danhigham look into device maps with tensor parellelism (one machine with mutiple GPUs) its pretty straight forward.

https://huggingface.co/docs/accelerate/usage_guides/big_modeling

l4b4r4b4b4 avatar May 01 '25 10:05 l4b4r4b4b4

Until this is implemented, you may want to check this fork periodically for potential improvements in speed: https://github.com/l4b4r4b4b4/speech-io-server

devnen avatar May 04 '25 16:05 devnen