Introduction to Qrisp on VTT QX

This notebook demonstrates how to use Qrisp, a high-level quantum programming language, with VTT’s quantum computers.

1. Setting Up the VTT Backend

The IQMBackend function connects Qrisp to VTT’s quantum computers through the VTT QX platform. It requires the following arguments:

  • api_token: Your personal access token from your VTT QX project.
  • server_url: The server URL, pointing to one of VTT QX quantum devices (q5 or q50).
from qrisp.interface import IQMBackend

qx_url = (
    "https://qx.vtt.fi/api/devices/q50"  # URL for VTT QX quantum device (q50 or q5)
)

# Replace YOUR_API_TOKEN_HERE with your actual token from VTT QX.
qrisp_qx = IQMBackend(api_token="YOUR_API_TOKEN_HERE", server_url=qx_url)

2. Running a Simple Qrisp Program

from qrisp import QuantumVariable, h, cx


# Create a GHZ state with 3 qubits
def create_ghz_state(n_qubits=3):
    # Create a quantum variable with n_qubits
    qv = QuantumVariable(n_qubits)

    # Apply Hadamard to the first qubit
    h(qv[0])

    # Apply CNOTs to create entanglement
    for i in range(n_qubits - 1):
        cx(qv[i], qv[i + 1])

    return qv


# Create the GHZ state
ghz = create_ghz_state(3)

# Measure the state
result_ghz = ghz.get_measurement(backend=qrisp_qx, shots=1000)
print(result_ghz)

# For simulation, use the default backend
# result_ghz_sim = ghz.get_measurement(shots=1000)
# print("Simulated GHZ state measurement:")
# print(result_ghz_sim)
{'000': 0.452, '111': 0.428, '110': 0.03, '011': 0.03, '001': 0.028, '100': 0.018, '010': 0.007, '101': 0.007}

Conclusion

This tutorial demonstrated how to:

  • Connect Qrisp to VTT QX quantum computers.
  • Create and execute a simple GHZ quantum circuit.

For more information, check the Qrisp documentation and the VTT QX documentation.