Skip to main content

Module softcap

Module softcap 

Source
Expand description

Softcap (tanh-based logit capping) GPU dispatch.

Computes: tanh(logits / cap) * cap

This bounds output logits to the range (-cap, +cap). Gemma 4 uses cap = 30.0 for final logit capping.

Statics§

SOFTCAP_SHADER_SOURCE
MSL source for the softcap kernels (embedded at compile time).

Functions§

dispatch_softcap
Dispatch a softcap operation on the GPU.
register
Register softcap shader sources with the given kernel registry.