QuBlox (v2.0) - Run Quantum Circuits Inside Roblox

QuBlox (v2.0)

What is this?

QuBlox is an open-source quantum computing simulator built for Roblox using Luau.

It provides state vector simulation, quantum gates, measurements, and even custom gates

Where can I download it?

You can download QuBlox at the github releases page: Releases · coolguy65161/QuBlox

API Documentation

The API documentation can be found here: Documentation

Example

This example creates a 5 qubit GHZ state.

More examples can be found in the /examples folder on the github repo: Repository

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local QuBlox = require(ReplicatedStorage.QuBlox)

local Circuit = QuBlox.Circuit(5, 5)

Circuit:h(1)
Circuit:cnot(1, 2)
Circuit:cnot(2, 3)
Circuit:cnot(3, 4)
Circuit:cnot(4, 5)

local results = Circuit:results(100000)

print(results)

Expected output:

00000 ≈ 50%
11111 ≈ 50%

Benchmarks

Old benchmarks (v1):

Example:

  • 7-qubit GHZ state
  • 500,000 measurements
  • ~3.5 seconds

Example:

  • 5-qubit GHZ state
  • 1,000 measurements
  • ~27.8 milliseconds

New benchmarks (v2.0):

Example:

  • 7-qubit GHZ state
  • 500,000 measurements
  • ~747 milliseconds

Example:

  • 5-qubit GHZ state
  • 1,000 measurements
  • ~1.1 milliseconds

Check changelog for newer information

Additional Information

QuBlox uses big endian display ordering.

Quantum noise simulation has not been implemented.

Not all gates have been fully tested.

Latest Release: QuBlox (v2.0) - Run Quantum Circuits Inside Roblox - #6 by coolguy65161

All minor versions will only be edited into this post, and all major versions will be a new reply in the forum. You can see those here:

Changelog
v1

QuBlox (v2.0) - Run Quantum Circuits Inside Roblox


v1.1 - rest of minor versions will be edited in

QuBlox (v2.0) - Run Quantum Circuits Inside Roblox - #5 by coolguy65161


v2.0-preview1

Release QuBlox v2.0-preview1 · coolguy65161/QuBlox

Changes

  • Direct state updates for single qubit gates

  • Removed QuBlox:GetTensorMatrix()

  • Renamed QuBlox:GetTensorOperations() to QuBlox:GetSingleOperations()

  • Added QuBlox:UpdateSingularState()

Additional information

Multi-qubit gates do not work in this version


v2.0-preview2

Release QuBlox v2.0-preview2 · coolguy65161/QuBlox

Changes

  • Removed QuBlox:GetMultiOperations()

  • Removed QuBlox:GetSingleOperations()

  • Removed findMultiGates()

  • Removed findSingleGates()

  • Removed removeDuplicateGates()

  • Removed QuBlox:GetCircuitMatrix

  • Removed QuBlox:GetTensorMatrix

  • Removed QuBlox:GetMultiMatrix

  • Added QuBlox:applyMultiQubit()

  • Added getIndex()

  • Added a general support algorithm for direct amplitude modification

  • Refactored QuBlox:UpdateStateVector()

Benchmarks:

7 qubit GHZ state

  • 500k shots
  • ~0.89s

New bottleneck:

State modification, updating the state vector now takes 1.3ms for the
7 qubit GHZ state. Results comes up with 0.89s of time.

Additional information

Can now support 15+ qubits


v2.0

QuBlox (v2.0) - Run Quantum Circuits Inside Roblox - #6 by coolguy65161

2 Likes

The 8 qubit limit seems pretty low for a simulator. Is that bottleneck coming from Luau performance or just how you’re managing the state vector memory?

1 Like

The 8 qubit limit is due to the way my simulator is currently running. It expands every gate, the solution for that is too directly modify amplitudes which will likely come in later versions. I think state vector memory usually becomes a problem later when its 20+ qubits. To be broader the current bottleneck is currently computation

That makes sense. Expanding the whole state vector for every gate is definitely going to hit a wall fast. Direct amplitude modification would be much more efficient.

1 Like

QuBlox v1.1

Changes

  • Updated Statevector creation
  • Replaced Circuit.qubits with empty table objects for now
  • Limit is now 9 qubits due to matrix multiplication optimizations
  • Removed Conjugate Transpose
  • Matrix multiplication and gate expansion are soon to be obsolete
  • Vector.Qubit(0 or 1) now returns {}

New Benchmarks

Example:

  • 7-qubit GHZ state
  • 500,000 measurements
  • ~1.5 seconds

Example:

  • 5-qubit GHZ state
  • 1,000 measurements
  • ~24.6 milliseconds

Additional Information

Roblox took down the original QuBlox v1.0, and other reuploads. For now you will have to download directly from the release page at Release QuBlox v1.1 · coolguy65161/QuBlox

QuBlox v2.0

Changes

  • Optimized Statevector Calculations
  • Added direct amplitude modification
  • Added customizable throttling to prevent script exhaustion and frame drops
  • Raised qubit limit to >20 qubits
  • For qubit amounts under 15, 5000+ gates can be done under a minute

Benchmarks

Example:

  • 7-qubit GHZ state
  • 500,000 measurements
  • ~747 milliseconds

Example:

  • 5-qubit GHZ state
  • 1,000 measurements
  • ~1.1 milliseconds

Example:

  • 26-qubit GHZ state (max possible qubits for Roblox)
  • 1,000 measurements
  • ~102 seconds

Download:
Release QuBlox v2.0