iqm-pulla 9.0.0__py3-none-any.whl → 9.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iqm/pulla/utils_qir.py +37 -8
- iqm/pulla/utils_qiskit.py +6 -2
- {iqm_pulla-9.0.0.dist-info → iqm_pulla-9.2.0.dist-info}/METADATA +2 -2
- {iqm_pulla-9.0.0.dist-info → iqm_pulla-9.2.0.dist-info}/RECORD +8 -8
- {iqm_pulla-9.0.0.dist-info → iqm_pulla-9.2.0.dist-info}/AUTHORS.rst +0 -0
- {iqm_pulla-9.0.0.dist-info → iqm_pulla-9.2.0.dist-info}/LICENSE.txt +0 -0
- {iqm_pulla-9.0.0.dist-info → iqm_pulla-9.2.0.dist-info}/WHEEL +0 -0
- {iqm_pulla-9.0.0.dist-info → iqm_pulla-9.2.0.dist-info}/top_level.txt +0 -0
iqm/pulla/utils_qir.py
CHANGED
|
@@ -34,10 +34,11 @@ from pyqir import (
|
|
|
34
34
|
required_num_results,
|
|
35
35
|
result_id,
|
|
36
36
|
)
|
|
37
|
+
from qiskit import QuantumCircuit
|
|
38
|
+
from qiskit.providers import BackendV2
|
|
37
39
|
|
|
38
40
|
from iqm.cpc.compiler.compiler import Compiler
|
|
39
41
|
from iqm.cpc.interface.compiler import Circuit as CPC_Circuit
|
|
40
|
-
from iqm.pulla.pulla import Pulla
|
|
41
42
|
from iqm.pulse.builder import CircuitOperation
|
|
42
43
|
|
|
43
44
|
qir_logger = logging.getLogger(__name__)
|
|
@@ -147,19 +148,20 @@ def _parse_double(value: str) -> float:
|
|
|
147
148
|
|
|
148
149
|
|
|
149
150
|
def qir_to_pulla( # noqa: PLR0915, PLR0912
|
|
150
|
-
|
|
151
|
+
compiler: Compiler, qir: str | bytes, qubit_mapping: dict[str, str] | None = None
|
|
151
152
|
) -> tuple[list[CPC_Circuit], Compiler]:
|
|
152
153
|
"""Convert a QIR module to a CPC circuit.
|
|
153
154
|
|
|
154
155
|
Args:
|
|
155
|
-
|
|
156
|
+
compiler: compiler to use
|
|
156
157
|
qir: The QIR source or bitcode to convert to a circuit.
|
|
157
158
|
qubit_mapping: A dictionary mapping QIR qubit indexes to physical qubit names,
|
|
158
159
|
None will assume opaque pointers match physical names.
|
|
159
160
|
|
|
160
161
|
Returns:
|
|
161
162
|
str: The QIR program name,
|
|
162
|
-
tuple[
|
|
163
|
+
tuple[list[Circuit], Compiler]:
|
|
164
|
+
Circuits extracted from the QIR module and the compiler with updated component_mapping
|
|
163
165
|
|
|
164
166
|
Raises:
|
|
165
167
|
ValueError: If the QIR program has more than one basic block.
|
|
@@ -240,14 +242,11 @@ def qir_to_pulla( # noqa: PLR0915, PLR0912
|
|
|
240
242
|
circuits = [CPC_Circuit(name=name, instructions=circuit_instructions)]
|
|
241
243
|
qir_logger.debug("Converted circuit: %s", circuits)
|
|
242
244
|
|
|
243
|
-
# Create a compiler containing all the required station information
|
|
244
|
-
compiler = pulla.get_standard_compiler()
|
|
245
|
-
|
|
246
245
|
if qubit_mapping:
|
|
247
246
|
# QIR programs reference to qubits as opaque pointer indexes,
|
|
248
247
|
# however, for example qiskit is using logical names for qubits,
|
|
249
248
|
# so we need to map these indexes to physical qubit names
|
|
250
|
-
compiler.component_mapping = {f"{i}": qubit_mapping[i] for i in range(_required_num_qubits)}
|
|
249
|
+
compiler.component_mapping = {f"{i}": qubit_mapping[str(i)] for i in range(_required_num_qubits)}
|
|
251
250
|
else:
|
|
252
251
|
# QIR programs reference to qubits as opaque pointer indexes,
|
|
253
252
|
# we expect these indexes to match physical qubit names,
|
|
@@ -256,3 +255,33 @@ def qir_to_pulla( # noqa: PLR0915, PLR0912
|
|
|
256
255
|
compiler.component_mapping = {f"{i}": f"QB{i + 1}" for i in range(_required_num_qubits)}
|
|
257
256
|
|
|
258
257
|
return circuits, compiler
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def generate_qiskit_qir_qubit_mapping(qiskit_circuit: QuantumCircuit, qiskit_backend: BackendV2) -> dict[str, str]:
|
|
261
|
+
"""qiskit-qir has a bug, which causes qubit pointers to not be generated correctly
|
|
262
|
+
according to the final_layout. So we replicate this logic here and generate a new mapping.
|
|
263
|
+
Then we assign qiskit-qir index to the qiskit logic qubit idx.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
qiskit_circuit: Qiskit circuit to generate the mapping for.
|
|
267
|
+
qiskit_backend: Qiskit backend object to be used for qubit name generation.
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
A dictionary mapping Qiskit qubit indices to QIR qubit pointers.
|
|
271
|
+
|
|
272
|
+
"""
|
|
273
|
+
# For simplicity, reverse the mapping
|
|
274
|
+
layout_reverse_mapping = {bit: idx for idx, bit in qiskit_circuit.layout.final_layout.get_physical_bits().items()}
|
|
275
|
+
qiskit_qir_mapping: dict[int, int] = {}
|
|
276
|
+
|
|
277
|
+
# Replicate qiskit-qir logic for defining qubit pointer indices
|
|
278
|
+
for register in qiskit_circuit.qregs:
|
|
279
|
+
qiskit_qir_mapping.update(
|
|
280
|
+
{layout_reverse_mapping[bit]: n + len(qiskit_qir_mapping) for n, bit in enumerate(register)}
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
# In the generated QIR qubit pointers will use qiskit-qir qubit labels,
|
|
284
|
+
# but we already know how to map them to IQM physical qubits, through qiskit logical qubit indices.
|
|
285
|
+
return {
|
|
286
|
+
str(qiskit_qir_mapping[i]): str(qiskit_backend.index_to_qubit_name(i)) for i in range(qiskit_circuit.num_qubits)
|
|
287
|
+
}
|
iqm/pulla/utils_qiskit.py
CHANGED
|
@@ -19,6 +19,7 @@ from collections import Counter
|
|
|
19
19
|
from collections.abc import Collection, Sequence
|
|
20
20
|
from typing import TYPE_CHECKING
|
|
21
21
|
|
|
22
|
+
from iqm.iqm_client import Circuit
|
|
22
23
|
from iqm.qiskit_iqm.iqm_backend import IQMBackendBase
|
|
23
24
|
from iqm.qiskit_iqm.iqm_job import IQMJob
|
|
24
25
|
from iqm.qiskit_iqm.qiskit_to_iqm import serialize_instructions
|
|
@@ -32,7 +33,7 @@ from iqm.pulla.interface import StationControlResult, TaskStatus
|
|
|
32
33
|
from iqm.pulse.builder import CircuitOperation
|
|
33
34
|
|
|
34
35
|
if TYPE_CHECKING:
|
|
35
|
-
from iqm.iqm_client import
|
|
36
|
+
from iqm.iqm_client import Instruction
|
|
36
37
|
from iqm.qiskit_iqm.iqm_backend import DynamicQuantumArchitecture
|
|
37
38
|
from iqm.qiskit_iqm.iqm_provider import IQMBackend
|
|
38
39
|
|
|
@@ -137,7 +138,10 @@ def qiskit_to_pulla(
|
|
|
137
138
|
else {m.logical_name: m.physical_name for m in run_request.qubit_mapping}
|
|
138
139
|
)
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
# We can be certain run_request contains only Circuit objects, because we created it
|
|
142
|
+
# right in this method with qiskit.QuantumCircuit objects
|
|
143
|
+
run_request_iqm_circuits: list[Circuit] = [c for c in run_request.circuits if isinstance(c, (Circuit))]
|
|
144
|
+
circuits = [_circuit_to_dataclass(c) for c in run_request_iqm_circuits]
|
|
141
145
|
return circuits, compiler
|
|
142
146
|
|
|
143
147
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: iqm-pulla
|
|
3
|
-
Version: 9.
|
|
3
|
+
Version: 9.2.0
|
|
4
4
|
Summary: Client library for pulse-level access to an IQM quantum computer
|
|
5
5
|
Author-email: IQM Finland Oy <developers@meetiqm.com>
|
|
6
6
|
License: Apache License
|
|
@@ -239,8 +239,8 @@ Provides-Extra: qiskit
|
|
|
239
239
|
Requires-Dist: iqm-exa-common <27,>=26 ; extra == 'qiskit'
|
|
240
240
|
Requires-Dist: iqm-station-control-client <10,>=9 ; extra == 'qiskit'
|
|
241
241
|
Requires-Dist: iqm-pulse <11,>=10 ; extra == 'qiskit'
|
|
242
|
-
Requires-Dist: iqm-client <30,>=29 ; extra == 'qiskit'
|
|
243
242
|
Requires-Dist: iqm-client[qiskit] <30,>=29 ; extra == 'qiskit'
|
|
243
|
+
Requires-Dist: iqm-client <30,>=29 ; extra == 'qiskit'
|
|
244
244
|
|
|
245
245
|
IQM Pulla
|
|
246
246
|
#########
|
|
@@ -18,11 +18,11 @@ iqm/pulla/quantum_architecture.py,sha256=mJH9e9fdkblg6LrgN7qd-Ui3Igawf-hGd2Z7Zcl
|
|
|
18
18
|
iqm/pulla/utils.py,sha256=TTAOFhNW59VFAjnu6ZicmHXvp-GI_f66oh6IC1zFQKE,24732
|
|
19
19
|
iqm/pulla/utils_cirq.py,sha256=8SBy6w7cr4AmnCgKwh7dBWwBGfGKxnoEMv9-1yfKs0A,777
|
|
20
20
|
iqm/pulla/utils_dd.py,sha256=SxYAuRBgvYELKjeXpFbP4mM0xCCivDk7WUHw7oEXfMo,1695
|
|
21
|
-
iqm/pulla/utils_qir.py,sha256=
|
|
22
|
-
iqm/pulla/utils_qiskit.py,sha256=
|
|
23
|
-
iqm_pulla-9.
|
|
24
|
-
iqm_pulla-9.
|
|
25
|
-
iqm_pulla-9.
|
|
26
|
-
iqm_pulla-9.
|
|
27
|
-
iqm_pulla-9.
|
|
28
|
-
iqm_pulla-9.
|
|
21
|
+
iqm/pulla/utils_qir.py,sha256=c4LiKdUnHZSQsI4fzc2wp59-qIH1s2sTyfBEf0MTxkk,11495
|
|
22
|
+
iqm/pulla/utils_qiskit.py,sha256=RBrAf_KbxlL8DI078mtN8nK1pdfAbd4yk7DJSZVEFSs,10397
|
|
23
|
+
iqm_pulla-9.2.0.dist-info/AUTHORS.rst,sha256=iCStz7WP5Jk7uMnn9jRA4ybS14X4yeUW2SsWE-OTaRk,328
|
|
24
|
+
iqm_pulla-9.2.0.dist-info/LICENSE.txt,sha256=cCj_biRA4Q8A77vxR8AuvAf-DZ5G79yxR_3lYY6TrmA,11333
|
|
25
|
+
iqm_pulla-9.2.0.dist-info/METADATA,sha256=H-mXVSGK33mzcRzM-y15wgG4udI1mSU8rGssI8koGxk,17695
|
|
26
|
+
iqm_pulla-9.2.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
27
|
+
iqm_pulla-9.2.0.dist-info/top_level.txt,sha256=NB4XRfyDS6_wG9gMsyX-9LTU7kWnTQxNvkbzIxGv3-c,4
|
|
28
|
+
iqm_pulla-9.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|