A lightweight quantum circuit simulator with PyTorch backend
Project description
Qubits
Overview
The Qubits is a Python-based library for simulating quantum circuits. It leverages PyTorch to efficiently represent and manipulate quantum states and gates. This library is designed for developers and researchers who want to prototype and experiment with quantum algorithms without needing access to actual quantum hardware.
Features
- Quantum Gates: Includes common gates like Pauli-X, Pauli-Y, Pauli-Z, Hadamard, CNOT, and parameterized rotation gates (Rx, Ry, Rz).
- Quantum and Classical Registers: Simulate quantum states and classical measurement storage.
- Gate Application: Apply single- and multi-qubit gates on quantum circuits.
- Measurement: Measure qubits and collapse the quantum state.
- Lightweight: Minimal dependencies with a PyTorch backend.
Installation
You can install the library using pip after cloning the repository:
pip install Kala_Qubits
Usage
Import the Library
from Qubits import Gate, QuantumCircuit
Create a Quantum Circuit
# Create a 2-qubit circuit with 2 classical bits
qc = QuantumCircuit(2, 2)
# Add gates
qc.apply(Gate.hadamard(), [0]) # Apply Hadamard to qubit 0
qc.apply(Gate.cnot(), [0, 1]) # Apply CNOT with qubit 0 as control and qubit 1 as target
# Execute the circuit
qc.execute()
# Measure all qubits
result = qc.measure_all()
print(f"Measurement outcome: {result}")
Add Custom Gates
import numpy as np
# Define a custom gate matrix
custom_matrix = np.array([[1, 0], [0, -1]])
custom_gate = Gate.custom(custom_matrix)
# Apply the custom gate
qc.apply(custom_gate, [0])
API Reference
Gate
Methods
Gate.pauli_x()Gate.pauli_y()Gate.pauli_z()Gate.hadamard()Gate.cnot()Gate.rotation_x(theta)Gate.rotation_y(theta)Gate.rotation_z(theta)Gate.custom(matrix)
QuantumCircuit
Methods
apply(gate, qubits)measure(qubit, cbit)measure_all()execute()
QuantumRegister and ClassicalRegister
Used internally to manage quantum states and classical bits.
Contributing
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a detailed explanation of your changes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- Inspired by Qiskit and PyTorch.
- Designed for educational and research purposes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kala_qubits-0.1.0.tar.gz.
File metadata
- Download URL: kala_qubits-0.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd307a69d5724f8e90571ed82846ad920836cba1cb1bfc45f57cad6fa6ea08c4
|
|
| MD5 |
ce39a23727e4d2e13553f2f4a4002d7c
|
|
| BLAKE2b-256 |
fba7acd70c8726d1c0ca24215e4d54ea6c1905ae5558b17a35d98bcd6f297855
|
File details
Details for the file Kala_Qubits-0.1.0-py3-none-any.whl.
File metadata
- Download URL: Kala_Qubits-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fbf51accf586e376a0f0f72656a527b4e97e72cb8fba4165a8ff3a5476a15fb
|
|
| MD5 |
d2eaca446bbba8640fc7332c748b7c5d
|
|
| BLAKE2b-256 |
29295e1ad8742bc860d684c76aff1fd09ed9c529ddd5ecdb9bb5660cbf5dbb0c
|