-
Notifications
You must be signed in to change notification settings - Fork 23.3k
CUDA: Support of GDN chunked kernel for prefill #26001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BLSharda
wants to merge
7
commits into
ggml-org:master
Choose a base branch
from
BLSharda:bhaviksharda/chunked_gdn
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ce878a
CUDA: Support of GDN chunked kernel for prefill
BLSharda 881bb77
CUDA: Fixed GDN chunked review comments and converted to use FP16 mos…
BLSharda 9a906df
CUDA: Added ggml_cuda_mma path for HID/MUSA
BLSharda 10c1e46
Updating based on review comments
BLSharda 2f47155
Apply batched suggestions from code review
BLSharda 5eb4306
Fixed RDNA3 compilation
BLSharda 47bed13
Merge branch 'ggml-org:master' into bhaviksharda/chunked_gdn
BLSharda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #pragma once | ||
|
|
||
| #include "common.cuh" | ||
| #include "gated_delta_net.cuh" | ||
| #include "ggml.h" | ||
|
|
||
| void ggml_cuda_op_gated_delta_net_chunked(ggml_backend_cuda_context & ctx, ggml_tensor * dst, | ||
| const ggml_cuda_gated_delta_net_fused_cache * cache); | ||
|
|
||
| // Chunked-GDN scratch, carved out of the tail of dst's own allocation. Two reasons: | ||
| // 1. The graph allocator sizes every tensor through ggml_backend_buft_get_alloc_size, so scratch | ||
| // that lives in dst's buffer is visible to llama_params_fit (--fit). A context-owned cudaMalloc | ||
| // (or the old ggml_cuda_pool_alloc) is invisible to that projection, which made --fit | ||
| // under-estimate VRAM by the full scratch size. | ||
| // 2. The address is a fixed offset from dst->data, so it is stable across CUDA-graph capture and | ||
| // replay without needing a separate persistent allocation to be pre-sized before capture. | ||
| struct ggml_cuda_gdn_chunked_scratch { | ||
| float * v_corr; | ||
| float * k_cumdecay; | ||
| float * g_cum; | ||
| float * qk; | ||
| uintptr_t end; | ||
| }; | ||
|
|
||
| // Pure function of the tensor graph, so allocation time and execution time cannot disagree. | ||
| ggml_cuda_gdn_chunked_scratch ggml_cuda_gdn_get_chunked_scratch(const ggml_tensor * dst); | ||
|
|
||
| // ggml_nbytes(dst) plus the scratch above, or just ggml_nbytes(dst) when the shape is ineligible. | ||
| size_t ggml_cuda_gdn_get_alloc_size(const ggml_tensor * dst); |
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.