Skip to content

adamreidsmith/ember

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

EMBER

Overview

Ember is a quantum computing framework that provides tools for building, simulating, and analyzing quantum circuits. To facilitate efficient statevector computation, Ember additionally contains a comprehensive complex number SIMD vector implementation, efficient complex dense and sparse matrices, and numerical linear algebra processing tools.

This project serves as one of my passion projects for me to learn about the Mojo language.


Features

  • ๐Ÿค– Feature-Rich Quantum Circuits: Supporting arbitrary quantum gates, classical bit control, measurement, inversion, and merging.
  • ๐Ÿงช Comprehensive Quantum Gate Library: Utilize preconfigured quantum gates or configure custom gates for complex operations.
  • ๐Ÿงฎ Statevector Handling: Efficient quantum state representations and operations through sparse statevectors.
  • ๐Ÿง  Density Matrix Support: Accurate representation of mixed states with purity validation.
  • ๐Ÿš€ Statevector Simulation: Efficient, parallelizable statevector simulation for large-circuit simulation.
  • ๐Ÿ”ข Complex Number SIMD Vectors: A complex number type supporting vectorized SIMD operations.
  • ๐Ÿ“š Complex Matrix Support: Sparse and dense complex matrices supporting efficient numerical linear algebra.

Project Structure

โ””โ”€โ”€ ember/
    โ”œโ”€โ”€ LICENSE
    โ”œโ”€โ”€ README.md
    โ”œโ”€โ”€ ember
    โ”‚   โ”œโ”€โ”€ __init__.mojo
    โ”‚   โ”œโ”€โ”€ config.mojo
    โ”‚   โ”œโ”€โ”€ cplx
    โ”‚   โ”‚   โ”œโ”€โ”€ __init__.mojo
    โ”‚   โ”‚   โ”œโ”€โ”€ complexsimd.mojo
    โ”‚   โ”‚   โ”œโ”€โ”€ cmatrix.mojo
    โ”‚   โ”‚   โ”œโ”€โ”€ csrcmatrix.mojo
    โ”‚   โ”‚   โ”œโ”€โ”€ mmath.mojo
    โ”‚   โ”‚   โ””โ”€โ”€ qr.mojo
    โ”‚   โ”œโ”€โ”€ quantum
    โ”‚   โ”‚   โ”œโ”€โ”€ __init__.mojo
    โ”‚   โ”‚   โ”œโ”€โ”€ gate.mojo
    โ”‚   โ”‚   โ”œโ”€โ”€ quantumcircuit.mojo
    โ”‚   โ”‚   โ”œโ”€โ”€ statevector.mojo
    โ”‚   โ”‚   โ””โ”€โ”€ densitymatrix.mojo
    โ”‚   โ””โ”€โ”€ sim
    โ”‚       โ”œโ”€โ”€ __init__.mojo
    โ”‚       โ””โ”€โ”€ statevectorsimulator.mojo
    โ”œโ”€โ”€ examples
    โ”‚   โ”œโ”€โ”€ fourier.mojo
    โ”‚   โ”œโ”€โ”€ grover.mojo
    โ”‚   โ””โ”€โ”€ teleportation.mojo
    โ””โ”€โ”€ test

Getting Started

Prerequisites

This project requires the following dependencies:

  • Programming Language: Mojo 25.3.0

Installation

Install Mojo and clone the repository:

โฏ git clone https://github.com/adamreidsmith/ember

Usage

The following example implements quantum teleportation in Ember:

from ember import QuantumCircuit, Statevector, StatevectorSimulator
from ember import X, Z, H, CX, Measure

fn main() raises:
	# Create a quantum circuit with 3 qubits and 2 classical bits
	var qc = QuantumCircuit(3, 2)

	# Apply a Hadamard gate to qubit 0 to prepare the state to teleport (we will teleport the |+โŸฉ state)
	qc.apply(H(0))

	# Generate the entangled Bell state on qubits 1 and 2
	qc.apply(H(1), CX(1, 2))

	# Change the basis so we can perform a Bell measurement
	qc.apply(CX(0, 1), H(0))

	# Measure qubit 0 to classicao bit 0 and qubit 1 to classical bit 1
	qc.apply(Measure(0, 0), Measure(0, 1))

	# Create gates controlled on the classical bits containing the measurement outcomes
	var x: Gate = X(2)
	x.control(clbits=List[Int, True](1))
	var z: Gate = Z(2)
	z.control(clbits=List[Int, True](0))
	qc.apply(x, z)

	# Initialize a simulator and run the quantum circuit
	sim = StatevectorSimulator()
	sim.run(qc)
	var statevector = sim.get_statevector()

	# Trace out qubits 0 and 1 to obtain the state of the telported qubit
	statevector = statevector.partial_trace(0, 1)

	print('Teleported state:')
	print(statevector)

See examples for more detailed examples of quantum teleportation, Grover's algorithm, and the quantum Fourier transform.


License

Ember is protected under the MIT License. For more details, refer to the LICENSE file.


Sources

  • Jones, Tyson, Bรกlint Koczor, and Simon C. Benjamin. "Distributed Simulation of Statevectors and Density Matrices." arXiv.org, November 2, 2023. https://arxiv.org/abs/2311.01512.

About

A quantum computing platform implemented in Mojo ๐Ÿ”ฅ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages