[CUDA] Added a cudaMemcpy2DAsync fast path to ggml_cuda_cpy#25057
Open
gaugarg-nv wants to merge 3 commits into
Open
[CUDA] Added a cudaMemcpy2DAsync fast path to ggml_cuda_cpy#25057gaugarg-nv wants to merge 3 commits into
gaugarg-nv wants to merge 3 commits into
Conversation
Add a CUDA ggml_cpy fast path for same-type, same-shape strided copies that are just 2D pitched block copies. When tensors are not fully contiguous but each row is contiguous, it now uses cudaMemcpy2DAsync instead of the slow element-wise scalar copy kernel. This fixes the GDN recurrent snapshot update with -np 4, where rollback slots are separated by cache stride gaps.
am17an
approved these changes
Jun 27, 2026
am17an
left a comment
Contributor
There was a problem hiding this comment.
Can we add a test-backend-ops for this shape in case it doesn't exist?
Contributor
Author
Thanks. There indeed was no test executing this path. I have added one now. |
Contributor
Author
|
OpenVino backend is failing these two tests. Adding checks in OpenVino to return unsupported for strided copies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add a CUDA ggml_cpy fast path for same-type, same-shape strided copies that are just 2D pitched block copies. When tensors are not fully contiguous, but each row is contiguous, it now uses
cudaMemcpy2DAsyncinstead of the slow element-wise scalar copy kernel.This fixes the GDN recurrent snapshot update with
-np 4, where rollback slots are separated by cache stride gaps. This has no impact on-np 1perf as that is already using optimizedcudaMemcpyAsyncpath.MTP=3 on RTX 5090 with Unsloth Qwen3.6-27B Q4_K_M with
-np 4shows a perf gain of ~7.5%.Master:
PR:
Requirements