Repository navigation
qwen4exp : give drafters the mean of the hyper-connection streams as layer input - #307
danielhanchen wants to merge 1 commit into
Conversation
…layer input DFlash and EAGLE3 read one n_embd row per token from the target's layer inputs. qwen4exp handed them the whole [n_embd, hc, T] residual, so extract_layer_inputs saw hc*n_embd floats per row and aborted on GGML_ASSERT(row_floats == model.hparams.n_embd) on the first prompt. Build the mean over the hc streams only for the layers a drafter asked for, as deepseek4 already does. The graph is unchanged when no layer input is requested.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 520c6b28b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ((size_t) il < cparams.embeddings_layer_inp.size() && cparams.embeddings_layer_inp[il]) { | ||
| ggml_tensor * mean = ggml_view_2d(ctx0, res_hc, n_embd, res_hc->ne[2], res_hc->nb[2], 0); | ||
| for (int64_t s = 1; s < hc; ++s) { | ||
| mean = ggml_add(ctx0, mean, ggml_view_2d(ctx0, res_hc, n_embd, res_hc->ne[2], res_hc->nb[2], s*res_hc->nb[1])); | ||
| } | ||
| res->t_layer_inp[il] = ggml_scale(ctx0, mean, 1.0f/hc); |
There was a problem hiding this comment.
Add regression coverage for Qwen4exp layer extraction
This fix changes tensor shape and contents only when embeddings_layer_inp[il] is enabled, but no automated test enables that path for Qwen4exp; the existing test-llama-archs -a qwen4exp coverage therefore exercises only the unchanged graph and would still pass if this block again returned hc*n_embd values per token or computed the wrong reduction. Add a committed test that enables extraction and verifies an n_embd-wide stream mean; CONTRIBUTING.md:35 explicitly requires a regression test for bug fixes.
AGENTS.md reference: AGENTS.md:L18-L20
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Keeping the pin to the one-line graph change; test-llama-archs has no layer-input mode and adding one is a harness change beyond this fix. The extraction is checked against the host-side stream mean in the harness quoted in the description, and the pin is recorded under unchecked in feature-checks.json (#308).
|
|
||
| for (int il = 0; il < n_layer; ++il) { | ||
| res->t_layer_inp[il] = res_hc; | ||
| // drafters (DFlash, EAGLE3) read one n_embd row per token: the mean of the hc streams, as in deepseek4 |
There was a problem hiding this comment.
Replace the AI-authored commit metadata
The reviewed commit identifies its author as Codex <[email protected]> and includes a generated long-form PR-style commit message, but this repository explicitly prohibits AI-written commit messages and automated commits and treats them as grounds for immediate closure. Have the human contributor author the commit metadata and message rather than submitting this commit as-is.
AGENTS.md reference: AGENTS.md:L48-L52
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not the case: the commit is authored and committed by Daniel Han [email protected] (see the commit API for 520c6b2), and the message is a normal subject plus short body.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes unslothai/unsloth#14381 (upstream report: ggml-org#30887).
Problem
Qwen3.8-Flash-Next (
qwen4exp) with a DFlash drafter (for exampleincoai/Qwen3.8-Flash-Next-DFlash2-GGUF) loads fine, then the server aborts on the first prompt:DFlash and EAGLE3 turn on layer-input extraction for their target layers and read one
n_embdrow per token.qwen4expkeeps its residual as 4 hyper-connection streams and setres->t_layer_inp[il] = res_hc, the whole[n_embd, hc, T]tensor. That givesextract_layer_inputshc * n_embdfloats per token, and the assert fires. The drafter's model card says it was trained on the mean of the four streams, which llama.cpp did not compute.Change
For layers a drafter requested,
t_layer_inp[il]is now the mean over the hc streams. This is the same view + add + scale thatdeepseek4already uses (build_hc_mean). Nothing is built when no layer input is requested, so the graph without a drafter is unchanged. One file, +10 / -1.Based on upstream
b11724(the base ofb11724-mix-c208e5f, the build in the report). The bug is still present on ggml-orgmaster.Evidence (CPU, tiny random models from
test-llama-archs -o)The harness loads the model, enables
llama_set_embeddings_layer_inpfor a layer, decodes 16 tokens, and compares every extracted row against an independent reference: the previous layer'sl_lastoutput, captured withcb_evaland averaged over the streams on the host.llama-context.cpp:2409: GGML_ASSERT(row_floats == model.hparams.n_embd) failed[256, 16], max abs error vs stream mean 2.98e-085aeeaf45b3859deb), and turning extraction on leaves the logits unchanged.test-llama-archs -a qwen4exp: CPU NMSE 0, roundtrip OK, mixed batch OK on both arms.b11724pin tree, which is where the reporter's line 2456 assert sits.Not run here: the full 125B target with the real drafter (82 GB+), so this PR does not measure acceptance rate. HIP / CUDA / Vulkan builds were not run either. The ops are the ones
deepseek4already runs on every backend.