Skip to main content

Scientific Toolkit for Quantum Computing

Project description

skq

Python Version uv Ruff

Scientific Toolkit for Quantum Computing

This library is used in the q4p (Quantum Computing for Programmers) course.

NOTE: This library is developed for educational purposes. While we strive for correctness of everything, the code is provided as is and not guaranteed to be bug-free. For sensitive applications make sure you check computations.

Why SKQ?

  • Exploration: Play with fundamental quantum building blocks using NumPy.
  • Education: Learn quantum computing concepts and algorithms.
  • Integration: Combine classical components with quantum components.
  • Democratize quantum for Python programmers and data scientists: Develop quantum algorithms in your favorite environment and easily export to your favorite quantum computing platform for running on real quantum hardware.

Install

pip install -U skq

Quickstart

Circuit Conversion

Run this code snippet to initialize a Bell State and convert to Qiskit and OpenQASM.

from skq.circuits.entangled_states import BellStates

# Initialize Bell State skq Circuit
circuit = BellStates().get_bell_state(1)

# Conversion to Qiskit
qiskit_circuit = circuit.convert(framework="qiskit")
qiskit_circuit.draw()
#      ┌───┐     
# q_0: ┤ H ├──■──
#      ├───┤┌─┴─┐
# q_1: ┤ I ├┤ X ├
#      └───┘└───┘

# Conversion to OpenQASM
qasm_circuit = circuit.convert(framework="qasm")
print(qasm_circuit)
# h q[0];
# id q[1];
# cx q[0], q[1];

Circuits from scratch

You can also build your own custom circuits from scratch using individual gates.

from skq.gates import H, I, CX
from skq.circuits import Concat, Circuit

H() # Hadamard gate (NumPy array)
# H([[ 0.70710678+0.j,  0.70710678+0.j],
#    [ 0.70710678+0.j, -0.70710678+0.j]])

I() # Identity gate (NumPy array)
# I([[1.+0.j, 0.+0.j],
#    [0.+0.j, 1.+0.j]])

CX() # CNOT gate (NumPy array)
# CX([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
#     [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
#     [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
#     [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j]])

# Initialize Bell State skq Circuit
circuit = Circuit([Concat([H(), I()]), CX()])

# Simulate circuit classically
state = np.array([1, 0, 0, 0]) # |00> state
circuit(state)
# array([0.70710678+0.j, 0, 0, 0.70710678+0.j])

# Conversion to Qiskit
qiskit_circuit = circuit.convert(framework="qiskit")
qiskit_circuit.draw()
#      ┌───┐     
# q_0: ┤ H ├──■──
#      ├───┤┌─┴─┐
# q_1: ┤ I ├┤ X ├
#      └───┘└───┘

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skq-0.3.2.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skq-0.3.2-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file skq-0.3.2.tar.gz.

File metadata

  • Download URL: skq-0.3.2.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for skq-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e41cc2daee01aa1a77f5e4f46a87fec485e5beeeeb0c61ee3a3c067623f8de9d
MD5 33bf8be7733ecb0b310e71f6fce8ff26
BLAKE2b-256 4b81542fbaa9dfc19f7a83775e58d57b9e48d7456f396f0e3d7ad1962eed35a7

See more details on using hashes here.

File details

Details for the file skq-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: skq-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 37.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for skq-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f27997242bf4995dcf9ea4585a7adc5b82d7f49b2cda44c0e07681e24b3999dc
MD5 6be6f6f33061df6d04328cb6ff1b0ec0
BLAKE2b-256 1161b5ccf542266003010685c3280ac4e7ec3c3666cc15a953a9fc53e6cfcf57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page