The llama.cpp project released version b10242, introducing a new backend sampler for penalties that allows penalty handling to be offloaded to the GPU. This change enhances the `common_sampler_init` function and updates the `llama_sampler_penalties` structure to inherit from `llama_sampler_backend`, enabling frequency and presence adjustments on the backend.

  • The implementation includes logic for backend initialization, application of penalties, and support for top-k penalties in backend sampling.
  • Numerical stability is improved by preserving masked logits as -Inf to prevent NaN generation during sampling.
  • Validation ensures repeat penalty values are finite and greater than 0, with tests added for invalid parameters.
  • The release provides binaries for macOS (Apple Silicon and Intel), Linux (CPU, Vulkan, ROCm, OpenVINO, SYCL), Android, Windows (CPU, CUDA 12/13, Vulkan, OpenCL, HIP, OpenVINO, SYCL), and openEuler architectures.