Skip to content

llm_graph_result::reset(): also reset t_h_pre_norm - #89

Open
serrynaimo wants to merge 1 commit into
charlie12345:mainfrom
serrynaimo:bugfix/pre-norm-reset
Open

llm_graph_result::reset(): also reset t_h_pre_norm#89
serrynaimo wants to merge 1 commit into
charlie12345:mainfrom
serrynaimo:bugfix/pre-norm-reset

Conversation

@serrynaimo

Copy link
Copy Markdown

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.

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Claude Fable 5 found and implemented this.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant