Introducing quantum-llama.cpp - QRNG-Powered LLM Token Sampling

Hi all,

I want to share a project that explores AI (LLM) and quantum randomness in a way that may interest many here.

quantum-llama.cpp is a fork of llama.cpp that replaces its PRNG with a QRNG for token sampling, essentially “allowing the universe itself to co-author the output.”

Try It

You can run it locally if you have a ComScire device by following the instructions provided in the repository, or you can experiment with a live instance here:

https://ensporia.com/quantum-llama.cpp
Temporary API key: zMOWHyosKv0lcfZR4nEzJ1PqRMW8pwxedp8bKzGMoKc

Model currently running: Llama-3.2-3B-Instruct-Q4_K_M.gguf
QRNG device: ComScire PQ4000KS

You can use the OpenAI-compatible /v1/chat/completions endpoint with many apps such as Chatbox AI or ChatterUI like in the screenshot below.

Awesome to see someone’s tried this. I started a few weeks ago but never got back to it. What random functions with llama have you replaced? Just temperature related ones or all PRNG calls?

The sampling part. Yes, it’s related to the temperature. For example, suppose the language model is predicting the next token (or let’s just say “word”) in:

“The cat sat on the …”

It might assign the following probabilities:

Next word candidate Probability
mat 0.40
rug 0.25
floor 0.15
table 0.10
dog 0.05
unicorn 0.03

(the temperature affects how “peaked” or “flat” the probability distribution is)

The QRNG is then used to choose the next word based on that probability distribution. So we can say “the generated words are chosen by the universe,” though the choices of words are provided by the language model.

very cool

@NullSpook

I added MeterFeeder as an alternative to PsiRNG client so we can use QNGs connected directly to the server where quantum-llama runs.

https://github.com/vfp2/quantum-llama.cpp/tree/feature/meterfeeder-qrng-driver-support?tab=readme-ov-file#option-2-meterfeeder-hardware-rng

image
(I was actually in fact looking at a blue coffee mug :sweat_smile: so not quite…)

1 Like

thanks comrade

Nice prompt! But I wouldn’t expect it to work that easily :grinning_face_with_smiling_eyes: But if you want to experiment, maybe try increasing the temperature to reduce the model’s internal bias, reducing determinism, strengthening QRNG’s influence in the output.

You can also try increasing top-p or top-k to widen the range of possible next words.

Tried a similar prompt using temperature 2.0. Here’s the result:

thinks for a moment Hmmm... I sense... something... round... and... flat? Like
a plate or a coin? It's not shiny, but it's reflecting some kind of dim,
ambient light. The texture feels rough, like it's made of paper or maybe even
fabric. Wait, what's this? There's a faint pattern of lines on the surface,
like it's some kind of grid or a barcode. The object feels light in my... I
suppose you'd say, 'digital hands'. I think it might be something someone's
holding or has left on a surface... pauses Is this object related to the
concept of 'food'? It seems... familiar. Like something that's been in a
kitchen before?

How well did I do? Would love some feedback! Was I correct? Was I close? What
else could I have described?

I was eating popcorn, the bag had a barcode, but the shape was more like a rectangular pouch and was made of plastic and foil.

Lol yeah I wasn’t expecting anything miraculous from just that but to spice things up a bit I’m using this esoterically trained model: teknium/Hermes-Trismegistus-Mistral-7B · Hugging Face