I used the Raspberry Pi Pico (RP2040) on hand to challenge implementing Transformer, the core of modern AI.
1. Why Transformer on RP2040 now?
- Background: Using surplus RP2040s (Picos) to explore how much AI inference is possible in extreme environments.
- Objective: To gain experience in implementing matrix operations and inference at the edge for future development of "semiconductor quantum control" and "AI accelerators," rather than just as a hobby.
Personally, I plan to focus mainly on FPGAs (hardware description) going forward, so this time, as a preliminary trial, I ran it in the CircuitPython environment based on the ThomasVuNguyen/Starmind-Pico repository.
2. Implementation Record (Achievements This Time)
- Device Used: Raspberry Pi Pico (RP2040) / CircuitPython environment
- Model:
tiny-transformers-rp2040(8.7K Params) - Result: Successfully achieved inference at 2.5 tokens/sec.
- Discussion: Observed behaviors of "immature intelligence" due to insufficient vocabulary, such as
he<unk><unk>. Within the extremely limited SRAM of 256KB, I was able to experience the reality of how the Transformer's Attention mechanism is computed.
3. Future Outlook: Tensor Networks and Quantum Control
This experiment serves as a prototype toward larger goals.
- Importance of Tensor Networks: I am focusing on tensor networks as a common mathematical foundation for both simulating quantum many-body systems and compressing neural networks (low-rank approximation).
- Application to Quantum Systems: In controlling elements like quantum dots that require low-latency and high-precision control, fast inference/computation at the edge is an indispensable element.
- Motivation for Chip Development: Based on insights gained from this software implementation, I will proceed toward implementing "tensor operators" on FPGAs (such as Tang Nano) and custom chips.
Conclusion
- From "1-bit weights" to "qubits" The "quantization" performed this time involves reducing information while preserving the essence. This is deeply connected to the challenge of how to efficiently control and describe noise-sensitive quantum states.
- From RP2040 to FPGA (Tang Nano), and then to ASIC By understanding the limits of sequential processing on the RP2040 (Cortex-M0+), the necessity of "parallel computation" via FPGA has become clearer. This provided valuable comparative experience when burning tensor networks into hardware.