Skip to content

engine#315: coherence for host-visible HRX buffers (llama.cpp pin move) - #366

Closed
bong-water-water-bong wants to merge 2 commits into
mainfrom
engine-315/coherence-fix
Closed

bong-water-water-bong wants to merge 2 commits into
mainfrom
engine-315/coherence-fix

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Draft. The pin move and the fork-side change are final; the acceptance campaign is running on
strixhalo and KNOWN-ISSUES.md will be updated in this branch with its evidence and the met criterion
before this is marked ready for review. Opened as a draft now so the CI checks (including
tools/check_pins.py) run while the campaign finishes.

What moves

third_party/llama.cpp: e44c9d01a4d5 -> fb4dff7bbb7a (branch
engine-315/host-visible-coherence
in 1bit-MONSTER/llama.cpp). The old pin is an ancestor of the new one, so this is forward, not a revert.

The change (fork side, one function)

ggml/src/ggml-hrx/ggml-hrx.cpp, 7 insertions / 3 deletions in buffer_alloc: coherence becomes
unconditional for host-visible buffers.

A host-visible buffer is read directly by the CPU — the generic ggml_backend_tensor_get_async
short-circuits for host buffers, so no backend copy runs and nothing in the transfer path orders the
device's write against that read. Coherence was gated on direct_host_binding
(GGML_HRX_USE_UNIFIED_MEMORY, default off), so in the default configuration the reader could
observe unwritten bytes from the output region. That is the whole defect shape: whole-vocabulary NaNs
on one face (Face A, common/sampling.cpp:587 guard then GGML_ABORT), and output bytes that are not
valid UTF-8 surfacing as an HTTP 500 parse failure on the other (Face B) — the same unwritten/wrong
output landing in two places. Same memory class, one bit, no new allocation path, no configuration
change, and it fixes the default rather than requiring a toggle.

Evidence so far (details and paths to follow in KNOWN-ISSUES.md)

  • Route: the sampler reads the output region directly — no 619520-byte download exists on it (the
    per-layer weight leases are the only downloads, all hashes_equal=1), and the deferred-writeback
    path is a measured hard negative (0 [hrx-wb-fp] records over a complete arm).
  • Region: HRX0_HOST host_visible=1 direct_host_binding=0 memory_type=0x52 size=619520
    (619520 = 154880 x 4, matching the Face-A guard's count=154880) — host-visible, not
    HOST_COHERENT.
  • Discriminating run (instrumented, in-regime at gtt_start 98 GiB, alternating default vs
    coherent): 3 pairs clean/clean, pair 4 default FAULT (Face B: 500 after
    unparsed Content-only output) with the coherent arm clean.
  • Live on the real binary, per arm: control logits buffer memory_type=0x52, fix cell
    memory_type=0x56 (HOST_COHERENT).
  • Acceptance campaign: running, >=60 in-regime fix-cell arms required with zero faults on both
    faces; results, CI and the power statement to be posted here when it completes.

…engine#315)

third_party/llama.cpp e44c9d01a4d5 -> fb4dff7bbb7a, a descendant: the pin is an ancestor of the new
revision, so this is a forward move and not a revert.

The single change on the fork side makes coherence unconditional for host-visible buffers. Such a
buffer is read directly by the CPU - the generic ggml_backend_tensor_get_async short-circuits for
host buffers, so no backend copy runs and nothing in the transfer path orders the device's write
against that read. Coherence was gated on direct_host_binding (GGML_HRX_USE_UNIFIED_MEMORY, default
off), so the default configuration could read unwritten bytes from the output region.

Measured on strixhalo, GLM-4.7-Flash, in-regime at gtt_start 98 GiB: the discriminating run put a
fault on the non-coherent side only (default FAULT with the coherent arm clean); every default arm
allocates the logits buffer as host-visible non-coherent (0x52) and every coherent arm as
HOST_COHERENT (0x56).
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 154fbc3)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Coherence for Host-Visible Buffers
The change modifies buffer allocation to make coherence unconditional for host-visible buffers. Previously, coherence was only applied when direct_host_binding was enabled (i.e., when GGML_HRX_USE_UNIFIED_MEMORY was on). With this change, all host-visible buffers now enforce coherence, which is necessary to prevent the CPU from reading unwritten or stale data from device memory. This fixes a potential data race condition where the CPU could observe invalid output, such as NaNs or invalid UTF-8, leading to crashes or incorrect behavior.

Moving a submodule pin requires regenerating registry/architectures.json, which the ctest case
registry_pins (tools/registry_build.py --check-pins) enforces. The architecture data is unchanged -
the fork-side change touches ggml-hrx.cpp's buffer allocator, not architecture definitions - so only
the recorded pin moves.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 154fbc3

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing: the candidate did not survive its own pre-registered acceptance campaign, so it must not land.

Fix cell: 9 clean / 1 fault in-regime (10.0%, 95% CI 1.8-40.4); control: 3 clean / 1 fault (25%); Fisher p = 0.505 -> acceptance NOT MET (>=60 clean, zero faults required). The stopping rule ended the run at the first fix-cell fault, and the decisive line is that arm itself:

pair 10 arm l: FAULT nan=0 req=33 parse=0 gtt_start=98G hv52=0 hv56=1

hv56=1 means the output region was HOST_COHERENT when it faulted (the same per-arm trace that proved the fix live in the smoke), so a visibility gap in the output region is not a sufficient cause. The fork branch engine-315/host-visible-coherence is left in place as the tested candidate; the full record is in the engine issue #315 and in docs/315-mechanism.md of the evidence branch.

The one part of this PR that is independent of the fix is the CI lesson: moving a submodule pin requires regenerating registry/architectures.json (ctest registry_pins), which is why the first run of this PR failed and the second passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant