Qaptiva Access¶
Qaptiva is the device that enables access to the quantum computing resources at JUNIQ facility.
Before proceeding, please ensure you have:
- Joined a project on JuDoor that provides access to Qaptiva resources. (If not see documentation here)
- Set up QLMAAS access. (If not see instructions in QLMAAS setup documentation)
Sending a job to Qaptiva¶
The following code snippet shows creating a simple Job, submitting it to Qaptiva and viewing the results.
from qlmaas.qpus import LinAlg # Note that we are importing remote qpu from qlmaas and not local one from qat
from qat.lang import qrout, H, CNOT, X
# Define the circuit
@qrout
def bell_pair():
H(0)
CNOT(0, 1)
bell_pair.display()
Alternatively you can create a program in a "Sequential" way:
from qat.lang import Program, H, CNOT
bell_pair = Program()
# Number of qbits
nbqbits = 2
# Allocate some qbits
qbits = bell_pair.qalloc(nbqbits)
# Apply some quantum Gates
H(qbits[0])
CNOT(qbits[0], qbits[1])
# Export this program into a quantum circuit
circuit = bell_pair.to_circ()
# Export this circuit into a job
job = circuit.to_job(nbshots=512)
# Convert the circuit into a myqlm Job
job = bell_pair.to_job(nbshots=512)
# Instantiate the qpu
linalgqpu = LinAlg()
# Submit the job to the QPU
result = linalgqpu.submit(job)
# Visualise the result
for sample in result:
print("State %s probability %s" % (sample.state, sample.probability))
Submitted a new batch: SJob25927 State |00> probability 0.505859375 State |11> probability 0.494140625
# if on a jupyter notebook run `result.display()` to get a better visualisation
result.display()
Result(raw_data=[Sample(_state=b'\x00', probability=0.50390625, _amplitude=None, intermediate_measurements=None, err=0.022118022740803385, qregs=[DefaultRegister(length=2, start=0, msb=None, _subtype_metadata=None, key=None)]), Sample(_state=b'\x03', probability=0.49609375, _amplitude=None, intermediate_measurements=None, err=0.022118022740803385, qregs=[DefaultRegister(length=2, start=0, msb=None, _subtype_metadata=None, key=None)])], _value=None, error=None, value_data=None, error_data=None, meta_data={'nbshots': '512', 'single_job': 'True'}, in_memory=True, data=None, qregs=[DefaultRegister(length=2, start=0, msb=None, _subtype_metadata=None, key=None)], _parameter_map=None, _values=None, values_data=None, need_flip=False, nbqbits=None, lsb_first=False, has_statevector=False, statevector=None)Sending Qiskit circuits to Qaptiva¶
One can also use the interoperability features of myqlm to create a circuit in Qiskit and then submit it to a Qaptiva backend for execution.
WARNING: MyQLM interoperability modules are experimental and might lead to unexpected results. If any issues arise due to this, please report them at myqlm-interop/issues.
Read more about Qiskit interoperability with myqlm here.
And see an example use below, you need to install myqlm-interop[qiskit_binder] module for it to work.
# Making a simple quantum circuit using qiskit
from qiskit import QuantumCircuit
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.measure_all()
# Convert it to a myqlm Job
from qat.interop.qiskit import qiskit_to_qlm
qlm_circuit = qiskit_to_qlm(qc)
qlm_job = qlm_circuit.to_job(nbshots=1000)
# Submitting a job to Qaptiva for a selected QPU
from qlmaas.qpus import LinAlg # Replace with your desired QPU
linalgqpu = LinAlg()
result = linalgqpu.submit(qlm_job)
result.display()
Submitted a new batch: SJob25928
Result(raw_data=[Sample(_state=b'\x00', probability=0.481, _amplitude=None, intermediate_measurements=[IntermediateMeasurement(cbits=[False], gate_pos=3, probability=None), IntermediateMeasurement(cbits=[False], gate_pos=4, probability=None), IntermediateMeasurement(cbits=[False], gate_pos=5, probability=None)], err=0.015807874268505835, qregs=[DefaultRegister(length=3, start=0, msb=None, _subtype_metadata=None, key=None)]), Sample(_state=b'\x07', probability=0.519, _amplitude=None, intermediate_measurements=[IntermediateMeasurement(cbits=[True], gate_pos=3, probability=None), IntermediateMeasurement(cbits=[True], gate_pos=4, probability=None), IntermediateMeasurement(cbits=[True], gate_pos=5, probability=None)], err=0.015807874268505835, qregs=[DefaultRegister(length=3, start=0, msb=None, _subtype_metadata=None, key=None)])], _value=None, error=None, value_data=None, error_data=None, meta_data={'nbshots': '1000', 'single_job': 'True'}, in_memory=True, data=None, qregs=[DefaultRegister(length=3, start=0, msb=None, _subtype_metadata=None, key=None)], _parameter_map=None, _values=None, values_data=None, need_flip=False, nbqbits=None, lsb_first=False, has_statevector=False, statevector=None)from qat.core import Batch
@qrout
def singlet_state():
X(0)
X(1)
H(0)
CNOT(0, 1)
singlet_job = singlet_state.to_job(nbshots=512)
bell_job = bell_pair.to_job(nbshots=512)
# Create a batch
batch = Batch([singlet_job, bell_job])
# submit the batch just as before
batch_result = linalgqpu.submit(batch)
Submitted a new batch: SJob25929
# Display the results
for i, job_result in enumerate(batch_result):
print("Job %s:" % i)
for state in job_result:
print("State %s probability %s" % (state.state, state.probability))
Job 0: State |01> probability 0.5234375 State |10> probability 0.4765625 Job 1: State |00> probability 0.53515625 State |11> probability 0.46484375
Further reading¶
More details on connecting to Qaptiva can be seen in the following resources:
- Circuit manipulation in myqlm
- Main myqlm documentation
- Internal Qaptiva documentation
- Internal Qaptiva Access documentation
Specific examples of using Qaptiva to connect to various quantum devices can be found in the following notebooks: