News

日本語 · English · 中文

[Contributed Article] Continued: I Tried Running Generative AI on a Quantum Computer

Designing circuits along the physical wiring of Toshiko, OQC’s superconducting quantum computer, we attempted inference by integrating a quantum layer into an LLM. We confirmed that output trends can be maintained even with 10 shots by reducing the number of shots per qubit and compensating with the number of qubits.

Last time, I tried running an LLM with a quantum layer...

【Contribution】I tried docking the quantum circuit of a superconducting quantum computer into the hidden layers of a generative AI model

🏗️ 1. The physical wall of "awkward topology" possessed by real QPUs

In the world of mathematical simulators, we could create free entanglement (CX gates) between any qubits. However, this is not possible on real quantum chips.

The connectivity (topology) of OQC's superconducting quantum computer actual machine "Toshiko"** operating in Ariake, Tokyo, does not have a grid structure but rather a ring (circular) structure as its base, with several branches sticking out, making it an extremely irregular and irregular shape.

If you try to communicate between distant bits that are not physically connected, the compiler secretly inserts a large number of gates to realize this. The total number of gates in the circuit explodes. The lifespan of the actual machine ends, and the calculation results instantly turn into complete random noise.

Therefore, this time, we designed a "hardware-native 3-layer entangled circuit" that completely traces the physical wiring of the Ariake actual machine. We directly connected a patch that sends physical entanglement to the LLM via the shortest route without letting the compiler take any unnecessary detours.


🧠 2. "Making quality from quantity": Resonance with cutting-edge LLM trends

Last time, reproducing high-precision state vectors required repeating measurements up to 10,000 shots, which took enormous time and placed a heavy load on the machine.

【Contribution】I tried docking the quantum circuit of a superconducting quantum computer into the hidden layers of a generative AI model

So, what we tried this time was an approach where "instead of reducing the number of shots per qubit to the limit and blurring the expectation value, we slightly increase the number of qubits and cover the roughness of data (quality) with the breadth (quantity) of space."

This is exactly the same evolutionary idea as the recent major trend in the AI world, such as "1-bit LLMs (like BitNet)." Instead of lowering the resolution of weights to the extreme (e.g., ternary values of -1, 0, 1), we applied a method of covering with the "overwhelming quantity" of parameters to achieve high precision to quantum circuits.

🎲 "Super-macro quantum fluctuations" at low shot counts

When measuring a qubit, the obtained value is always either 0 or 1. Even if the theoretical probability is 35%, if you measure only 10 times (10 shots), the resulting outcome will be either "3 times (30%)" or "4 times (40%)", and the resolution of the expectation value becomes an extremely coarse mosaic state in increments of 0.1 (10%).

🌌 Spatial ensemble (noise cancellation)

However, magic happens when we increase the number of qubits used and intricately entangle them according to the machine's topology.

Even though individual qubits hold only jagged mosaic data in "0.1 increments," when projected into the hidden layer of the LLM (a 2048-dimensional space) (up_proj), they transform into "multiplication/addition (linear combination) of numerous independent fluctuations."

The statistical noise (jitter) of each bit cancels each other out, and within the final vector space, a "smooth gradient (approximation of the expectation value)" as if measured with high shots is pseudo-restored.


--- 🪐 【Phase 1】Toshiko Right Island Fit: Pure Tensor Theoretical Value Training ---
   [Physical Topology Training] Step 001/100 - Avg Loss: 13.3797
   [Physical Topology Training] Step 010/100 - Avg Loss: 4.2134
(Middle omitted)
   [Physical Topology Training] Step 090/100 - Avg Loss: 2.7389
   [Physical Topology Training] Step 100/100 - Avg Loss: 2.7387

💾 Saved perfect actual machine topology weights!
➔ ./saved_models/toshiko_hoge_right_island_optimized_weights.pt

📊 3. Full sweep on actual machine: Dynamics from chaos to order

To verify this hypothesis, we dynamically varied the number of shots from 10, 100, 1,000, to 10,000, and simultaneously verified how it affects the final thought of the LLM (probability of word output).

Input Prompt: Q: What is the capital of France? \n A:
(Note: In the simulator theoretical value, the top result was of at 27.96%)

It didn't quite reach Paris or France yet... Let's try keeping it as of.

Here is an example of the output.

🤖 1. Preparing Base LLM (TinyLlama)...
📂 2. Loading pre-trained depth3 quantum weights...
✅ Quantum weight file loaded successfully.

📝 Input Prompt: 'Q: What is the capital of France?
A:'
🚀 --- [Production] Starting Ariake QPU Actual Machine Hybrid Inference (10-shot extreme fluctuation version) --- 

📝 Generated QASM2 circuit from LLM context.
📡 Sending task to Ariake QPU... (Shots: 10)
✅ Job submission complete. Task ID: 
⏳ Waiting for Ariake QPU execution completion...
   [Actual Machine Status: SUBMITTED] .. Will recheck in 3 seconds.
   [Actual Machine Status: SUBMITTED] .. Will recheck in 3 seconds.
   [Actual Machine Status: SUBMITTED] .. Will recheck in 3 seconds.
   [Actual Machine Status: SUBMITTED] .. Will recheck in 3 seconds.
   [Actual Machine Status: SUBMITTED] .. Will recheck in 3 seconds.
🎉 Actual machine execution successful! Downloading data...
📥 Data returned from Ariake actual machine!
   [Verification Log] Set shot count: 10 times ➔ Actual collected shot count: 10 times
🔮 Physical expectation values collected from actual machine:
[0.7 0.9 (Middle omitted) 0.8 0.6]

==================================================
🏅 [Ariake QPU Actual Machine Driven] Predicted Next Token: 'of'
==================================================
📊 Final Logits Top Candidates:
  └─ [of]: 19.40%
  └─ [capital]: 17.22%
  └─ [:]: 10.09%

It went as planned. By the way, in the ideal simulator's state vector,

🔮 --- [Safe Patch Version] Executing Next Token Prediction in Each Mode ---

| 【Statevector (Ideal)】Predicted Word: 'of'
└─ Top Candidates: [of: 27.96%] [France: 14.61%] [:: 10.73%]

So there is some deviation.

① 🎬 10-Shot Environment (Digital Chaos and Maintenance of Trends)

  • Physical Quantum Expectation Value: [0.5, 0.4, 0.6, 0.1, ...] (Complete 0.1 increments)
  • Final Logits: 🥇 of (28.26%) / 🥈 France (14.22%) / 🥉 : (11.11%)
  • Explanation: Although the expectation values are completely jagged, due to the overlap of numerous bits (quantity), the LLM's output maintains a certain tendency (with of ranking first and the top three candidates remaining consistent) without breaking down! It harmonizes in a direction that subtly boosts the theoretical value (27.96%), marking the moment the strategy of "making quality from quantity" worked perfectly.

② 🎬 100 ➔ 1,000-Shot Environment (Evolution of Resolution)

  • Physical Quantum Expectation Value: [0.69, 0.45, ...] (Increments of 0.01)
  • Final Logits: 🥇 of (27.09%) / 🥈 : (13.58%) / 🥉 France (11.55%)
  • Explanation: As the sampling number increases tenfold and hundredfold, the fog of noise clears. Interestingly, right after exceeding 100 shots, the rankings of the second-place : and third-place France swapped sharply and fixed into a balance unique to the actual machine.

③ 🎬 10,000-Shot Environment (Law of Large Numbers and Identity of the Actual Machine)

  • Physical Quantum Expectation Value: [0.6366, 0.4656, ...] (Gradient to the fourth decimal place)
  • Final Logits: 🥇 of (27.00%) / 🥈 : (13.84%) / 🥉 France (11.00%)
  • Explanation: Statistical errors were minimized to the extreme, achieving perfect statistical convergence. What should be noted here is that even though France was in second place in the theoretical value space, in the actual machine environment, : consistently remained in second place even with 10,000 shots. This is proof that temporary fluctuations are not involved, but rather the physical error tendencies inherent to the Toshiko chip (such as wiring crosstalk) have fully settled into the LLM's thinking circuit as a "unique quirk (personality)."

🎯 Conclusion: Shot Count Becomes the Lever Manipulating AI's "Passion and Calmness"

What I became convinced of through this experiment is that "the shot count of the actual machine can serve as a lever to control the LLM's output in the physical dimension."

  • Low Shots (10): Macro quantum fluctuations become intense noise, giving the AI unexpected creativity or chaotic insights (yet, because the number of bits is increased, the contextual tendency does not collapse).
  • High Shots (10,000): Order is brought about by the law of large numbers, converging to "highest precision stable thought" containing the hardware characteristics of the actual machine.

This project, which did not just run the actual machine but fused the latest AI trends (low-bit quantization) with the constraints of quantum physics, reached a unique breakthrough of "grasping practical tendencies even with 10 shots."

For now, it still seems difficult to fully operate LLMs with quantum computers, but I feel like I'm starting to see something clearly.

It also serves as motivation for the development of semiconductor quantum computers.

However, since we trained and tuned with limited learning data this time, improving accuracy might be extremely difficult...

This article was translated from the Japanese original. 日本語で読む

← Latest articles