Skip to content
Startseite/HLQuantum
✨ Empfohlener Ansatz — Einmal schreiben, überall ausführen

HLQuantum — High-Level-Quantenabstraktion

Eine Python-Bibliothek, die die Komplexität von Quantenhardware abstrahiert. Schreibe deine Schaltung einmal mit HLQuantum und führe sie auf IBM Qiskit, Google Cirq, Amazon Braket, PennyLane, NVIDIA CUDA-Q oder IonQ aus — ohne eine einzige Codezeile zu ändern.

Open Source6 BackendsEchte QPUGPU-Unterstützung

Warum HLQuantum verwenden?

🔁

Einmal schreiben, überall ausführen

Derselbe Schaltungscode läuft auf jedem der 6 unterstützten Backends — keine Übersetzung, kein Neuschreiben.

GPU-Beschleunigung integriert

Leite Schaltungen transparent an NVIDIA-GPU-Simulatoren weiter, um bei großen Schaltungen enorme Geschwindigkeitsvorteile zu erzielen.

🛡️

Fehlerminderung

ZNE, Auslese-Fehlerminderung und weitere Techniken sind integriert — mit einem einzigen Argument anwendbar.

🧠

Integrierte Algorithmen

QFT, Grover, VQE, QAOA, Bernstein-Vazirani — sofort einsatzbereit und backend-unabhängig.

🔀

Asynchrone Multi-Backend-Ausführung

Führe Experimente gleichzeitig auf mehreren Backends aus, um zu benchmarken und zu verifizieren.

🤖

KI-/MCP-Integration

Die Unterstützung des Model Context Protocol ermöglicht es KI-Agenten, Quantenexperimente zu orchestrieren.

Unterstützte Backends

BackendFrameworkInstallationEchte QPU
qiskitIBM Qiskitpip install hlquantum[qiskit]Ja
cirqGoogle Cirqpip install hlquantum[cirq]Nur Simulation
pennylaneXanadu PennyLanepip install hlquantum[pennylane]Nur Simulation
braketAmazon Braketpip install hlquantum[braket]Ja
cudaqNVIDIA CUDA-Qpip install hlquantum[cudaq]Nur Simulation
ionqIonQ (via Qiskit)pip install hlquantum[ionq]Ja

Schnellstart

1. Installieren

terminal
# Install with your preferred backend
pip install hlquantum[qiskit]     # IBM Qiskit backend
pip install hlquantum[cirq]       # Google Cirq backend
pip install hlquantum[pennylane]  # PennyLane backend
pip install hlquantum[braket]     # Amazon Braket backend
pip install hlquantum[cudaq]      # NVIDIA CUDA-Q backend
pip install hlquantum[ionq]       # IonQ backend

# Or install multiple at once
pip install "hlquantum[qiskit,cirq,cudaq]"

2. Erstelle deine erste Schaltung

hello_quantum.py
import hlquantum as hlq

# Create a 2-qubit circuit
qc = hlq.Circuit(2)

# Apply gates using the fluent API
qc.h(0).cx(0, 1).measure_all()

# Run on the default backend (auto-detects installed SDK)
result = hlq.run(qc, shots=1000)
print(result)
# {'00': 507, '11': 493}

3. Wechsle das Backend mit einem einzigen Flag

switch_backends.py
import hlquantum as hlq

qc = hlq.Circuit(2)
qc.h(0).cx(0, 1).measure_all()

# The SAME circuit, on DIFFERENT backends — zero code changes
r1 = hlq.run(qc, shots=1000, backend="qiskit")   # Qiskit Aer
r2 = hlq.run(qc, shots=1000, backend="cirq")      # Google Cirq
r3 = hlq.run(qc, shots=1000, backend="pennylane") # PennyLane
r4 = hlq.run(qc, shots=1000, backend="cudaq")     # NVIDIA GPU
r5 = hlq.run(qc, shots=1000, backend="braket")    # Amazon Braket
r6 = hlq.run(qc, shots=1000, backend="ionq")      # IonQ

for name, result in zip(["Qiskit","Cirq","PennyLane","CUDA-Q","Braket","IonQ"],
                         [r1, r2, r3, r4, r5, r6]):
    print(f"{name}: {result}")

Der @kernel-Dekorator

Der @hlq.kernel-Dekorator ermöglicht es dir, Quantenlogik als gewöhnliche Python-Funktionen zu schreiben. HLQuantum kompiliert und führt sie automatisch auf dem ausgewählten Backend aus.

kernel_example.py
import hlquantum as hlq

@hlq.kernel
def ghz_state(n: int):
    """Create an n-qubit GHZ state."""
    qubits = hlq.qvector(n)
    hlq.h(qubits[0])
    for i in range(n - 1):
        hlq.cx(qubits[i], qubits[i + 1])
    hlq.measure_all(qubits)

# Run the kernel
result = hlq.run(ghz_state, args=(5,), shots=1000)
print(result)  # {'00000': ~500, '11111': ~500}

# Works on any backend
result_gpu = hlq.run(
    ghz_state,
    args=(20,),       # 20-qubit GHZ!
    shots=1000,
    backend="cudaq"   # GPU acceleration
)

Integrierte Quantenalgorithmen

HLQuantum enthält sofort einsatzbereite Implementierungen gängiger Quantenalgorithmen, die auf jedem Backend funktionieren.

Quanten-Fourier-Transformation (QFT)PhasenschätzungShors Algorithmus

Das quantenmechanische Analogon zur diskreten Fourier-Transformation. Wird als Unterroutine in vielen Algorithmen verwendet, darunter Shors Faktorisierungsalgorithmus.

python
import hlquantum as hlq
from hlquantum.algorithms import QFT

# Create a QFT circuit for 4 qubits
qft_circuit = QFT(n_qubits=4)
result = hlq.run(qft_circuit, shots=1000)
print(result)

Grovers SuchalgorithmusSucheQuadratische Beschleunigung

Bietet eine quadratische Beschleunigung für die unstrukturierte Suche. Findet ein markiertes Element in √N Schritten statt in N.

python
import hlquantum as hlq
from hlquantum.algorithms import Grover

# Search for item "101" in a 3-qubit space
grover = Grover(oracle_string="101")
result = hlq.run(grover.circuit, shots=2000)

# The marked state should have high probability
print(result)  # {'101': ~1800, others: ~200}

VQE — Variational Quantum EigensolverChemieOptimierung

Findet die Grundzustandsenergie eines Hamiltonoperators. Schlüsselalgorithmus für die Quantenchemie auf NISQ-Geräten.

python
import hlquantum as hlq
from hlquantum.algorithms import VQE
from hlquantum.operators import PauliSum

# Define Hamiltonian
H = PauliSum.from_list([
    ("ZZ", -1.052), ("IZ", 0.398),
    ("ZI", -0.398), ("XX", 0.181),
])

vqe = VQE(hamiltonian=H, n_qubits=2, ansatz="TwoLocal", reps=2)
energy, params = vqe.run(backend="qiskit", max_iter=200)
print(f"Ground state energy: {energy:.6f}")

QAOA — Quanten-NäherungsoptimierungKombinatorischOptimierung

Näherungsalgorithmus für kombinatorische Optimierungsprobleme wie MaxCut, Graphpartitionierung und Ablaufplanung.

python
import hlquantum as hlq
from hlquantum.algorithms import QAOA
import networkx as nx

# Define a MaxCut problem
graph = nx.Graph([(0,1),(1,2),(2,3),(3,0),(0,2)])

qaoa = QAOA(problem="maxcut", graph=graph, p=2)
result = qaoa.run(backend="pennylane", shots=2000)
print(f"Best cut: {result.best_solution}")
print(f"Cut value: {result.best_value}")

Quanten-ML-Schichten & -Pipelines

HLQuantum enthält eine ML-inspirierte Komposition für Quantenschaltungen — baue variationelle Ansätze als geschichtete Modelle auf, ähnlich wie bei PyTorchs nn.Sequential.

hl_pipeline.py
import hlquantum as hlq
from hlquantum.layers import RYLayer, EntanglingLayer, Sequential

# Build a variational quantum model
model = Sequential([
    RYLayer(n_qubits=4),         # Layer of RY rotations
    EntanglingLayer(n_qubits=4), # CNOT entangling layer
    RYLayer(n_qubits=4),         # Another RY layer
    EntanglingLayer(n_qubits=4),
])

# Run the model (initializes random params)
result = model.run(shots=1000, backend="pennylane")

# Train the model (gradient-based)
loss_history = model.fit(
    X_train, y_train,
    optimizer="adam",
    learning_rate=0.01,
    epochs=50
)

Asynchrone Multi-Backend-Ausführung

Führe dieselbe Schaltung gleichzeitig auf mehreren Backends aus und vergleiche die Ergebnisse. Ideal, um Rauschpegel zu benchmarken oder Ergebnisse plattformübergreifend zu verifizieren.

async_run.py
import hlquantum as hlq
import asyncio

qc = hlq.Circuit(3)
qc.h(0).cx(0, 1).cx(1, 2).measure_all()

async def benchmark_backends():
    tasks = {
        name: hlq.run_async(qc, shots=1000, backend=name)
        for name in ["qiskit", "cirq", "pennylane", "cudaq"]
    }
    results = {name: await task for name, task in tasks.items()}

    for name, result in results.items():
        print(f"{name}: {result}")

asyncio.run(benchmark_backends())

Fehlerminderung

HLQuantum enthält integrierte Techniken zur Fehlerminderung für die Ausführung auf echter Hardware.

error_mitigation.py
import hlquantum as hlq
from hlquantum.mitigation import ZNE, ReadoutMitigation

qc = hlq.Circuit(2)
qc.h(0).cx(0, 1).measure_all()

# Zero-Noise Extrapolation (ZNE)
mitigated_result = hlq.run(
    qc,
    shots=2000,
    backend="qiskit",
    device="ibm_sherbrooke",  # Real hardware
    mitigation=ZNE(noise_factors=[1, 2, 3])
)

# Readout error mitigation
result_mit = hlq.run(
    qc,
    shots=2000,
    backend="qiskit",
    mitigation=ReadoutMitigation()
)

print(f"Raw result:      {hlq.run(qc, shots=2000)}")
print(f"Mitigated result: {mitigated_result}")

GPU-Beschleunigung

gpu_accel.py
import hlquantum as hlq

# Large circuit — 28 qubits
qc = hlq.Circuit(28)
for i in range(28):
    qc.h(i)
for i in range(27):
    qc.cx(i, i + 1)
qc.measure_all()

# CPU simulation (may be slow for 28 qubits)
result_cpu = hlq.run(qc, shots=100, backend="qiskit")

# GPU simulation — orders of magnitude faster!
result_gpu = hlq.run(qc, shots=100, backend="cudaq")  # NVIDIA
result_gpu2 = hlq.run(qc, shots=100, backend="pennylane",
                       device="lightning.gpu")           # lightning.gpu

print(f"CPU: {result_cpu}")
print(f"GPU (CUDA-Q): {result_gpu}")
🤖

KI-gesteuertes Quantencomputing (MCP)

HLQuantum bietet Unterstützung für das Model Context Protocol (MCP), wodurch KI-Agenten Quantenschaltungen autonom konstruieren, optimieren und ausführen können. Dies ermöglicht ein neues Paradigma der KI-gesteuerten Entdeckung von Quantenalgorithmen.

Mehr über die MCP-Integration von HLQuantum erfahren