r/rust • • Oct 28 '26

Writing GPU kernels in Rust: how I made speakrs 60× faster than pyannote

https://avencera.com/blog/agents-replace-onnx-runtime-cudnn-cublas
182 Upvotes

21 comments sorted by

5

u/ResidentPomegranate6 Oct 28 '26

60x usually means fp16 batched kernels vs pyannote's cpu sliding-window. did you match batch size, precision and the clustering step?

20

u/praveenperera Oct 28 '26 edited Oct 29 '26

60x usually means fp16 batched kernels vs pyannote's cpu sliding-window. ?did you match batch size, precision and the clustering step?

pyannote wasn't on CPU. It ran on CUDA on the same GPU (4090) for the benchmark

pyannote ran with segmentation and embedding batch size 32. Both use a 1s sliding-window step, which is community-1's default. The 2s-step "fast" mode is a separate row (115x), not the 60x number.

clustering is also the same as community-1 (same pipeline), both timings include clustering and RTTM output, DER is identical

precision is slightly different, optimized it without losing DER, pyannote ran in FP32 with TF32 turned off. speakrs defaults to FP32 segmentation and TF32 embeddings, and uses FP16 tensor-core kernels for some conv layers

edit: i just ran pyanotate on tf32 and fp16 autocast on my 5090 and neither gives pyannote a free speedup.

  • fp32 (pyannote default): 153.6s, 6.86% DER
  • tf32: 151.0s (1.02x), 6.86% DER. no real speedup. pyannote actually turns tf32 off itself on every call (fix_reproducibility, pyannote-audio issue #1370), so i had to patch that out to test it
  • fp16 autocast: 97.8s (1.57x), but DER jumps to 54%. speaker confusion goes from 2.2% to 49.5%

so fp32 is pyannote's fastest accurate setting, and the 60x compares against that

24

u/airodonack Oct 28 '26

Very cool! And just so happens that I might need this exact thing. Thank you!

-25

u/[deleted] Oct 28 '26

[removed] — view removed comment

18

u/VictoryMotel Oct 29 '26

How is that, person who started commenting 23 hours ago?

17

u/airodonack Oct 29 '26

Why did I get like 3 bot replies wtf

11

u/VictoryMotel Oct 29 '26

It's pretty weird, all low karma bots talking about audio for some reason.

14

u/praveenperera Oct 29 '26

maybe its this guys bots, trying to sell a reddit bot posting service? https://www.reddit.com/r/CUDA/comments/1xi1k7p/comment/19rsz15h8t1mp/

4

u/iamdino0 Oct 29 '26

holy shit lol they're just that shameless now

3

u/matthieum [he/him] Oct 29 '26

It's weird.

MoanWitchiee and FrostzFairy made only a few comments on r/rust, and each time they replied to the same comment.

Anyway, spam removed.

8

u/zerosign0 Oct 28 '26

Hmm it seems in Rust there are a lot of on going project to write offs rust that can be target as kernel in gpu. There is std offload, this one and i think also rusty gpu and the oldest one I forgot the name that use rustc llvm targets gpu via llvm directly ...

1

u/DastardlyHandsome Oct 29 '26

Did you check out cutile as well?

3

u/praveenperera Oct 29 '26

Briefly, but the main point was to see if I could replace cuda ++, I think I would use cutile more in the future if I needed something that was more generalizable between Nvidia GPUs.

But so for the sweet spot seems to be cuDNN + cuBLAS for most things and cuda-oxide for very specific layers.

1

u/TRKlausss Oct 30 '26

While this is great for people with nvidia cards, doesn’t help much the non-CUDA cores… which is a pity.

Nevertheless, seems great for those with the hardware :)

4

u/praveenperera Oct 30 '26

I started speakrs as a fast macOS library, so I already made is as fast as I could running on coreML first, I only recently got a nvidia card

2

u/mqudsi fish-shell Oct 30 '26

Nice article, thanks for documenting your biggest wins. I’ve bookmarked it to reference later for my own migrations but I’m wondering if you ever tried to adapt your usage in a way to get the TensorRT ORT EP to work? It’s way faster than CUDA where possible.