Qoqo, Struqture and HQS Noise App (HQS)

General

The HQS-Package is composed of three libraries which provide the basic tools to performance simulations of open quantum system using quantum errors as resource. We provide here a summary of the libraries:

Qoqo: This is a toolkit to represent quantum circuits by HQS Quantum Simulations. Like many quantum toolkits, qoqo is a circuit-based toolkits. A sequence of operations to be run on a quantum computer is grouped into a quantum circuit. In the majority of quantum computing applications, the output of several quantum circuits needs to be collected and processed using additional classical measurement input, in order to construct a usable measurement result (e.g. when using a quantum computer to simulate physical quantum systems). Qoqo also provide tools to group quantum circuits and measurement input into a QuantumProgram. QuantumPrograms are designed as a high-level interface to quantum computations that can be used similar to standard function calls. This package is open source. 

Struqture: This library represents quantum mechanical operators, Hamiltonians and open quantum systems. The library supports building spin objects, fermionic objects, bosonic objects and mixed system objects that contain arbitrary many spin, fermionic and bosonic subsystems. This package is open source. 

HQS Noise App: The HQS Noise App is a software package that permits to set up quantum circuits for the trotterized time evolution operator of spin-, fermionic- and mixed-systems. This library is optimized for noisy quantum computers and can extract an effective noisy algorithm model suitable for the simulation of open quantum systems. This package is not open source. 


Project website / official documentation:

https://hqsquantumsimulations.github.io/qoqo_examples/

https://hqsquantumsimulations.github.io/struqture/

https://github.com/HQSquantumsimulations/qoqo

https://github.com/HQSquantumsimulations/struqture


Author(s):

HQS Quantum Simulations(HQS)


License (Qoqo and Struqture):

Apache License 2.0


Current version / version supported by LRZ:

qoqo 1.3.2, struqture-py==1.1.0

 

Supported HPC systems

Eviden Qaptiva

 

Installation / deployment

Currently all packages are globally installed in the QLM cluster. 


 Example(s) for usage

Create a file in your user space containing the example Python script and the hamiltonian_C2H3NC_B=11.7_rot.json file, as described below. 

Simple use of qoqo
# External imports:
import matplotlib.pyplot as plt
import numpy as np
import json


# Open-source HQS software
from qoqo import devices

from struqture_py.spins import (
    SpinHamiltonianSystem,
    PauliProduct,
    SpinSystem,
)
from qoqo_quest import Backend

# Internal HQS
from hqs_noise_app import HqsNoiseApp


# Open file.
with open("hamiltonian_C2H3NC_B=11.7_rot.json") as file:
    # Load json file.
    system_hamiltonian_json = json.load(file)

# Get struqture Hamiltonian from json file.
system_hamiltonian = SpinHamiltonianSystem.from_json(system_hamiltonian_json)

# Get number of spins.
number_spins = system_hamiltonian.number_spins()

print("Number of spins:", number_spins)
print(system_hamiltonian)


# Single qubit gates.
single_qubit_gates = ["RotateX", "RotateY", "RotateZ"]

# Two-qubit gates.
two_qubit_gates = ["VariableMSXX"]

# Default gate-time for all gates.
default_gate_time = 1.0

# Perfect device with all-to-all connectivity.
perfect_device = devices.AllToAllDevice(
    number_spins, single_qubit_gates, two_qubit_gates, default_gate_time
)


# In the following we assume that all spins are set to |0>
initialisation = [0 for _ in range(number_spins)]

# List with measurement operators
operators = []
# List with names of measurement operators.
operator_names = []


for i in range(number_spins):
    operator = SpinSystem(number_spins)
    operator.set(PauliProduct().z(i), 1.0)
    operators.append(operator)
    operator_names.append(f"Magnetization Z site {i}")


# Trotter timestep.
trotter_timestep = 0.0005

# Number of measurements.
number_trottersteps = 400

# Noise acts on all qubits, also on idle qubits.
noise_mode = "parallelization_blocks"

# Algorithm
algorithm = "VariableMolmerSorensen"

# Initialise the HQSNoiseApp.
noise_app = HqsNoiseApp(noise_mode).algorithm(algorithm)


# Create the QuantumProgram.
quantum_program = noise_app.quantum_program(
    system_hamiltonian,
    trotter_timestep=trotter_timestep,
    initialisation=initialisation,
    measured_operators=operators,
    operator_names=operator_names,
    device=perfect_device,
)


from qoqo_qasm import QasmBackend
from qiskit import QuantumCircuit

circuit_evolution = quantum_program.measurement().constant_circuit().operations()[0].circuit()
backend = QasmBackend()
qasm = backend.circuit_to_qasm_str(circuit_evolution)

qiskit_circuit = QuantumCircuit.from_qasm_str(qasm)

#print(qiskit_circuit)

times = np.arange(0, number_trottersteps * trotter_timestep, trotter_timestep)
result = np.zeros((number_spins, number_trottersteps))

quantum_program = noise_app.add_noise(quantum_program, perfect_device, [])
backend = Backend(number_spins)
for i in range(number_trottersteps):
    simulation = backend.run_program(quantum_program, [i])
    for j in range(number_spins):
        result[j, i] = simulation[f"Magnetization Z site {j}_re"]


# Plot the results.
plt.figure(dpi=200)

for ii in range(number_spins):
    plt.plot(times, result[ii, :], ls="-", label="spin %s" % ii)

plt.xlabel("time", fontsize=10)
plt.ylabel("magnetization", fontsize=10)
plt.legend(loc="lower right", fontsize=10, framealpha=1.0)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.savefig('fig.png')


In the above example, the file hamiltonian_C2H3NC_B=11.7_rot.json  have information about the Hamiltonian.

hamiltonian_C2H3NC_B=11.7_rot.json
"{"number_spins":3,"hamiltonian":{"items":[["2X",375.6010675430298],["0Z2Z",-0.7853981633974483],["0Y2Y",-0.7853981633974483],["1Z2Z",13.50884841043611],["1X",-500.8014237880707],["0X1X",24.504422698000386],["1Y2Y",13.50884841043611],["1X2X",13.50884841043611],["0Y1Y",24.504422698000386],["0Z1Z",24.504422698000386],["0X2X",-0.7853981633974483]],"_struqture_version":{"major_version":1,"minor_version":0}}}"






 FAQ / Troubleshooting