llm_graph_result::reset(): also reset t_h_pre_norm - #89
Open
serrynaimo wants to merge 1 commit into
Open
Conversation
Every other result tensor pointer is cleared in reset(), but t_h_pre_norm was left holding its previous graph's pointer. When a subsequent graph does not produce a pre-norm output (not all model graph paths set it), the stale pointer aliases an unrelated tensor in the rebuilt compute arena. The pre-norm extraction in llama_context::decode() then either asserts (ggml_backend_sched_get_tensor_backend returns null) or silently reads the wrong tensor. Observed as a hard assert when combining embeddings_pre_norm with draft model graphs that only set t_h_pre_norm on some batch types; may also be implicated in dflash draft issues like charlie12345#44.
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.
Overview
reset() clears every result tensor pointer (t_logits, t_embd, t_embd_pooled, …) except t_h_pre_norm, which keeps the previous graph's pointer. When a later graph doesn't produce a pre-norm output — not all model graph paths set it — the stale pointer aliases an unrelated tensor in the rebuilt compute arena.
Symptoms: with embeddings_pre_norm enabled, the extraction in llama_context::decode() either hard-asserts (ggml_backend_sched_get_tensor_backend returns null — we caught it pointing at attn_inp_kq_mask) or, worse, silently reads the wrong tensor into the pre-norm buffer.
Repro: any target+draft setup where the draft context enables pre-norm extraction but only some batch types set t_h_pre_norm (we hit it with a draft-dflash decoder on gfx1100/HIP; first decode after prefill asserts at llama-context.cpp:2076). This may also be implicated in the DFlash weirdness reported in #44.
One-line fix; no behavior change for graphs that do set the tensor.