cuda: fix layer split mode preventing cuda graph compilation #13815
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When layer split is used, the output from one layer is the input to another layer.
I noticed that CUDA graphs would eventually give up due to too many changes in the graph. The input tensor would have a
data
address that would cycle between 4 (I think) allocated values. I dug into this a bit to see if I could fix that, so the cuda graph would not have a noisy input address, but my understanding is that this is done due to pipelining? Maybe that is the correct fix, and someone else could make that change. This change works under the assumption that the underlying platform is working as intended here.In any case, I implemented CUDA graph compilation to account for input address changes by caching CUDA Graphs, and (quickly) finding the one that matches from a LRU set.
This showed appreciable gains in tokens per second:
bartowski/Qwen2.5-72B-Instruct-GGUF:IQ4_XS, 2 x RTX PRO 6000:
Before: 29 tokens/s
After: 35 tokens/s