MQT Qudits - A Framework For Mixed-Dimensional Qudit Quantum ComputingΒΆ
MQT Qudits is an open-source C++17 and Python framework for mixed-dimensional qudit quantum computing developed as part of the Munich Quantum Toolkit (MQT) by the Chair for Design Automation at the Technical University of Munich.
Note
The tool is in an experimental stage, which is subject to frequent changes, and has limited documentation. We are working on improving that. In the meantime, users can explore how to use the framework via the Tutorial, showcasing its main functionality.
Furthermore, this video briefly illustrates some of the functionalities of MQT Qudits.
We appreciate any feedback and contributions to the project. If you have any questions, feel free to create a discussion or an issue on GitHub.
MQT Qudits Tutorial πΒΆ
Discover a New Dimension in Quantum Computing. Embark on a journey with MQT Qudits, a framework for Mixed-Dimensional Quantum Computing.
Delve into the realm of mixed-dimensional quantum computing with NeQSTβa project funded by the European Union and developed developed as part of the Munich Quantum Toolkit (MQT) by the Chair for Design Automation at the Technical University of Munich. Our team is focused on creating design automation methods and software for quantum computing. The following tutorial will guide you through the initial tools and contributions we have made to advance Quantum Information Processing for Science and Technology.
Installation Steps:ΒΆ
(.venv) $ pip install mqt.qudits
For those seeking hands-on customization, simply clone the corresponding repository and perform a local installation.
$ git clone https://github.com/cda-tum/mqt-qudits.git
$ cd mqt-qudits
$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $ pip install -ve .
+++
```{note}
This requires a C++17 compiler, a minimum CMake version of 3.19, and Python 3.8+.
User Inputs π»ΒΆ
1import numpy as np
2
3from mqt.qudits.quantum_circuit import QuantumCircuit
π New QASM Extension:ΒΆ
Dive into a language meticulously designed to express quantum algorithms and circuits. MQT Qudits extends the OpenQASM 2.0 grammar, effortlessly adapting to mixed-dimensional registers. In the following, a DITQASM program is explicitly written, although several methods for importing programs from files are present in the library.
1qasm = """
2 DITQASM 2.0;
3
4 qreg field [7][5,5,5,5,5,5,5];
5 qreg matter [2];
6
7 creg meas_matter[7];
8 creg meas_fields[3];
9
10 h matter[0] ctl field[0] field[1] [0,0];
11 cx field[2], matter[0];
12 cx field[2], matter[1];
13 rxy (0, 1, pi, pi/2) field[3];
14
15 measure q[0] -> meas[0];
16 measure q[1] -> meas[1];
17 measure q[2] -> meas[2];
18 """
A new feature is the control syntax:
_operation_ __ctl__ _quditline_ [list of qudit control levels]
We can import the DITQASM program and construct a quantum circuit.
1circuit = QuantumCircuit()
2circuit.from_qasm(qasm)
3
4print(f"Number of operations: {len(circuit.instructions)}")
5print(f"Number of qudits in the circuit: {circuit.num_qudits}")
6print(f"Dimensions: {circuit.dimensions}")
Number of operations: 4
Number of qudits in the circuit: 9
Dimensions: [5, 5, 5, 5, 5, 5, 5, 2, 2]
π Python InterfaceΒΆ
Constructing and manipulating quantum programs becomes a breeze with Python. You have the flexibility to:
Initialize Quantum Circuits: Start by creating your quantum circuits effortlessly.
Create Quantum Registers: Build dedicated quantum registers tailored to your needs.
Compose Circuits: Seamlessly bring together your quantum registers, forming a unified and powerful circuit.
Apply Operations: Easily apply a variety of qudit operations, without worrying about the right representation.
Letβs construct a quantum circuit from scratch, with the python interface.
1from mqt.qudits.quantum_circuit import QuantumRegister
2
3circuit = QuantumCircuit()
4
5field_reg = QuantumRegister("fields", 1, [7])
6matter_reg = QuantumRegister("matter", 1, [2])
7
8circuit.append(field_reg)
9circuit.append(matter_reg)
10
11print(f"Number of operations: {len(circuit.instructions)}")
12print(f"Number of qudits in the circuit: {circuit.num_qudits}")
13print(f"Gate set: {circuit.gate_set}")
Number of operations: 0
Number of qudits in the circuit: 2
csum
cu_one
cu_two
cu_multi
cx
gellmann
h
ls
ms
pm
r
rh
randu
rz
virtrz
s
x
z
Gate set: None
No operations were inserted yet, letβs take a look at how operations can be applied!
The size of every line is detected automatically and the right operations are applied to the right qudits
1circuit.h(field_reg[0])
2circuit.csum([field_reg[0], matter_reg[0]])
3
4print(f"Number of operations: {len(circuit.instructions)}")
5print(f"Number of qudits in the circuit: {circuit.num_qudits}")
Number of operations: 2
Number of qudits in the circuit: 2
It is possible to export the code as well and share your program in a QASM file.
1print(circuit.to_qasm())
DITQASM 2.0;
qreg fields [1][7];
qreg matter [1][2];
creg meas[2];
h fields[0];
csum fields[0], matter[0];
measure fields[0] -> meas[0];
measure matter[0] -> meas[1];
Letβs save the circuit to a file
1file = circuit.save_to_file("my_circuit", ".")
and load it back
1circuit.load_from_file(file)
2
3print("Program:", circuit.to_qasm(), sep="\n")
4print("Dimensions: ", circuit.dimensions)
Program:
DITQASM 2.0;
qreg fields [1][7];
qreg matter [1][2];
creg meas[2];
h fields[0];
csum fields[0], matter[0];
measure fields[0] -> meas[0];
measure matter[0] -> meas[1];
Dimensions: [7, 2]
Custom gates can be added to the circuit as well.
1n = 5
2random_matrix = np.random.randn(n, n) + 1j * np.random.randn(n, n)
3
4Q, R = np.linalg.qr(random_matrix)
5
6unitary_matrix = Q
7cu = circuit.cu_one(field_reg[0], unitary_matrix)
Gates follow the order:
target qudit/s : list or single number
parameters list with order lower level, upper level, control level, theta, phi
control data
A simple qudit gate can be added as follows:
1r = circuit.r(field_reg[0], [0, 1, np.pi / 5, np.pi / 7])
Operations can also be controlled by other qudits, as shown below:
1from mqt.qudits.quantum_circuit.gate import ControlData
2
3r_c1 = circuit.r(field_reg[0], [0, 1, np.pi / 5, np.pi / 7], ControlData([matter_reg[0]], [1]))
or as
1r_c2 = circuit.r(field_reg[0], [0, 1, np.pi / 5, np.pi / 7]).control([matter_reg[0]], [1])
The representation of the matrix corresponding to a gate is dynamic:
0: no identities
1: identities in between long-range gates are introduced
2: full circuit unitary
1print(f"Gate matrix for {r._name}:", r.to_matrix(0), sep="\n")
Gate matrix for R7:
[[ 0.95105652+0.j -0.13407745-0.27841469j 0. +0.j
0. +0.j 0. +0.j 0. +0.j
0. +0.j ]
[ 0.13407745-0.27841469j 0.95105652+0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j
0. +0.j ]
[ 0. +0.j 0. +0.j 1. +0.j
0. +0.j 0. +0.j 0. +0.j
0. +0.j ]
[ 0. +0.j 0. +0.j 0. +0.j
1. +0.j 0. +0.j 0. +0.j
0. +0.j ]
[ 0. +0.j 0. +0.j 0. +0.j
0. +0.j 1. +0.j 0. +0.j
0. +0.j ]
[ 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 1. +0.j
0. +0.j ]
[ 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j
1. +0.j ]]
The inverse of any gate can easily be obtained.
1rd = r.dag()
2print(f"Inverse gate matrix for {r._name}:", rd.to_matrix(0), sep="\n")
Inverse gate matrix for R7_dag:
[[ 0.95105652-0.j 0.13407745+0.27841469j 0. -0.j
0. -0.j 0. -0.j 0. -0.j
0. -0.j ]
[-0.13407745+0.27841469j 0.95105652-0.j 0. -0.j
0. -0.j 0. -0.j 0. -0.j
0. -0.j ]
[ 0. -0.j 0. -0.j 1. -0.j
0. -0.j 0. -0.j 0. -0.j
0. -0.j ]
[ 0. -0.j 0. -0.j 0. -0.j
1. -0.j 0. -0.j 0. -0.j
0. -0.j ]
[ 0. -0.j 0. -0.j 0. -0.j
0. -0.j 1. -0.j 0. -0.j
0. -0.j ]
[ 0. -0.j 0. -0.j 0. -0.j
0. -0.j 0. -0.j 1. -0.j
0. -0.j ]
[ 0. -0.j 0. -0.j 0. -0.j
0. -0.j 0. -0.j 0. -0.j
1. -0.j ]]
The control information can be accessed as well.
1r_c1.control_info
{'target': 0,
'dimensions_slice': 7,
'params': [0, 1, 0.6283185307179586, 0.4487989505128276],
'controls': ControlData(indices=[1], ctrl_states=[1])}
Two- and multi-qudit gates follow the rule:
two : target_qudits first is control, second is target
multi: all are controls, except last one is target
1r_c1.reference_lines
[1, 0]
Simulation πΒΆ
After crafting your quantum circuit with precision, take it for a spin using two distinct engines, each flaunting its unique set of data structures.
External Tensor-Network Simulator: Delve into the quantum realm with a robust external tensor-network simulator. Can simulate all the gate-set.
MiSiM (C++-Powered): Unleash the power of decision-diagram-based simulation with MiSiM, seamlessly interfaced with Python for a fluid and efficient experience. ππ‘Can only simulate the machine following machine gate set:
csum
cx
h
rxy
rz
rh
virtrz
s
x
z
Basic SimulationΒΆ
1circuit = QuantumCircuit()
2
3field_reg = QuantumRegister("fields", 1, [3])
4matter_reg = QuantumRegister("matter", 1, [3])
5
6circuit.append(field_reg)
7circuit.append(matter_reg)
8
9h = circuit.h(field_reg[0])
10csum = circuit.csum([field_reg[0], matter_reg[0]])
11
12print(f"Number of operations: {len(circuit.instructions)}")
13print(f"Number of qudits in the circuit: {circuit.num_qudits}")
Number of operations: 2
Number of qudits in the circuit: 2
1from mqt.qudits.simulation import MQTQuditProvider
2
3provider = MQTQuditProvider()
4provider.backends("sim")
['tnsim', 'misim']
1from mqt.qudits.visualisation import plot_counts, plot_state
2
3backend = provider.get_backend("tnsim")
4
5job = backend.run(circuit)
6result = job.result()
7
8state_vector = result.get_state_vector()
9
10plot_state(state_vector, circuit)
1backend = provider.get_backend("misim")
2
3job = backend.run(circuit)
4result = job.result()
5
6state_vector = result.get_state_vector()
7
8plot_state(state_vector, circuit)
Extending Engines with Noise Model and Properties for FakeBackendΒΆ
Enhance your quantum simulation experience by extending the engines with a noise model and incorporating various properties. By combining a noise model and carefully tuned properties, you can craft a FakeBackend that closely emulates the performance of the best quantum machines in experimental laboratories. This allows for more realistic and insightful quantum simulations.
Experiment, iterate, and simulate quantum circuits with the sophistication of real-world conditions, all within the controlled environment of your simulation. π οΈπ¬
1from mqt.qudits.simulation.noise_tools.noise import Noise, NoiseModel
2
3# Depolarizing quantum errors
4local_error = Noise(probability_depolarizing=0.001, probability_dephasing=0.001)
5local_error_rz = Noise(probability_depolarizing=0.03, probability_dephasing=0.03)
6
7entangling_error = Noise(probability_depolarizing=0.1, probability_dephasing=0.001)
8entangling_error_extra = Noise(probability_depolarizing=0.1, probability_dephasing=0.1)
9
10entangling_error_on_target = Noise(probability_depolarizing=0.1, probability_dephasing=0.0)
11entangling_error_on_control = Noise(probability_depolarizing=0.01, probability_dephasing=0.0)
12
13# Add errors to noise_tools model
14
15noise_model = NoiseModel() # We know that the architecture is only two qudits
16# Very noisy gate
17noise_model.add_all_qudit_quantum_error(local_error, ["csum"])
18noise_model.add_recurrent_quantum_error_locally(local_error, ["csum"], [0])
19# Entangling gates
20noise_model.add_nonlocal_quantum_error(entangling_error, ["cx", "ls", "ms"])
21noise_model.add_nonlocal_quantum_error_on_target(entangling_error_on_target, ["cx", "ls", "ms"])
22noise_model.add_nonlocal_quantum_error_on_control(entangling_error_on_control, ["csum", "cx", "ls", "ms"])
23# Super noisy Entangling gates
24noise_model.add_nonlocal_quantum_error(entangling_error_extra, ["csum"])
25# Local Gates
26noise_model.add_quantum_error_locally(local_error, ["h", "rxy", "s", "x", "z"])
27noise_model.add_quantum_error_locally(local_error_rz, ["rz", "virtrz"])
28
29print(noise_model.quantum_errors)
{'csum': {'all': Noise(probability_depolarizing=0.001, probability_dephasing=0.001), (0,): Noise(probability_depolarizing=0.001, probability_dephasing=0.001), 'control': Noise(probability_depolarizing=0.01, probability_dephasing=0.0), 'nonlocal': Noise(probability_depolarizing=0.1, probability_dephasing=0.1)}, 'cx': {'nonlocal': Noise(probability_depolarizing=0.1, probability_dephasing=0.001), 'target': Noise(probability_depolarizing=0.1, probability_dephasing=0.0), 'control': Noise(probability_depolarizing=0.01, probability_dephasing=0.0)}, 'ls': {'nonlocal': Noise(probability_depolarizing=0.1, probability_dephasing=0.001), 'target': Noise(probability_depolarizing=0.1, probability_dephasing=0.0), 'control': Noise(probability_depolarizing=0.01, probability_dephasing=0.0)}, 'ms': {'nonlocal': Noise(probability_depolarizing=0.1, probability_dephasing=0.001), 'target': Noise(probability_depolarizing=0.1, probability_dephasing=0.0), 'control': Noise(probability_depolarizing=0.01, probability_dephasing=0.0)}, 'h': {'local': Noise(probability_depolarizing=0.001, probability_dephasing=0.001)}, 'rxy': {'local': Noise(probability_depolarizing=0.001, probability_dephasing=0.001)}, 's': {'local': Noise(probability_depolarizing=0.001, probability_dephasing=0.001)}, 'x': {'local': Noise(probability_depolarizing=0.001, probability_dephasing=0.001)}, 'z': {'local': Noise(probability_depolarizing=0.001, probability_dephasing=0.001)}, 'rz': {'local': Noise(probability_depolarizing=0.03, probability_dephasing=0.03)}, 'virtrz': {'local': Noise(probability_depolarizing=0.03, probability_dephasing=0.03)}}
We can set the noise model for the simulation, but also set several other flags:
shots
: number of shots for the stochastic simulationmemory
: flag for saving shots (True/False)full_state_memory
: save the full noisy statesfile_path
: file path of the h5 database storing the datafile_name
: name of the file
1backend = provider.get_backend("tnsim")
2
3job = backend.run(circuit, noise_model=noise_model)
4
5result = job.result()
6counts = result.get_counts()
7
8plot_counts(counts, circuit)
{'00': 332,
'01': 0,
'02': 3,
'10': 4,
'11': 329,
'12': 0,
'20': 0,
'21': 7,
'22': 325}
You can also invoke a fake backend and retrieve a few relevant properties, that are already embedded in them
1provider = MQTQuditProvider()
2provider.backends("fake")
['faketraps2trits', 'faketraps2six']
1backend_ion = provider.get_backend("faketraps2trits", shots=1000)
1import matplotlib.pyplot as plt
2import networkx as nx
3
4mapping = backend_ion.energy_level_graphs
5
6pos = nx.circular_layout(mapping[0])
7nx.draw(mapping[0], pos, with_labels=True, node_size=2000, node_color="lightblue", font_size=12, font_weight="bold")
8plt.show()
1job = backend_ion.run(circuit)
2result = job.result()
3counts = result.get_counts()
4
5plot_counts(counts, circuit)
{'00': 328,
'01': 0,
'02': 1,
'10': 2,
'11': 322,
'12': 0,
'20': 0,
'21': 2,
'22': 345}
Compilation βοΈΒΆ
Tailor your quantum compilation process to achieve optimal performance and emulate the intricacies of experimental setups.
Compiler Customization with Modern PassesΒΆ
Optimization Strategies: Implement specific optimization strategies based on your quantum algorithmβs characteristics. Fine-tune compilation for better resource utilization and reduced gate counts.
Gate Decomposition: Customize gate decomposition techniques to match the capabilities of experimental quantum hardware. Aligning with the native gate set enhances the efficiency of your compiled circuits.
Experimental-Inspired CompilationΒΆ
Emulate the features of the best experimental laboratories in your compilation process. Leverage modern compiler passes to customize optimization, gate decomposition, and noise-aware strategies, creating compiled circuits that closely resemble the challenges and advantages of cutting-edge quantum hardware.
Customize, compile, and push the boundaries of quantum algorithms with a tailored approach to quantum compilation. π οΈπ§π
1from mqt.qudits.compiler import QuditCompiler
1qudit_compiler = QuditCompiler()
2
3passes = ["PhyLocQRPass"]
1compiled_circuit_qr = qudit_compiler.compile(backend_ion, circuit, passes)
2
3print(f"Number of operations: {len(compiled_circuit_qr.instructions)}")
4print(f"Number of qudits in the circuit: {compiled_circuit_qr.num_qudits}")
Number of operations: 10
Number of qudits in the circuit: 2
1job = backend_ion.run(compiled_circuit_qr)
2
3result = job.result()
4counts = result.get_counts()
5
6plot_counts(counts, compiled_circuit_qr)
{'00': 326,
'01': 0,
'02': 4,
'10': 0,
'11': 326,
'12': 0,
'20': 0,
'21': 2,
'22': 342}
1passes = ["PhyLocAdaPass", "ZPropagationPass", "ZRemovalPass"]
2
3compiled_circuit_ada = qudit_compiler.compile(backend_ion, circuit, passes)
4
5print(f"Number of operations: {len(compiled_circuit_ada.instructions)}")
6print(f"Number of qudits in the circuit: {compiled_circuit_ada.num_qudits}")
Number of operations: 5
Number of qudits in the circuit: 2
1job = backend_ion.run(compiled_circuit_ada)
2
3result = job.result()
4counts = result.get_counts()
5
6plot_counts(counts, compiled_circuit_ada)
{'00': 321,
'01': 0,
'02': 4,
'10': 2,
'11': 328,
'12': 0,
'20': 0,
'21': 3,
'22': 342}
1from mqt.qudits.visualisation import draw_qudit_local
2
3draw_qudit_local(compiled_circuit_ada)
|0>-----[R01(1.57,-2.09)]----[R02(1.23,-2.62)]----[R02(3.14,-2.62)]----[R01(1.57,-0.52)]----MG-----=||
|0>-----MG----MG----MG----MG----MG-----=||
PublicationsΒΆ
MQT Qudits is academic software. Thus, many of its built-in algorithms have been published as scientific papers [1, 2, 3, 4, 5].
If you use MQT Qudits in your work, we would appreciate if you cited the respective paper(s).
Kevin Mato, Stefan Hillmich, and Robert Wille. Mixed-dimensional qudit state preparation using edge-weighted decision diagrams. In Design Automation Conference (DAC). 2024.
Kevin Mato, Stefan Hillmich, and Robert Wille. Mixed-dimensional quantum circuit simulation with decision diagrams. In International Conference on Quantum Computing and Engineering (QCE). 2023. doi:10.1109/QCE57702.2023.00112.
Kevin Mato, Stefan Hillmich, and Robert Wille. Compression of qubit circuits: Mapping to mixed-dimensional quantum systems. In International Conference on Quantum Software (QSW). 2023. doi:10.1109/QSW59989.2023.00027.
Kevin Mato, Martin Ringbauer, Stefan Hillmich, and Robert Wille. Compilation of entangling gates for high-dimensional quantum systems. In Asia and South Pacific Design Automation Conference (ASP-DAC). 2023. doi:10.1145/3566097.3567930.
Kevin Mato, Martin Ringbauer, Stefan Hillmich, and Robert Wille. Adaptive compilation of multi-level quantum operations. In International Conference on Quantum Computing and Engineering (QCE). 2022. doi:10.1109/QCE53715.2022.00070.
mqt.qudits
ΒΆ
MQT Qudits - A framework for mixed-dimensional qudit quantum computing.
SubpackagesΒΆ
mqt.qudits.compiler
ΒΆ
SubpackagesΒΆ
mqt.qudits.compiler.compilation_minitools
ΒΆ
Common utilities for compilation.
SubmodulesΒΆ
mqt.qudits.compiler.compilation_minitools.local_compilation_minitools
ΒΆ
Module ContentsΒΆ
mqt.qudits.compiler.compilation_minitools.naive_unitary_verifier
ΒΆ
Module ContentsΒΆ
- class UnitaryVerifier(sequence, target, dimensions, nodes=None, initial_map=None, final_map=None)[source]ΒΆ
Verifies unitary matrices. sequence is a list of numpy arrays target is a numpy array dimensions is list of ints, equals to the dimensions of the qudits involved in the target operation initial_map is a list representing the mapping of the logic states to the physical ones at the beginning of the computation final_map is a list representing the mapping of the logic states to the physical ones at the end of the computation
mqt.qudits.compiler.compilation_minitools.numerical_ansatz_utils
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
- class UnitaryVerifier(sequence, target, dimensions, nodes=None, initial_map=None, final_map=None)[source]ΒΆ
Verifies unitary matrices. sequence is a list of numpy arrays target is a numpy array dimensions is list of ints, equals to the dimensions of the qudits involved in the target operation initial_map is a list representing the mapping of the logic states to the physical ones at the beginning of the computation final_map is a list representing the mapping of the logic states to the physical ones at the end of the computation
mqt.qudits.compiler.onedit
ΒΆ
SubpackagesΒΆ
mqt.qudits.compiler.onedit.local_operation_swap
ΒΆ
SubmodulesΒΆ
mqt.qudits.compiler.onedit.local_operation_swap.swap_routine
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
mqt.qudits.compiler.onedit.local_phases_transpilation
ΒΆ
SubmodulesΒΆ
mqt.qudits.compiler.onedit.local_phases_transpilation.propagate_virtrz
ΒΆ
Module ContentsΒΆ
- class ZPropagationPass(backend, back=True)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.onedit.local_phases_transpilation.remove_phase_rotations
ΒΆ
Module ContentsΒΆ
- class ZRemovalPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
Package ContentsΒΆ
- class ZPropagationPass(backend, back=True)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class ZRemovalPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.onedit.mapping_aware_transpilation
ΒΆ
SubmodulesΒΆ
mqt.qudits.compiler.onedit.mapping_aware_transpilation.phy_local_adaptive_decomp
ΒΆ
Module ContentsΒΆ
- class PhyLocAdaPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.onedit.mapping_aware_transpilation.phy_local_qr_decomp
ΒΆ
Module ContentsΒΆ
- class PhyLocQRPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
Package ContentsΒΆ
- class PhyAdaptiveDecomposition(gate, graph_orig, cost_limit=(0, 0), dimension=-1, Z_prop=False)[source]ΒΆ
- class PhyLocAdaPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class PhyLocQRPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.onedit.mapping_un_aware_transpilation
ΒΆ
SubmodulesΒΆ
mqt.qudits.compiler.onedit.mapping_un_aware_transpilation.log_local_adaptive_decomp
ΒΆ
Module ContentsΒΆ
- class LogLocAdaPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.onedit.mapping_un_aware_transpilation.log_local_qr_decomp
ΒΆ
Module ContentsΒΆ
- class LogLocQRPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
Package ContentsΒΆ
- class LogAdaptiveDecomposition(gate, graph_orig, cost_limit=(0, 0), dimension=-1, Z_prop=False)[source]ΒΆ
- class LogLocAdaPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class LogLocQRPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
Package ContentsΒΆ
- class ZPropagationPass(backend, back=True)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class ZRemovalPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class PhyLocAdaPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class PhyLocQRPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class LogLocAdaPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
- class LogLocQRPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.twodit
ΒΆ
SubpackagesΒΆ
mqt.qudits.compiler.twodit.entanglement_qr
ΒΆ
SubmodulesΒΆ
mqt.qudits.compiler.twodit.entanglement_qr.crot
ΒΆ
Module ContentsΒΆ
- CEX_SEQUENCEΒΆ
mqt.qudits.compiler.twodit.entanglement_qr.log_ent_qr_cex_decomp
ΒΆ
Module ContentsΒΆ
- class LogEntQRCEXPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.compiler_pass.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.twodit.entanglement_qr.pswap
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
- class LogEntQRCEXPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.compiler_pass.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
mqt.qudits.compiler.twodit.variational_twodit_compilation
ΒΆ
SubpackagesΒΆ
mqt.qudits.compiler.twodit.variational_twodit_compilation.ansatz
ΒΆ
SubmodulesΒΆ
mqt.qudits.compiler.twodit.variational_twodit_compilation.ansatz.ansatz_gen
ΒΆ
Module ContentsΒΆ
mqt.qudits.compiler.twodit.variational_twodit_compilation.ansatz.instantiate
ΒΆ
Module ContentsΒΆ
mqt.qudits.compiler.twodit.variational_twodit_compilation.ansatz.parametrize
ΒΆ
Module ContentsΒΆ
- CUSTOM_PRIMITIVEΒΆ
- bound_1ΒΆ
- bound_2ΒΆ
- bound_3ΒΆ
Package ContentsΒΆ
mqt.qudits.compiler.twodit.variational_twodit_compilation.opt
ΒΆ
SubmodulesΒΆ
mqt.qudits.compiler.twodit.variational_twodit_compilation.opt.distance_measures
ΒΆ
FROM An alternative quantum fidelity for mixed states of qudits Xiaoguang Wang, 1, 2, * Chang-Shui Yu, 3 and x. x. Yi 3
Module ContentsΒΆ
mqt.qudits.compiler.twodit.variational_twodit_compilation.opt.optimizer
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
SubmodulesΒΆ
Package ContentsΒΆ
- class LogEntQRCEXPass(backend)[source]ΒΆ
Bases:
mqt.qudits.compiler.compiler_pass.CompilerPass
Helper class that provides a standard way to create an ABC using inheritance.
SubmodulesΒΆ
mqt.qudits.compiler.compiler_pass
ΒΆ
Module ContentsΒΆ
mqt.qudits.compiler.dit_manager
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
mqt.qudits.core
ΒΆ
Core structure used in the package.
SubmodulesΒΆ
mqt.qudits.core.dfs_tree
ΒΆ
Module ContentsΒΆ
- class Node(key, rotation, U_of_level, graph_current, current_cost, current_decomp_cost, max_cost, pi_pulses, parent_key, children=None)[source]ΒΆ
mqt.qudits.core.level_graph
ΒΆ
Module ContentsΒΆ
- class LevelGraph(edges, nodes, nodes_physical_mapping=None, initialization_nodes=None, qudit_index=None, og_circuit=None)[source]ΒΆ
Bases:
networkx.Graph
Base class for undirected graphs.
A Graph stores nodes and edges with optional data, or attributes.
Graphs hold undirected edges. Self loops are allowed but multiple (parallel) edges are not.
Nodes can be arbitrary (hashable) Python objects with optional key/value attributes, except that None is not allowed as a node.
Edges are represented as links between nodes with optional key/value attributes.
ParametersΒΆ
- incoming_graph_datainput graph (optional, default: None)
Data to initialize graph. If None (default) an empty graph is created. The data can be any format that is supported by the to_networkx_graph() function, currently including edge list, dict of dicts, dict of lists, NetworkX graph, 2D NumPy array, SciPy sparse matrix, or PyGraphviz graph.
- attrkeyword arguments, optional (default= no attributes)
Attributes to add to graph as key=value pairs.
See AlsoΒΆ
DiGraph MultiGraph MultiDiGraph
ExamplesΒΆ
Create an empty graph structure (a βnull graphβ) with no nodes and no edges.
>>> G = nx.Graph()
G can be grown in several ways.
Nodes:
Add one node at a time:
>>> G.add_node(1)
Add the nodes from any container (a list, dict, set or even the lines from a file or the nodes from another graph).
>>> G.add_nodes_from([2, 3]) >>> G.add_nodes_from(range(100, 110)) >>> H = nx.path_graph(10) >>> G.add_nodes_from(H)
In addition to strings and integers any hashable Python object (except None) can represent a node, e.g. a customized node object, or even another Graph.
>>> G.add_node(H)
Edges:
G can also be grown by adding edges.
Add one edge,
>>> G.add_edge(1, 2)
a list of edges,
>>> G.add_edges_from([(1, 2), (1, 3)])
or a collection of edges,
>>> G.add_edges_from(H.edges)
If some edges connect nodes not yet in the graph, the nodes are added automatically. There are no errors when adding nodes or edges that already exist.
Attributes:
Each graph, node, and edge can hold key/value attribute pairs in an associated attribute dictionary (the keys must be hashable). By default these are empty, but can be added or changed using add_edge, add_node or direct manipulation of the attribute dictionaries named graph, node and edge respectively.
>>> G = nx.Graph(day="Friday") >>> G.graph {'day': 'Friday'}
Add node attributes using add_node(), add_nodes_from() or G.nodes
>>> G.add_node(1, time="5pm") >>> G.add_nodes_from([3], time="2pm") >>> G.nodes[1] {'time': '5pm'} >>> G.nodes[1]["room"] = 714 # node must exist already to use G.nodes >>> del G.nodes[1]["room"] # remove attribute >>> list(G.nodes(data=True)) [(1, {'time': '5pm'}), (3, {'time': '2pm'})]
Add edge attributes using add_edge(), add_edges_from(), subscript notation, or G.edges.
>>> G.add_edge(1, 2, weight=4.7) >>> G.add_edges_from([(3, 4), (4, 5)], color="red") >>> G.add_edges_from([(1, 2, {"color": "blue"}), (2, 3, {"weight": 8})]) >>> G[1][2]["weight"] = 4.7 >>> G.edges[1, 2]["weight"] = 4
Warning: we protect the graph data structure by making G.edges a read-only dict-like structure. However, you can assign to attributes in e.g. G.edges[1, 2]. Thus, use 2 sets of brackets to add/change data attributes: G.edges[1, 2][βweightβ] = 4 (For multigraphs: MG.edges[u, v, key][name] = value).
Shortcuts:
Many common graph features allow python syntax to speed reporting.
>>> 1 in G # check if node in graph True >>> [n for n in G if n < 3] # iterate through nodes [1, 2] >>> len(G) # number of nodes in graph 5
Often the best way to traverse all edges of a graph is via the neighbors. The neighbors are reported as an adjacency-dict G.adj or G.adjacency()
>>> for n, nbrsdict in G.adjacency(): ... for nbr, eattr in nbrsdict.items(): ... if "weight" in eattr: ... # Do something useful with the edges ... pass
But the edges() method is often more convenient:
>>> for u, v, weight in G.edges.data("weight"): ... if weight is not None: ... # Do something useful with the edges ... pass
Reporting:
Simple graph information is obtained using object-attributes and methods. Reporting typically provides views instead of containers to reduce memory usage. The views update as the graph is updated similarly to dict-views. The objects nodes, edges and adj provide access to data attributes via lookup (e.g. nodes[n], edges[u, v], adj[u][v]) and iteration (e.g. nodes.items(), nodes.data(βcolorβ), nodes.data(βcolorβ, default=βblueβ) and similarly for edges) Views exist for nodes, edges, neighbors()/adj and degree.
For details on these and other miscellaneous methods, see below.
Subclasses (Advanced):
The Graph class uses a dict-of-dict-of-dict data structure. The outer dict (node_dict) holds adjacency information keyed by node. The next dict (adjlist_dict) represents the adjacency information and holds edge data keyed by neighbor. The inner dict (edge_attr_dict) represents the edge data and holds edge attribute values keyed by attribute names.
Each of these three dicts can be replaced in a subclass by a user defined dict-like object. In general, the dict-like features should be maintained but extra features can be added. To replace one of the dicts create a new graph class by changing the class(!) variable holding the factory for that dict-like structure.
- node_dict_factoryfunction, (default: dict)
Factory function to be used to create the dict containing node attributes, keyed by node id. It should require no arguments and return a dict-like object
- node_attr_dict_factory: function, (default: dict)
Factory function to be used to create the node attribute dict which holds attribute values keyed by attribute name. It should require no arguments and return a dict-like object
- adjlist_outer_dict_factoryfunction, (default: dict)
Factory function to be used to create the outer-most dict in the data structure that holds adjacency info keyed by node. It should require no arguments and return a dict-like object.
- adjlist_inner_dict_factoryfunction, (default: dict)
Factory function to be used to create the adjacency list dict which holds edge data keyed by neighbor. It should require no arguments and return a dict-like object
- edge_attr_dict_factoryfunction, (default: dict)
Factory function to be used to create the edge attribute dict which holds attribute values keyed by attribute name. It should require no arguments and return a dict-like object.
- graph_attr_dict_factoryfunction, (default: dict)
Factory function to be used to create the graph attribute dict which holds attribute values keyed by attribute name. It should require no arguments and return a dict-like object.
Typically, if your extension doesnβt impact the data structure all methods will inherit without issue except: to_directed/to_undirected. By default these methods create a DiGraph/Graph class and you probably want them to create your extension of a DiGraph/Graph. To facilitate this we define two class variables that you can set in your subclass.
- to_directed_classcallable, (default: DiGraph or MultiDiGraph)
Class to create a new graph structure in the to_directed method. If None, a NetworkX class (DiGraph or MultiDiGraph) is used.
- to_undirected_classcallable, (default: Graph or MultiGraph)
Class to create a new graph structure in the to_undirected method. If None, a NetworkX class (Graph or MultiGraph) is used.
Subclassing Example
Create a low memory graph class that effectively disallows edge attributes by using a single attribute dict for all edges. This reduces the memory used, but you lose edge attributes.
>>> class ThinGraph(nx.Graph): ... all_edge_dict = {"weight": 1} ... ... def single_edge_dict(self): ... return self.all_edge_dict ... ... edge_attr_dict_factory = single_edge_dict >>> G = ThinGraph() >>> G.add_edge(2, 1) >>> G[2][1] {'weight': 1} >>> G.add_edge(2, 2) >>> G[2][1] is G[2][2] True
- property log_phy_mapΒΆ
- __str__() str [source]ΒΆ
Returns a short summary of the graph.
ReturnsΒΆ
- infostring
Graph information including the graph name (if any), graph type, and the number of nodes and edges.
ExamplesΒΆ
>>> G = nx.Graph(name="foo") >>> str(G) "Graph named 'foo' with 0 nodes and 0 edges"
>>> G = nx.path_graph(3) >>> str(G) 'Graph with 3 nodes and 2 edges'
Package ContentsΒΆ
- class NAryTree[source]ΒΆ
- property total_sizeΒΆ
- class Node(key, rotation, U_of_level, graph_current, current_cost, current_decomp_cost, max_cost, pi_pulses, parent_key, children=None)[source]ΒΆ
- class LevelGraph(edges, nodes, nodes_physical_mapping=None, initialization_nodes=None, qudit_index=None, og_circuit=None)[source]ΒΆ
Bases:
networkx.Graph
Base class for undirected graphs.
A Graph stores nodes and edges with optional data, or attributes.
Graphs hold undirected edges. Self loops are allowed but multiple (parallel) edges are not.
Nodes can be arbitrary (hashable) Python objects with optional key/value attributes, except that None is not allowed as a node.
Edges are represented as links between nodes with optional key/value attributes.
ParametersΒΆ
- incoming_graph_datainput graph (optional, default: None)
Data to initialize graph. If None (default) an empty graph is created. The data can be any format that is supported by the to_networkx_graph() function, currently including edge list, dict of dicts, dict of lists, NetworkX graph, 2D NumPy array, SciPy sparse matrix, or PyGraphviz graph.
- attrkeyword arguments, optional (default= no attributes)
Attributes to add to graph as key=value pairs.
See AlsoΒΆ
DiGraph MultiGraph MultiDiGraph
ExamplesΒΆ
Create an empty graph structure (a βnull graphβ) with no nodes and no edges.
>>> G = nx.Graph()
G can be grown in several ways.
Nodes:
Add one node at a time:
>>> G.add_node(1)
Add the nodes from any container (a list, dict, set or even the lines from a file or the nodes from another graph).
>>> G.add_nodes_from([2, 3]) >>> G.add_nodes_from(range(100, 110)) >>> H = nx.path_graph(10) >>> G.add_nodes_from(H)
In addition to strings and integers any hashable Python object (except None) can represent a node, e.g. a customized node object, or even another Graph.
>>> G.add_node(H)
Edges:
G can also be grown by adding edges.
Add one edge,
>>> G.add_edge(1, 2)
a list of edges,
>>> G.add_edges_from([(1, 2), (1, 3)])
or a collection of edges,
>>> G.add_edges_from(H.edges)
If some edges connect nodes not yet in the graph, the nodes are added automatically. There are no errors when adding nodes or edges that already exist.
Attributes:
Each graph, node, and edge can hold key/value attribute pairs in an associated attribute dictionary (the keys must be hashable). By default these are empty, but can be added or changed using add_edge, add_node or direct manipulation of the attribute dictionaries named graph, node and edge respectively.
>>> G = nx.Graph(day="Friday") >>> G.graph {'day': 'Friday'}
Add node attributes using add_node(), add_nodes_from() or G.nodes
>>> G.add_node(1, time="5pm") >>> G.add_nodes_from([3], time="2pm") >>> G.nodes[1] {'time': '5pm'} >>> G.nodes[1]["room"] = 714 # node must exist already to use G.nodes >>> del G.nodes[1]["room"] # remove attribute >>> list(G.nodes(data=True)) [(1, {'time': '5pm'}), (3, {'time': '2pm'})]
Add edge attributes using add_edge(), add_edges_from(), subscript notation, or G.edges.
>>> G.add_edge(1, 2, weight=4.7) >>> G.add_edges_from([(3, 4), (4, 5)], color="red") >>> G.add_edges_from([(1, 2, {"color": "blue"}), (2, 3, {"weight": 8})]) >>> G[1][2]["weight"] = 4.7 >>> G.edges[1, 2]["weight"] = 4
Warning: we protect the graph data structure by making G.edges a read-only dict-like structure. However, you can assign to attributes in e.g. G.edges[1, 2]. Thus, use 2 sets of brackets to add/change data attributes: G.edges[1, 2][βweightβ] = 4 (For multigraphs: MG.edges[u, v, key][name] = value).
Shortcuts:
Many common graph features allow python syntax to speed reporting.
>>> 1 in G # check if node in graph True >>> [n for n in G if n < 3] # iterate through nodes [1, 2] >>> len(G) # number of nodes in graph 5
Often the best way to traverse all edges of a graph is via the neighbors. The neighbors are reported as an adjacency-dict G.adj or G.adjacency()
>>> for n, nbrsdict in G.adjacency(): ... for nbr, eattr in nbrsdict.items(): ... if "weight" in eattr: ... # Do something useful with the edges ... pass
But the edges() method is often more convenient:
>>> for u, v, weight in G.edges.data("weight"): ... if weight is not None: ... # Do something useful with the edges ... pass
Reporting:
Simple graph information is obtained using object-attributes and methods. Reporting typically provides views instead of containers to reduce memory usage. The views update as the graph is updated similarly to dict-views. The objects nodes, edges and adj provide access to data attributes via lookup (e.g. nodes[n], edges[u, v], adj[u][v]) and iteration (e.g. nodes.items(), nodes.data(βcolorβ), nodes.data(βcolorβ, default=βblueβ) and similarly for edges) Views exist for nodes, edges, neighbors()/adj and degree.
For details on these and other miscellaneous methods, see below.
Subclasses (Advanced):
The Graph class uses a dict-of-dict-of-dict data structure. The outer dict (node_dict) holds adjacency information keyed by node. The next dict (adjlist_dict) represents the adjacency information and holds edge data keyed by neighbor. The inner dict (edge_attr_dict) represents the edge data and holds edge attribute values keyed by attribute names.
Each of these three dicts can be replaced in a subclass by a user defined dict-like object. In general, the dict-like features should be maintained but extra features can be added. To replace one of the dicts create a new graph class by changing the class(!) variable holding the factory for that dict-like structure.
- node_dict_factoryfunction, (default: dict)
Factory function to be used to create the dict containing node attributes, keyed by node id. It should require no arguments and return a dict-like object
- node_attr_dict_factory: function, (default: dict)
Factory function to be used to create the node attribute dict which holds attribute values keyed by attribute name. It should require no arguments and return a dict-like object
- adjlist_outer_dict_factoryfunction, (default: dict)
Factory function to be used to create the outer-most dict in the data structure that holds adjacency info keyed by node. It should require no arguments and return a dict-like object.
- adjlist_inner_dict_factoryfunction, (default: dict)
Factory function to be used to create the adjacency list dict which holds edge data keyed by neighbor. It should require no arguments and return a dict-like object
- edge_attr_dict_factoryfunction, (default: dict)
Factory function to be used to create the edge attribute dict which holds attribute values keyed by attribute name. It should require no arguments and return a dict-like object.
- graph_attr_dict_factoryfunction, (default: dict)
Factory function to be used to create the graph attribute dict which holds attribute values keyed by attribute name. It should require no arguments and return a dict-like object.
Typically, if your extension doesnβt impact the data structure all methods will inherit without issue except: to_directed/to_undirected. By default these methods create a DiGraph/Graph class and you probably want them to create your extension of a DiGraph/Graph. To facilitate this we define two class variables that you can set in your subclass.
- to_directed_classcallable, (default: DiGraph or MultiDiGraph)
Class to create a new graph structure in the to_directed method. If None, a NetworkX class (DiGraph or MultiDiGraph) is used.
- to_undirected_classcallable, (default: Graph or MultiGraph)
Class to create a new graph structure in the to_undirected method. If None, a NetworkX class (Graph or MultiGraph) is used.
Subclassing Example
Create a low memory graph class that effectively disallows edge attributes by using a single attribute dict for all edges. This reduces the memory used, but you lose edge attributes.
>>> class ThinGraph(nx.Graph): ... all_edge_dict = {"weight": 1} ... ... def single_edge_dict(self): ... return self.all_edge_dict ... ... edge_attr_dict_factory = single_edge_dict >>> G = ThinGraph() >>> G.add_edge(2, 1) >>> G[2][1] {'weight': 1} >>> G.add_edge(2, 2) >>> G[2][1] is G[2][2] True
- property log_phy_mapΒΆ
- __str__() str [source]ΒΆ
Returns a short summary of the graph.
ReturnsΒΆ
- infostring
Graph information including the graph name (if any), graph type, and the number of nodes and edges.
ExamplesΒΆ
>>> G = nx.Graph(name="foo") >>> str(G) "Graph named 'foo' with 0 nodes and 0 edges"
>>> G = nx.path_graph(3) >>> str(G) 'Graph with 3 nodes and 2 edges'
mqt.qudits.exceptions
ΒΆ
Exceptions module.
SubmodulesΒΆ
mqt.qudits.exceptions.backenderror
ΒΆ
Module ContentsΒΆ
mqt.qudits.exceptions.circuiterror
ΒΆ
Module ContentsΒΆ
mqt.qudits.exceptions.compilerexception
ΒΆ
Module ContentsΒΆ
- exception NodeNotFoundException(value)[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
- exception SequenceFoundException(node_key: int = -1)[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
mqt.qudits.exceptions.joberror
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
- exception BackendNotFoundError(message: str)[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
- exception CircuitError(message: str)[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
- exception FidelityReachException(message: str = '')[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
- exception NodeNotFoundException(value)[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
- exception RoutingException[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
- exception SequenceFoundException(node_key: int = -1)[source]ΒΆ
Bases:
Exception
Common base class for all non-exit exceptions.
mqt.qudits.quantum_circuit
ΒΆ
Qudit Quantum Circuit Module.
SubpackagesΒΆ
mqt.qudits.quantum_circuit.components
ΒΆ
SubpackagesΒΆ
mqt.qudits.quantum_circuit.components.extensions
ΒΆ
SubmodulesΒΆ
mqt.qudits.quantum_circuit.components.extensions.controls
ΒΆ
Module ContentsΒΆ
mqt.qudits.quantum_circuit.components.extensions.gate_types
ΒΆ
Module ContentsΒΆ
- class GateTypes(*args, **kwds)[source]ΒΆ
Bases:
enum.Enum
Enumeration for job status.
- SINGLE = 'Single Qudit Gate'ΒΆ
- TWO = 'Two Qudit Gate'ΒΆ
- MULTI = 'Multi Qudit Gate'ΒΆ
- CORE_GATE_TYPES = ()ΒΆ
mqt.qudits.quantum_circuit.components.extensions.matrix_factory
ΒΆ
Module ContentsΒΆ
SubmodulesΒΆ
mqt.qudits.quantum_circuit.components.classic_register
ΒΆ
Module ContentsΒΆ
mqt.qudits.quantum_circuit.components.quantum_register
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
mqt.qudits.quantum_circuit.gates
ΒΆ
Instructions module.
SubmodulesΒΆ
mqt.qudits.quantum_circuit.gates.csum
ΒΆ
Module ContentsΒΆ
- class CSum(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.custom_multi
ΒΆ
Module ContentsΒΆ
- class CustomMulti(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: ndarray, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Multi body custom gate
mqt.qudits.quantum_circuit.gates.custom_one
ΒΆ
Module ContentsΒΆ
- class CustomOne(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: ndarray, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
One body custom gate
mqt.qudits.quantum_circuit.gates.custom_two
ΒΆ
Module ContentsΒΆ
- class CustomTwo(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: ndarray, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Two body custom gate
mqt.qudits.quantum_circuit.gates.cx
ΒΆ
Module ContentsΒΆ
- class CEx(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.gellmann
ΒΆ
Module ContentsΒΆ
- class GellMann(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Gate used as generator for Givens rotations.
mqt.qudits.quantum_circuit.gates.h
ΒΆ
Module ContentsΒΆ
- class H(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.ls
ΒΆ
Module ContentsΒΆ
- class LS(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.ms
ΒΆ
Module ContentsΒΆ
- class MS(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.perm
ΒΆ
Module ContentsΒΆ
- class Perm(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.r
ΒΆ
Module ContentsΒΆ
mqt.qudits.quantum_circuit.gates.randu
ΒΆ
Module ContentsΒΆ
- class RandU(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.rh
ΒΆ
Module ContentsΒΆ
- class Rh(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
SU2 Hadamard
mqt.qudits.quantum_circuit.gates.rz
ΒΆ
Module ContentsΒΆ
mqt.qudits.quantum_circuit.gates.s
ΒΆ
Module ContentsΒΆ
- class S(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.virt_rz
ΒΆ
Module ContentsΒΆ
mqt.qudits.quantum_circuit.gates.x
ΒΆ
Module ContentsΒΆ
- class X(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
mqt.qudits.quantum_circuit.gates.z
ΒΆ
Module ContentsΒΆ
- class Z(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
Package ContentsΒΆ
- class GateTypes(*args, **kwds)[source]ΒΆ
Bases:
enum.Enum
Enumeration for job status.
- SINGLE = 'Single Qudit Gate'ΒΆ
- TWO = 'Two Qudit Gate'ΒΆ
- MULTI = 'Multi Qudit Gate'ΒΆ
- class CSum(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class CustomMulti(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: ndarray, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Multi body custom gate
- class CustomOne(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: ndarray, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
One body custom gate
- class CustomTwo(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: ndarray, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Two body custom gate
- class CEx(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class GellMann(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Gate used as generator for Givens rotations.
- class H(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class LS(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class MS(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class Perm(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class R(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- property costΒΆ
- class RandU(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class Rh(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
SU2 Hadamard
- class Rz(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- property costΒΆ
- class S(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class VirtRz(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, parameters: list | None, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- property costΒΆ
- class X(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
- class Z(circuit: QuantumCircuit, name: str, target_qudits: list[int] | int, dimensions: list[int] | int, controls: ControlData | None = None)[source]ΒΆ
Bases:
mqt.qudits.quantum_circuit.gate.Gate
Unitary gate_matrix.
SubmodulesΒΆ
mqt.qudits.quantum_circuit.circuit
ΒΆ
Module ContentsΒΆ
- class QuantumCircuit(*args)[source]ΒΆ
- property num_quditsΒΆ
- property dimensionsΒΆ
- qasm_to_gate_set_dictΒΆ
- append(qreg: QuantumRegister) None [source]ΒΆ
- append_classic(creg: ClassicRegister) None [source]ΒΆ
- h(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- s(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- x(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- z(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- save_to_file(file_name: str, file_path: str = '.') str [source]ΒΆ
Save qasm into a file with the specified name and path.
mqt.qudits.quantum_circuit.gate
ΒΆ
Module ContentsΒΆ
- class Instruction(name: str)[source]ΒΆ
Bases:
abc.ABC
Helper class that provides a standard way to create an ABC using inheritance.
- class Gate(circuit: QuantumCircuit, name: str, gate_type: enum, target_qudits: list[int] | int, dimensions: list[int] | int, params: list | ndarray | None = None, control_set=None, label: str | None = None, duration=None, unit='dt')[source]ΒΆ
Bases:
Instruction
Unitary gate_matrix.
- property reference_linesΒΆ
- property get_control_linesΒΆ
- property control_infoΒΆ
- to_matrix(identities=0) ndarray [source]ΒΆ
Return a np.ndarray for the gate_matrix unitary parameters.
- Returns:
if the Gate subclass has a parameters definition.
- Return type:
np.ndarray
- Raises:
CircuitError β If a Gate subclass does not implement this method an exception will be raised when this base class method is called.
mqt.qudits.quantum_circuit.qasm
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
- class QuantumCircuit(*args)[source]ΒΆ
- property num_quditsΒΆ
- property dimensionsΒΆ
- qasm_to_gate_set_dictΒΆ
- append(qreg: QuantumRegister) None [source]ΒΆ
- append_classic(creg: ClassicRegister) None [source]ΒΆ
- h(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- s(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- x(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- z(qudit: int, controls: ControlData | None = None)[source]ΒΆ
- save_to_file(file_name: str, file_path: str = '.') str [source]ΒΆ
Save qasm into a file with the specified name and path.
- class QuantumRegister(name, size, dims=None)[source]ΒΆ
- classmethod from_map(sitemap: dict) list[QuantumRegister] [source]ΒΆ
mqt.qudits.simulation
ΒΆ
SubpackagesΒΆ
mqt.qudits.simulation.backends
ΒΆ
SubpackagesΒΆ
mqt.qudits.simulation.backends.fake_backends
ΒΆ
SubmodulesΒΆ
mqt.qudits.simulation.backends.fake_backends.fake_traps2six
ΒΆ
Module ContentsΒΆ
- class FakeIonTraps2Six(provider: mqt.qudits.simulation.qudit_provider.QuditProvider | None = None, name: str | None = None, description: str | None = None, online_date: datetime | None = None, backend_version: str | None = None, **fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.tnsim.TNSim
Helper class that provides a standard way to create an ABC using inheritance.
- property energy_level_graphs: list[LevelGraph, LevelGraph]ΒΆ
mqt.qudits.simulation.backends.fake_backends.fake_traps2three
ΒΆ
Module ContentsΒΆ
- class FakeIonTraps2Trits(provider: mqt.qudits.simulation.qudit_provider.QuditProvider | None = None, name: str | None = None, description: str | None = None, online_date: datetime | None = None, backend_version: str | None = None, **fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.tnsim.TNSim
Helper class that provides a standard way to create an ABC using inheritance.
- property energy_level_graphs: list[LevelGraph, LevelGraph]ΒΆ
Package ContentsΒΆ
- class FakeIonTraps2Six(provider: mqt.qudits.simulation.qudit_provider.QuditProvider | None = None, name: str | None = None, description: str | None = None, online_date: datetime | None = None, backend_version: str | None = None, **fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.tnsim.TNSim
Helper class that provides a standard way to create an ABC using inheritance.
- property energy_level_graphs: list[LevelGraph, LevelGraph]ΒΆ
- class FakeIonTraps2Trits(provider: mqt.qudits.simulation.qudit_provider.QuditProvider | None = None, name: str | None = None, description: str | None = None, online_date: datetime | None = None, backend_version: str | None = None, **fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.tnsim.TNSim
Helper class that provides a standard way to create an ABC using inheritance.
- property energy_level_graphs: list[LevelGraph, LevelGraph]ΒΆ
SubmodulesΒΆ
mqt.qudits.simulation.backends.backendv2
ΒΆ
Module ContentsΒΆ
- class Backend(provider: mqt.qudits.simulation.qudit_provider.QuditProvider | None = None, name: str | None = None, description: str | None = None, online_date: datetime | None = None, backend_version: str | None = None, **fields: Any)[source]ΒΆ
Bases:
abc.ABC
Helper class that provides a standard way to create an ABC using inheritance.
- abstract property energy_level_graphs: list[LevelGraph, LevelGraph]ΒΆ
- property optionsΒΆ
- property providerΒΆ
- targetΒΆ
mqt.qudits.simulation.backends.misim
ΒΆ
Module ContentsΒΆ
- class MISim(**fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.backendv2.Backend
Helper class that provides a standard way to create an ABC using inheritance.
- run(circuit: QuantumCircuit, **options) Job [source]ΒΆ
- execute(circuit: QuantumCircuit, noise_model: NoiseModel | None = None) ndarray [source]ΒΆ
mqt.qudits.simulation.backends.stochastic_sim
ΒΆ
Module ContentsΒΆ
- stochastic_simulation(backend: Backend, circuit: QuantumCircuit)[source]ΒΆ
- stochastic_simulation_misim(backend: Backend, circuit: QuantumCircuit)[source]ΒΆ
mqt.qudits.simulation.backends.tnsim
ΒΆ
Module ContentsΒΆ
- class TNSim(**fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.backendv2.Backend
Helper class that provides a standard way to create an ABC using inheritance.
- run(circuit: QuantumCircuit, **options)[source]ΒΆ
- execute(circuit: QuantumCircuit)[source]ΒΆ
Package ContentsΒΆ
- class MISim(**fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.backendv2.Backend
Helper class that provides a standard way to create an ABC using inheritance.
- run(circuit: QuantumCircuit, **options) Job [source]ΒΆ
- execute(circuit: QuantumCircuit, noise_model: NoiseModel | None = None) ndarray [source]ΒΆ
- class TNSim(**fields)[source]ΒΆ
Bases:
mqt.qudits.simulation.backends.backendv2.Backend
Helper class that provides a standard way to create an ABC using inheritance.
- run(circuit: QuantumCircuit, **options)[source]ΒΆ
- execute(circuit: QuantumCircuit)[source]ΒΆ
mqt.qudits.simulation.jobs
ΒΆ
SubmodulesΒΆ
mqt.qudits.simulation.jobs.job
ΒΆ
Module ContentsΒΆ
- class Job(backend: Backend | None, job_id: str = 'auto', **kwargs)[source]ΒΆ
Class to handle jobs
This first version of the Backend abstract class is written to be mostly backwards compatible with the legacy providers interface. This was done to ease the transition for users and provider maintainers to the new versioned providers. Expect future versions of this abstract class to change the data model and interface.
- version = 1ΒΆ
- in_final_state() bool [source]ΒΆ
Return whether the job is in a final job state such as DONE or ERROR.
- wait_for_final_state(timeout: float | None = None, wait: float = 5, callback: Callable | None = None) None [source]ΒΆ
Poll the job status until it progresses to a final state such as DONE or ERROR.
- Parameters:
timeout β Seconds to wait for the job. If None, wait indefinitely.
wait β Seconds between queries.
callback β Callback function invoked after each query.
- Raises:
JobTimeoutError β If the job does not reach a final state before the specified timeout.
mqt.qudits.simulation.jobs.job_result
ΒΆ
Module ContentsΒΆ
mqt.qudits.simulation.jobs.jobstatus
ΒΆ
Module ContentsΒΆ
- class JobStatus(*args, **kwds)[source]ΒΆ
Bases:
enum.Enum
Enumeration for job status.
- INITIALIZING = 'Initializing: Job is being initialized'ΒΆ
- QUEUED = 'Queued: Job is waiting in the queue'ΒΆ
- VALIDATING = 'Validating: Job is being validated'ΒΆ
- RUNNING = 'Running: Job is actively running'ΒΆ
- CANCELLED = 'Cancelled: Job has been cancelled'ΒΆ
- DONE = 'Done: Job has successfully run'ΒΆ
- ERROR = 'Error: Job incurred an error'ΒΆ
- JOB_FINAL_STATES = ()ΒΆ
Package ContentsΒΆ
- class Job(backend: Backend | None, job_id: str = 'auto', **kwargs)[source]ΒΆ
Class to handle jobs
This first version of the Backend abstract class is written to be mostly backwards compatible with the legacy providers interface. This was done to ease the transition for users and provider maintainers to the new versioned providers. Expect future versions of this abstract class to change the data model and interface.
- version = 1ΒΆ
- in_final_state() bool [source]ΒΆ
Return whether the job is in a final job state such as DONE or ERROR.
- wait_for_final_state(timeout: float | None = None, wait: float = 5, callback: Callable | None = None) None [source]ΒΆ
Poll the job status until it progresses to a final state such as DONE or ERROR.
- Parameters:
timeout β Seconds to wait for the job. If None, wait indefinitely.
wait β Seconds between queries.
callback β Callback function invoked after each query.
- Raises:
JobTimeoutError β If the job does not reach a final state before the specified timeout.
- class JobStatus(*args, **kwds)[source]ΒΆ
Bases:
enum.Enum
Enumeration for job status.
- INITIALIZING = 'Initializing: Job is being initialized'ΒΆ
- QUEUED = 'Queued: Job is waiting in the queue'ΒΆ
- VALIDATING = 'Validating: Job is being validated'ΒΆ
- RUNNING = 'Running: Job is actively running'ΒΆ
- CANCELLED = 'Cancelled: Job has been cancelled'ΒΆ
- DONE = 'Done: Job has successfully run'ΒΆ
- ERROR = 'Error: Job incurred an error'ΒΆ
mqt.qudits.simulation.noise_tools
ΒΆ
SubmodulesΒΆ
mqt.qudits.simulation.noise_tools.noise
ΒΆ
Module ContentsΒΆ
mqt.qudits.simulation.noise_tools.noisy_circuit_factory
ΒΆ
Module ContentsΒΆ
- class NoisyCircuitFactory(noise_model: NoiseModel, circuit: QuantumCircuit)[source]ΒΆ
Package ContentsΒΆ
- class NoisyCircuitFactory(noise_model: NoiseModel, circuit: QuantumCircuit)[source]ΒΆ
SubmodulesΒΆ
mqt.qudits.simulation.qudit_provider
ΒΆ
Module ContentsΒΆ
mqt.qudits.simulation.save_info
ΒΆ
Module ContentsΒΆ
Package ContentsΒΆ
mqt.qudits.visualisation
ΒΆ
SubmodulesΒΆ
mqt.qudits.visualisation.drawing_routines
ΒΆ
Module ContentsΒΆ
- draw_qudit_local(circuit: QuantumCircuit) None [source]ΒΆ
mqt.qudits.visualisation.mini_quantum_information
ΒΆ
Module ContentsΒΆ
- partial_trace(rho, qudits2keep, dims, optimize=False)[source]ΒΆ
Calculate the partial trace
p_a = Tr_b(p)
ParametersΒΆ
- p2D array
Matrix to trace
- qudits2keeparray
An array of indices of the spaces to keep after being traced. For instance, if the space is A x B x C x D and we want to trace out B and D, keep = [0,2]
- dimsarray
An array of the dimensions of each space. For instance, if the space is A x B x C x D, dims = [dim_A, dim_B, dim_C, dim_D]
ReturnsΒΆ
- p_a2D array
Traced matrix
mqt.qudits.visualisation.plot_information
ΒΆ
Module ContentsΒΆ
- plot_state(result: ndarray, circuit: QuantumCircuit, errors=None) None [source]ΒΆ
- plot_counts(result, circuit: QuantumCircuit) None [source]ΒΆ
Package ContentsΒΆ
- draw_qudit_local(circuit: QuantumCircuit) None [source]ΒΆ
- partial_trace(rho, qudits2keep, dims, optimize=False)[source]ΒΆ
Calculate the partial trace
p_a = Tr_b(p)
ParametersΒΆ
- p2D array
Matrix to trace
- qudits2keeparray
An array of indices of the spaces to keep after being traced. For instance, if the space is A x B x C x D and we want to trace out B and D, keep = [0,2]
- dimsarray
An array of the dimensions of each space. For instance, if the space is A x B x C x D, dims = [dim_A, dim_B, dim_C, dim_D]
ReturnsΒΆ
- p_a2D array
Traced matrix
- plot_counts(result, circuit: QuantumCircuit) None [source]ΒΆ
- plot_state(result: ndarray, circuit: QuantumCircuit, errors=None) None [source]ΒΆ