TECHNOLOGY

llama.cpp Metal mul_mv: promote the offset before multiplying large outputs

In this article
THE QUICK TAKE

Metal mul_mv in b12374 widens destination-offset arithmetic before multiplication; large allocations still require large-index correctness.

The November 14 llama.cpp b12374 prerelease fixes destination-offset overflow in Metal mul_mv. Upstream identifies 32-bit arithmetic for a large batched-output offset and changes the calculation to 64 bits before multiplication. The notable failure mode is unwritten destination slices, even though the allocation itself can be large enough.

Capacity and address arithmetic differ

A system may allocate a buffer whose valid element range exceeds the range of an intermediate index expression. In that case, available memory does not rescue the calculation. The PR identifies the product used for the destination slice offset and explains that overflow can leave affected slices unwritten. This is an indexing defect, not evidence that the model or device ran out of storage capacity.

Promotion has to precede the product

Converting an already overflowed narrow result to a wider type preserves the wrong result. The release repair instead promotes the offset arithmetic before multiplication. That order is the core correctness property. A review should inspect the types of operands and intermediate expressions rather than only the type of the variable receiving the answer. The same reasoning is useful when auditing other large-tensor address calculations, without assuming they share this defect.

Detect slices that were never written

A proposed regression test initializes the destination to a recognizable sentinel before invoking the operation, then checks every relevant slice against a reference. Sampling a few early elements is insufficient when only later batch offsets cross the integer boundary. Preserve a smaller control case to show that a failure is linked to scale. The upstream PR includes its own reproduction; the test described here is guidance for independent qualification.

Do not turn a boundary fix into a throughput claim

Correctly writing the full output can alter observed timing, but speed is secondary to verifying that all requested work was performed. A faster pre-fix run that omitted slices would not be a valid performance baseline. Record output coverage with any timing comparison, and keep the build revision attached. The published change establishes a repaired integer-width boundary for this Metal operation, rather than a new general memory limit for llama.cpp.

Sources

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles