port(ggml): in-place GDN state write + qwen dense decode recovery (lucebox-ggml #24, #27)#499
Merged
davide221 merged 2 commits intoJul 8, 2026
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/deps/llama.cpp/ggml/src/ggml-cuda/gated_delta_net.cu">
<violation number="1" location="server/deps/llama.cpp/ggml/src/ggml-cuda/gated_delta_net.cu:593">
P2: `ggml_gated_delta_net_inplace` now has backend-dependent semantics: CUDA writes the final recurrent state into `src_state`, while the CPU GDN implementation still writes only into `dst`. A graph that falls back off CUDA will keep using stale state, so the in-place flag should either be implemented/rejected consistently in non-CUDA backends or kept out of the generic API path.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| const float * s_d = (const float *) src_state->data; | ||
| float * dst_d = (float *) dst->data; | ||
| const int64_t attn_score_elems = S_v * H * n_tokens * n_seqs; | ||
| const bool inplace_state = ggml_get_op_params_i32(dst, 1) != 0; |
Contributor
There was a problem hiding this comment.
P2: ggml_gated_delta_net_inplace now has backend-dependent semantics: CUDA writes the final recurrent state into src_state, while the CPU GDN implementation still writes only into dst. A graph that falls back off CUDA will keep using stale state, so the in-place flag should either be implemented/rejected consistently in non-CUDA backends or kept out of the generic API path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At server/deps/llama.cpp/ggml/src/ggml-cuda/gated_delta_net.cu, line 593:
<comment>`ggml_gated_delta_net_inplace` now has backend-dependent semantics: CUDA writes the final recurrent state into `src_state`, while the CPU GDN implementation still writes only into `dst`. A graph that falls back off CUDA will keep using stale state, so the in-place flag should either be implemented/rejected consistently in non-CUDA backends or kept out of the generic API path.</comment>
<file context>
@@ -586,6 +589,9 @@ void ggml_cuda_op_gated_delta_net(ggml_backend_cuda_context & ctx, ggml_tensor *
const float * s_d = (const float *) src_state->data;
float * dst_d = (float *) dst->data;
+ const int64_t attn_score_elems = S_v * H * n_tokens * n_seqs;
+ const bool inplace_state = ggml_get_op_params_i32(dst, 1) != 0;
+ float * state_out_d = inplace_state ? (float *) src_state->data : dst_d + attn_score_elems;
const int * parent_ids_d = src_parent
</file context>
howard0su
approved these changes
Jul 8, 2026
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.
Ports two open ggml feature PRs from
Luce-Org/lucebox-ggmlinto the in-tree vendored ggml (server/deps/llama.cpp/ggml/), on top of the vendorization from #486. Both were intentionally excluded from the initial snapshot (seeVENDOR.md) and are brought in here.Included
perf(cuda): add in-place GDN state write(2576c152)Adds public API
ggml_gated_delta_net_inplace, which writes the final recurrent state directly intosrc[5]viaop_params[1]. Threads astate_outparam through the CUDA GDN kernels. Defaultggml_gated_delta_netbehavior is unchanged.perf(cuda): recover qwen dense decode path(c3d44ed4)ggml_cuda_set_skip_props_check) to bypass per-step graph re-validation on the stable AR decode path.WRITE_INTERtemplate specialization of the GDN kernels — the pure-AR path compiles out the intermediate-state store entirely.DFLASH_GDN_FORCE_GROUPED_COLS/DFLASH_GDN_NO_GROUPED_COLS); grouped-cols is off by default on Ampere (sm_86 / 3090).Notes
gated_delta_net.cu; applied as the union (each kernel/launch signature carries bothstate_outand theWRITE_INTERtemplate, with the runtimeskip_intermediateparam removed).server/src/. The new symbols are additive and unused by current server code.Verification
ggml.c,gated_delta_net.cu, andggml-cuda.cucompile clean under CUDA 12.6 / sm_86 using the existing build flags.server/deps/llama.cpp/ggml/; zeroserver/src/drift.