﻿# llama.cpp OpenCL F16 SWIGLU_OAI: dtype support includes dispatch and writes

OpenCL F16 SWIGLU_OAI in b12389 repairs dispatch and writes; validation should cover the destination buffer as well as returned values.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-engine-opencl-f16-swiglu-dispatch/
Language: en

llama.cpp b12389 includes an OpenCL correction for F16 SWIGLU_OAI. The associated commits identify both kernel dispatch and out-of-bounds writes. This is a useful example of why accepting an F16 tensor at the interface is only the beginning of implementing an operator for that type.

## A type claim has several layers

Upstream describes the previous implementation as not handling F16 correctly. There are separate questions behind that short statement: whether the backend admits the operation, whether it selects the right implementation, and whether that implementation writes within the storage allocated for its output. A type label attached to a graph node answers none of those questions by itself. The merged fix is evidence about this particular operator, rather than a general change to every half-precision path.

## Use an operator-level reference

For qualification, construct small F16 inputs whose expected activation result can be computed independently, including negative, zero and positive values. Compare outputs with a reference using tolerances justified by the datatype. An end-to-end language answer is a weak numerical oracle: a plausible sentence may survive intermediate errors. A focused test also makes it easier to distinguish wrong arithmetic from an incorrect output address or an inappropriate launch configuration.

## Output ownership belongs in the test

A proposed regression test should place detectable guard storage around the output where the backend test machinery permits it. Checking only the intended elements can miss damage to adjacent allocations. Run several shape boundaries rather than multiplying one convenient shape indefinitely. A destination overrun is especially deceptive when allocator reuse determines which neighbouring tensor is damaged, because the visible symptom may move to a later operation.

## Release evidence is narrower than deployment evidence

The dated prerelease and PR establish that a repair was published and merged. They do not show that a particular packaged application contains that code, or that its chosen device executes this OpenCL path. Preserve the binary version and backend selection with any before-and-after result. A successful F32 comparison remains useful as a reference, but it cannot stand in for exercising the newly corrected F16 dispatch. Preserve the output allocation size in bytes as well as its element count. A type-dependent store can have the correct logical index while using the wrong storage width, so reviewing only the launch dimensions would leave another essential F16 condition unexamined.

## Sources

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

## Related reading

- [Building llama.cpp on Windows with the right backend](/journal/llama-cpp-windows-build/)
- [CUDA half2: lane meaning, aligned storage, and an odd-length tail](/journal/fg2-cuda-half2-lanes-alignment-odd-tail/)
