Sampling Is Computing: The Language-Model Decoder Is a P-Bit, and Any QUBO Compiles into It
Every language model contains a probabilistic computer: the softmax sampler that picks its next token is, exactly, the update rule of a probabilistic bit (p-bit). We give, to our knowledge, the first compiler that turns any quadratic unconstrained binary optimization (QUBO) energy into ordinary transformer weights, so that standard decoding, with no training, runs exact block Gibbs sampling. Earlier compiled transformers are deterministic, and earlier language-model Gibbs samplers use learned conditionals with no known joint law. Each token sets k variables from their exact joint conditional, and the sampling temperature is the Gibbs temperature. We prove that decoding reproduces the Gibbs transition kernel exactly (the decoder–Gibbs equivalence), that floating-point evaluation is exact for integer QUBOs under stated bounds, and that otherwise the token process stays within a computable total-variation distance of the exact chain. A second, programmable transformer reads any integer QUBO with up to 40 variables from its prompt. A counting bound shows the weight count is optimal for dense problems up to constant factors at fixed precision, and a higher-order extension samples any strictly positive distribution on binary variables, at exponential cost in general. Experiments check the exactness token by token. The compiled decoder reaches the best-known cuts of the 800-node Gset graphs G1 and G6, stays exact in Hugging Face generate() and on a GPU, and, given QUBOs from a language-model repair, chooses the same weight edits as a direct sampler. Any transformer runtime can run a provably correct stochastic algorithm with the sampler it already has.
Authors
- Soufiane Chehraoui (ORCID: https://orcid.org/0009-0008-1958-1155)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-11-30
- DOI
- https://doi.org/10.5281/zenodo.24673363
- Primary Topic
- Quantum Computing Algorithms and Architecture
- Type
- preprint