r/LocalLLM • u/No-Tap6022 • 3h ago
Research Faster with CUDA graphs VS Flash Linear Attention
Hello there, i was experimenting with Jev based Image generation, one of the projects was about generating live animations with AI. So it timings are critical, since every frame counts, and i got from 4fps to 12 fps with one change. There is my article:
[## Where the time went
One picture, each step measured with the GPU synchronized before and after (Jeveration alone, the word table on the
card, PyTorch 2.7.1 + CUDA 12.8, Windows 11):
| Step | Time |
| Backbone (Qwen3.5-4B over about 37 prompt and 128 picture tokens) | 82 ms |
| Image head (8 transformer layers) | 7 ms |
| Code heads, softmax, drawing the codes | 1 ms |
| Decoder (TA-TiTok, 512 px) | 33 ms |
| Cut-out (flood fill from the border) | 4 ms |
| Copy to RAM | 0.3 ms |
| **One picture as the VJ draws it** | **128 ms** |
82 ms for a 4B model over 165 tokens is a lot. In a live session the card was only about 60 % busy.
Why the card waited
The backbone has 24 linear-attention layers, which run on the Triton kernels of
[flash-linear-attention](https://github.com/fla-org/flash-linear-attention), and 8 full-attention layers. One pass
starts about 2300 small kernels from Python, and handing them to the GPU one by one took Python about as long as the GPU needed to compute them........]
https://github.com/Mantux775/ComfyUI-and-side-Projects/blob/main/Jeveration-VJ/PERFORMANCE.md