What Is This?
A gadget that generates photorealistic cat faces using a neural network running entirely on a RISC-V microcontroller. The twist is that every cat's existence is determined by quantum vacuum fluctuations measured at the Australian National University in Canberra. After generating your cat, the device flips a quantum coin to decide if it's feeling motivated or demotivated, and then speaks an absurd physics themed verdict through a speaker. So you'll hear phrases like:
"The quantum vacuum has wagered everything on your sheer audacity. And the math checks out."
Or:
"A tired photon lasted longer than your attention span. The math is brutal."
There's no WiFi or cloud or GPU. Just a microcontroller, an SD card, and the fundamental randomness of the universe.
The Hardware
The whole thing runs on a CH32H417, a dual-core RISC-V chip from WCH that costs around $3. It has two cores, a V3F at 150 MHz that handles I/O, and a V5F at 300 MHz with a hardware floating point unit that does the actual neural network math. Total SRAM is 512 KB shared plus 256 KB of tightly coupled memory on the fast core.
The rest of the BOM:
- ST7796S 480x320 LCD with FT6336U capacitive touch
- MicroSD card for weights, entropy, and audio clips
- PAM8403 amplifier and a small speaker
- Wires
The Neural Network
The model is a DCGAN (Deep Convolutional Generative Adversarial Network) trained on 5,153 cat faces from the AFHQ dataset. It has 12.6 million parameters across five transposed convolution layers and the generator takes a 100 element random noise vector and produces a 64x64 RGB cat face in a single forward pass. The weights are 48.3 MB in float32, but that's a problem when your chip has 512 KB of RAM.
So the solution of course is int8 per channel quantization which drops the weights to 12.1 MB, which lives on the SD card. The MCU streams them in through SPI, processes them in tiles that fit in SRAM, and uses both cores simultaneously. The V3F reads from the SD card while the V5F crunches numbers, one of the benefits of a dual core design. So what you get is double buffered weight streaming that overlaps I/O with compute.
The first version of this took 242 seconds and after six rounds of optimization (FPU offload, quantization, dequantization fusion, double buffering, tiled weight layout, DTCM intermediate storage), it's down to 26 seconds, a 9.3x improvement and this is reasonable for an edge generated installation.
The generated cats are recognizable, photorealistic, and occasionally cursed (lol). Exactly what you want!!
The Quantum Part
This is where it gets interesting, I could have just did GAN on RISC-V mcu and leave it there, but I wanted a fun application and cats and Schrodinger go hand in hand. So I wanted to incorporate some of this into the design. I wanted to have a variation of the though experiment realized, but I didn't want anything dead or alive, so to do this I decided I'd make the cat motivated or unmotivated instead of alive or dead.
To do this I made sure every cat is generated from a noise vector. Normally you'd seed that with a pseudorandom number generator, but a PRNG is deterministic and given the seed, every future output is predetermined.
That's boring.
So instead, the noise vector comes from quantum vacuum fluctuations measured at the ANU Quantum Optics Laboratory in Canberra, Australia. They split a laser beam and measure the power fluctuations in each arm using balanced homodyne detection. Those fluctuations come from virtual photon pairs spontaneously appearing and disappearing in the quantum vacuum, and the zero point energy of the electromagnetic field, therefore each measurement is fundamentally unpredictable. It's not just "hard to predict" but actually its physically impossible to predict. Bell's theorem and 40 years of experiments (including the work that won the 2022 Nobel Prize in Physics) confirm that no hidden variables...
Read more »
Armstrong Subero
ziggurat29
Stuart
Stephen Holdaway
Bitroller