Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions azure-quantum/azure/quantum/qiskit/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def _azure_config(self) -> Dict[str, str]:
"blob_name": "inputData",
"content_type": "qir.v1",
"input_data_format": "qir.v1",
"output_data_format": "microsoft.quantum-results.v2",
}

def run(
Expand Down
28 changes: 23 additions & 5 deletions azure-quantum/azure/quantum/qiskit/backends/ionq.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from qiskit.providers import Options, Provider

from qiskit_ionq.helpers import (
ionq_basis_gates,
GATESET_MAP,
qiskit_circ_to_ionq_circ,
)
Expand Down Expand Up @@ -52,6 +51,25 @@
_IONQ_SHOTS_INPUT_PARAM_NAME = "shots"
_DEFAULT_SHOTS_COUNT = 500

IONQ_BASIS_GATES = [
"measure",
"m",
"cx",
"cz",
"h",
"reset",
"rx",
"ry",
"rz",
"s",
"swap",
"t",
"x",
"y",
"z",
"id",
]

class IonQQirBackendBase(AzureQirBackend):
"""Base class for interfacing with an IonQ QIR backend"""

Expand Down Expand Up @@ -115,7 +133,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "IonQ simulator on Azure Quantum",
"basis_gates": ionq_basis_gates,
"basis_gates": IONQ_BASIS_GATES,
"memory": False,
"n_qubits": 29,
"conditional": False,
Expand Down Expand Up @@ -147,7 +165,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "IonQ QPU on Azure Quantum",
"basis_gates": ionq_basis_gates,
"basis_gates": IONQ_BASIS_GATES,
"memory": False,
"n_qubits": 11,
"conditional": False,
Expand Down Expand Up @@ -179,7 +197,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "IonQ Aria QPU on Azure Quantum",
"basis_gates": ionq_basis_gates,
"basis_gates": IONQ_BASIS_GATES,
"memory": False,
"n_qubits": 23,
"conditional": False,
Expand Down Expand Up @@ -211,7 +229,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "IonQ Forte QPU on Azure Quantum",
"basis_gates": ionq_basis_gates,
"basis_gates": IONQ_BASIS_GATES,
"memory": False,
"n_qubits": 35,
"conditional": False,
Expand Down
7 changes: 2 additions & 5 deletions azure-quantum/azure/quantum/qiskit/backends/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
from qiskit.providers.models import BackendConfiguration
from qiskit.providers import Options, Provider

QIR_BASIS_GATES = [
MICROSOFT_BASIS_GATES = [
"measure",
"m",
"ccx",
"cx",
"cz",
"h",
Expand All @@ -24,10 +23,8 @@
"ry",
"rz",
"s",
"sdg",
"swap",
"t",
"tdg",
"x",
"y",
"z",
Expand Down Expand Up @@ -93,7 +90,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "Resource estimator on Azure Quantum",
"basis_gates": QIR_BASIS_GATES,
"basis_gates": MICROSOFT_BASIS_GATES,
"memory": False,
"n_qubits": 0xFFFFFFFFFFFFFFFF, # NOTE: maximum 64-bit unsigned value
"conditional": True,
Expand Down
8 changes: 3 additions & 5 deletions azure-quantum/azure/quantum/qiskit/backends/qci.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from qiskit.providers.models import BackendConfiguration
from qiskit.providers import Options, Provider

QIR_BASIS_GATES = [
QCI_BASIS_GATES = [
"measure",
"m",
"barrier",
Expand All @@ -27,10 +27,8 @@
"ry",
"rz",
"s",
"sdg",
"swap",
"t",
"tdg",
"x",
"y",
"z",
Expand Down Expand Up @@ -110,7 +108,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "QCI simulator on Azure Quantum",
"basis_gates": QIR_BASIS_GATES,
"basis_gates": QCI_BASIS_GATES,
"memory": False,
"n_qubits": 29,
"conditional": True,
Expand Down Expand Up @@ -142,7 +140,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "QCI QPU on Azure Quantum",
"basis_gates": QIR_BASIS_GATES,
"basis_gates": QCI_BASIS_GATES,
"memory": False,
"n_qubits": 11,
"conditional": True,
Expand Down
10 changes: 4 additions & 6 deletions azure-quantum/azure/quantum/qiskit/backends/quantinuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@
"cx",
"cz",
"s",
"sdg",
"t",
"tdg",
"v",
"vdg",
"zz",
"rzz",
"measure",
"reset",
]
Expand Down Expand Up @@ -119,7 +117,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"coupling_map": None,
"description": f"Quantinuum Syntax Checker on Azure Quantum",
"basis_gates": QUANTINUUM_BASIS_GATES,
"memory": False,
"memory": True,
"n_qubits": self._get_n_qubits(name),
"conditional": False,
"max_shots": None,
Expand Down Expand Up @@ -156,7 +154,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"coupling_map": None,
"description": f"Quantinuum emulator on Azure Quantum",
"basis_gates": QUANTINUUM_BASIS_GATES,
"memory": False,
"memory": True,
"n_qubits": self._get_n_qubits(name),
"conditional": False,
"max_shots": None,
Expand Down Expand Up @@ -193,7 +191,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"coupling_map": None,
"description": f"Quantinuum QPU on Azure Quantum",
"basis_gates": QUANTINUUM_BASIS_GATES,
"memory": False,
"memory": True,
"n_qubits": self._get_n_qubits(name),
"conditional": False,
"max_shots": 10000,
Expand Down
12 changes: 5 additions & 7 deletions azure-quantum/azure/quantum/qiskit/backends/rigetti.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qiskit.providers.models import BackendConfiguration
from qiskit.providers import Options, Provider

QIR_BASIS_GATES = [
RIGETTI_BASIS_GATES = [
"measure",
"m",
"cx",
Expand All @@ -23,9 +23,7 @@
"ry",
"rz",
"s",
"sdg",
"t",
"tdg",
"x",
"y",
"z",
Expand Down Expand Up @@ -85,8 +83,8 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "Rigetti simulator on Azure Quantum",
"basis_gates": QIR_BASIS_GATES,
"memory": False,
"basis_gates": RIGETTI_BASIS_GATES,
"memory": True,
"n_qubits": RigettiTarget.num_qubits(name),
"conditional": False,
"max_shots": 10000,
Expand Down Expand Up @@ -117,8 +115,8 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"local": False,
"coupling_map": None,
"description": "Rigetti QPU on Azure Quantum",
"basis_gates": QIR_BASIS_GATES,
"memory": False,
"basis_gates": RIGETTI_BASIS_GATES,
"memory": True,
"n_qubits": RigettiTarget.num_qubits(name),
"conditional": False,
"max_shots": 10000,
Expand Down
49 changes: 18 additions & 31 deletions azure-quantum/azure/quantum/qiskit/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,45 +273,32 @@ def _format_unknown_results(self):

def _translate_microsoft_v2_results(self):
""" Translate Microsoft's batching job results histograms into a format that can be consumed by qiskit libraries. """
az_result = self._azure_job.get_results()

if not "DataFormat" in az_result:
raise ValueError("DataFormat missing from Job results")

if not "Results" in az_result:
raise ValueError("Results missing from Job results")

az_result_histogram = self._azure_job.get_results_histogram()
az_result_shots = self._azure_job.get_results_shots()

# If it is a non-batched result, format to be in batch format so we can have one code path
if isinstance(az_result_histogram, dict):
az_result_histogram = [az_result_histogram]
az_result_shots = [az_result_shots]
histograms = []
results = az_result["Results"]
for circuit_results in results:

for (histogram, shots) in zip(az_result_histogram, az_result_shots):
counts = {}
probabilities = {}

if not "TotalCount" in circuit_results:
raise ValueError("TotalCount missing from Job results")
total_count = len(shots)

total_count = circuit_results["TotalCount"]

if total_count <= 0:
raise ValueError("TotalCount must be a positive non-zero integer")

if not "Histogram" in circuit_results:
raise ValueError("Histogram missing from Job results")

histogram = circuit_results["Histogram"]
for result in histogram:
if not "Display" in result:
raise ValueError("Dispaly missing from histogram result")

if not "Count" in result:
raise ValueError("Count missing from histogram result")

bitstring = AzureQuantumJob._qir_to_qiskit_bitstring(result["Display"])
count = result["Count"]
for (display, result) in histogram.items():
bitstring = AzureQuantumJob._qir_to_qiskit_bitstring(display)
count = result["count"]
probability = count / total_count
counts[bitstring] = count
probabilities[bitstring] = probability
histograms.append((total_count, {"counts": counts, "probabilities": probabilities}))

formatted_shots = [AzureQuantumJob._qir_to_qiskit_bitstring(shot) for shot in shots]

histograms.append((total_count, {"counts": counts, "probabilities": probabilities, "memory": formatted_shots}))
return histograms

def _get_entry_point_names(self):
Expand Down
Loading