﻿# llama.cpp MoltenVK row guards: valid output values can coexist with damaged sentinels

The b12247 MoltenVK repair guards nonexistent rows; combine numerical output checks with sentinel protection around the intended tensor range.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-engine-moltenvk-extra-row-bounds-sentinels/
Language: en

llama.cpp b12247 repairs Vulkan shader row-boundary accesses observed through MoltenVK. The upstream report describes shaders that did not check whether a dispatched row existed, causing backend-test sentinel mismatches. This is a logical tensor-boundary issue: extra invocations can touch storage outside the intended result even when ordinary rows look correct.

## Rounded dispatches can create inactive rows

A launch can contain invocations beyond the logical row count. Those invocations need a correct guard before reading or writing tensor data. A proposed test uses row counts that do not fill the selected dispatch granularity exactly. Checking only aligned dimensions can avoid the issue. Keep active output values distinguishable and guard surrounding storage, because an extra-row write may leave every intended output element numerically correct.

## Sentinels test a different property

A sentinel mismatch reports unintended access to protected test storage. It should not be dismissed because the model still generates plausible text. Conversely, a clean sentinel does not establish arithmetic correctness inside the tensor. Use both checks and retain the original failing operation. A full model can change allocation neighbours and make the same out-of-range access appear as an unrelated later failure, so the focused backend case remains valuable.

## Translation layers need actual coverage

The report concerns MoltenVK, so testing a different native Vulkan driver does not reproduce the same compilation and execution path. Record the translation layer and platform with the build. Do not infer that every macOS GPU path is affected in the same way: native Metal is another backend. A proposed qualification runs the documented shader operations through the actual MoltenVK configuration and compares ordinary and tail-row cases.

## Do not borrow a performance claim from a bounds fix

The release reports a memory-access correction, not a universal throughput improvement. A local assessment should first show safe bounds and correct values, then measure cost if relevant. This article adds no independent MoltenVK benchmark and does not claim every prior crash on that stack had this cause. The practical benefit is a defined exclusion of nonexistent rows from the operator’s memory accesses.

## Sources

- [llama.cpp b12247 release](https://github.com/ggml-org/llama.cpp/releases/tag/b12247)
- [llama.cpp pull request #31890](https://github.com/ggml-org/llama.cpp/pull/31890)

## Related reading

- [What does llama.cpp b12221 fix in Metal flash attention scratch writes?](/journal/news-llamacpp-metal-flash-attention-scratch-guard/)
- [CUDA errors: separate launch status from asynchronous execution failure](/journal/fg2-cuda-asynchronous-error-attribution-boundary/)
