TECHNOLOGY

llama.cpp CUDA MoE fixup: unchanged answers can hide an out-of-bounds read

In this article
THE QUICK TAKE

The b12316 CUDA fix skips empty MoE fixup tiles before unsafe reads; sanitizer evidence matters even when output values already match.

llama.cpp b12316 fixes an empty-tile read in the CUDA MMQ stream-k fixup path. The upstream analysis explicitly distinguishes the read overrun from output correctness: the empty tile returned without storing a result. This makes numerical equality an insufficient regression criterion for this particular defect.

Empty tiles are real scheduled work

The PR explains that helper logic can emit an extra tile per expert, including trailing experts assigned no rows. The main multiplication kernel already returned early for an empty range, but its fixup counterpart attempted an index read first. A tile having no useful output therefore did not mean that the implementation performed no memory accesses. That distinction is the central bug, rather than a change to expert-routing probabilities.

The return must precede the access

The correction checks the empty upper bound before the problematic reads. Upstream notes that the condition is uniform across the block and occurs before block synchronization. This matters because a safe memory fix must also preserve the synchronization contract. Moving an early return into parallel code without considering which threads take it can create a separate defect, even when the original out-of-bounds expression disappears.

Use routing that leaves trailing experts unused

A focused regression needs experts with zero assigned rows and shapes that actually launch the stream-k fixup. An evenly populated expert set can miss the issue entirely. The PR adds such a backend test, giving a more precise reproduction than a generic MoE prompt. For independent verification, preserve the route pattern and run a suitable memory checker as well as comparing numerical output against a reference.

Safety evidence has its own value

The upstream statement that results were unaffected does not make the invalid read acceptable, nor does it establish that all possible environments react identically. Conversely, this patch is not a demonstrated model-quality improvement. A good release assessment records both facts: the intended output comparison may already pass, while the memory-access check fails before the correction and passes afterward. No new device measurements are claimed in this article.

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