Skip to main content

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

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. 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.

Release files for Kala-Qubits 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Kala-Qubits 0.1.0
File Size Uploaded
kala_qubits-0.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Kala-Qubits 0.1.0
File Interpreter ABI Platform
Kala_Qubits-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.5 kB

Release files / kala_qubits-0.1.0.tar.gz

Download URL kala_qubits-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cd307a69d5724f8e90571ed82846ad920836cba1cb1bfc45f57cad6fa6ea08c4
BLAKE2b-256 checksum
How to use checksums
fba7acd70c8726d1c0ca24215e4d54ea6c1905ae5558b17a35d98bcd6f297855
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / Kala_Qubits-0.1.0-py3-none-any.whl

Download URL Kala_Qubits-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fbf51accf586e376a0f0f72656a527b4e97e72cb8fba4165a8ff3a5476a15fb
BLAKE2b-256 checksum
How to use checksums
29295e1ad8742bc860d684c76aff1fd09ed9c529ddd5ecdb9bb5660cbf5dbb0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page