← Quantum Store · Guides · Lessons · Glossary · Packages · About · Türkçe

Fraunhofer FOKUS and Eclipse Qrisp

High-level quantum programming with Qrisp

SoftwareQuantum SDKLicence: EPL-2.0Version: 0.910.3 KB

Official source: eclipse-qrisp/Qrisp

Download ZIP (free)

Quantum arithmetic without fiddling with gates, using Qrisp developed at Fraunhofer FOKUS: a tested example that adds 3 to 8 numbers in superposition in a single circuit.

What is Qrisp?

Qrisp is a quantum programming language (as a Python library) developed at Fraunhofer FOKUS in Berlin and maintained today under the Eclipse Foundation. Instead of gates you write programs with quantum variables (QuantumFloat, QuantumBool …) and familiar operators (+, *, ==); Qrisp builds the required circuit and cleans up the helper qubits itself.

When to use it

The example in this package

kuantum_toplama.py puts a 3-bit number into an equal superposition of 0–7, adds it together with 3 into a second 4-bit variable, and measures both together. All eight additions are done in one circuit and every line gives the correct a+3.

In our first attempt we also kept the result in 3 bits; sums such as 5+3 overflowed and came out as 0. The bit width of quantum variables is fixed, as with classical integers, so you have to leave room for the result to fit.

Version note

The example was run on Linux with the current Qrisp 0.9.9. If you get a "DLL initialisation" error while jaxlib loads on Windows, first install Microsoft's current "Visual C++ Redistributable" package (https://aka.ms/vs/17/release/vc_redist.x64.exe); an old runtime causes this error. If you cannot update, the same example ran without problems on our Windows test machine with pip install "qrisp==0.6.3".

Next steps

  1. Try c = a * a instead of b += a; Qrisp builds the multiplication circuit itself.
  2. Move on to the Grover and QAOA tutorials in the documentation.

Installation and running

pip install qrisp
python kuantum_toplama.py

Tested with: qrisp 0.6.3 (Windows, Python 3.12) and qrisp 0.9.9 (Linux, Python 3.12).

Official source

Links

Package contents

Licence

The example code and the guide in this package were written by the Quantum Store editors and are MIT licensed. The project it uses is subject to its own licence (EPL-2.0).


Quantum Store — https://hakanerdogan.com/en

Example code

The example shipped in the package, run and checked. Comments and printed messages are in Turkish; the code is the same in any language. Everything is in the ZIP.

kuantum_toplama.py

"""Qrisp ile kuantum aritmetiği: süperpozisyondaki bir sayıya 3 ekle.

Çalıştırma:
    pip install qrisp
    python kuantum_toplama.py
"""

from qrisp import QuantumFloat, h, multi_measurement

a = QuantumFloat(3)  # 0..7 arası tamsayı tutan kuantum değişkeni
h(a)  # a artık 0..7'nin hepsinin eşit süperpozisyonu

# Sonuç 10'a kadar çıkabilir; 3 bit yetmez (taşar), bu yüzden 4 bitlik yer aç.
b = QuantumFloat(4)
b[:] = 3
b += a  # Qrisp toplama devresini kendisi kurar

sonuc = multi_measurement([a, b])
for (x, y), p in sorted(sonuc.items()):
    print(f"a={x:>3}  a+3={y:>4}  olasılık={p:.3f}")

assert len(sonuc) == 8
assert all(y == x + 3 for (x, y) in sonuc)
print("Tamam: tek devreyle 8 toplama aynı anda yapıldı; her sonuç doğru.")

Related concepts

← All packages

Share: X · LinkedIn