microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/replace-qsharp-with-qdk-python-tests

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/pip/qsharp/interop/qiskit/backends/neutral_atom_target.py

44lines · modecode

1# Copyright (c) Microsoft Corporation.
2# Licensed under the MIT License.
3
4import logging
5
6from qiskit.circuit import Measure, Parameter, Reset
7from qiskit.circuit.library.standard_gates import CZGate, RZGate, SXGate
8from qiskit.transpiler.target import Target
9
10logger = logging.getLogger(__name__)
11
12
13class NeutralAtomTarget:
14 """Factory for a Qiskit ``Target`` restricted to the NeutralAtomDevice native gate set.
15
16 The native gate set is ``{rz, sx, cz, measure}`` — the only gates that survive
17 ``NeutralAtomDevice.compile()``'s decomposition pipeline. Using this target ensures
18 that Qiskit's transpiler decomposes all non-native gates (H, CX, X, etc.) into
19 native gates *before* QASM3 export, so the noise model fields that matter
20 (``noise.rz``, ``noise.sx``, ``noise.cz``, ``noise.mresetz``) align with the
21 gates actually present during simulation.
22 """
23
24 @classmethod
25 def build_target(
26 cls,
27 num_qubits: int | None = None,
28 ) -> Target:
29 """Return a Qiskit ``Target`` with only the NeutralAtomDevice native gates.
30
31 :param num_qubits: Number of qubits. ``None`` means no limit (simulator).
32 :return: A ``Target`` containing ``{rz, sx, cz, measure, reset}``.
33 """
34 target = Target(num_qubits=num_qubits)
35
36 target.add_instruction(RZGate(Parameter("theta")), name="rz")
37 target.add_instruction(SXGate, name="sx")
38 target.add_instruction(CZGate, name="cz")
39 target.add_instruction(Measure, name="measure")
40 # Reset is used internally by NeutralAtomDevice (MResetZ), so include it
41 # so the transpiler can express mid-circuit resets.
42 target.add_instruction(Reset, name="reset")
43
44 return target
45