ddsim package

Submodules

ddsim.hybridqasmsimulator module

Backend for DDSIM Hybrid Schrodinger-Feynman Simulator.

class HybridQasmSimulatorBackend(name='hybrid_qasm_simulator', description='MQT DDSIM Hybrid Schrodinger-Feynman simulator')[source]

Bases: QasmSimulatorBackend

Python interface to MQT DDSIM Hybrid Schrodinger-Feynman Simulator.

property target: Target

Return the target of the backend.

ddsim.hybridstatevectorsimulator module

Backend for DDSIM Hybrid Schrodinger-Feynman Simulator.

class HybridStatevectorSimulatorBackend[source]

Bases: HybridQasmSimulatorBackend

Python interface to MQT DDSIM Hybrid Schrodinger-Feynman Simulator.

property target: Target

Return the target of the backend.

ddsim.job module

Job module for DDSIM backend.

class DDSIMJob(backend, job_id, fn, experiments, parameter_values, **args)[source]

Bases: JobV1

DDSIMJob class.

_executor

executor to handle asynchronous jobs

Type:

futures.Executor

backend()[source]

Return the instance of the backend used for this job.

Return type:

BackendV2 | None

cancel()[source]

Attempt to cancel the job.

Return type:

bool

result(timeout=None)[source]

Get job result.

The behavior is the same as the underlying concurrent Future objects, https://docs.python.org/3/library/concurrent.futures.html#future-objects.

Parameters:

timeout (float | None) – number of seconds to wait for results.

Returns:

Result – Result object

Raises:
status()[source]

Gets the status of the job by querying the Python’s future.

Returns:

JobStatus – The current JobStatus

Raises:
submit()[source]

Submit the job to the backend for execution.

Raises:

JobError – if trying to re-submit the job.

Return type:

None

requires_submit(func)[source]

Decorator to ensure that a submit has been performed before calling the method.

Parameters:

func (callable) – test function to be decorated.

Returns:

callable – the decorated function.

ddsim.pathqasmsimulator module

Backend for DDSIM Task-Based Simulator.

class PathQasmSimulatorBackend(name='path_sim_qasm_simulator', description='MQT DDSIM Simulation Path Framework')[source]

Bases: QasmSimulatorBackend

Python interface to MQT DDSIM Simulation Path Framework.

property target: Target

Return the target of the backend.

create_tensor_network(qc)[source]

Create a tensor network from a quantum circuit.

Parameters:

qc (QuantumCircuit) – The quantum circuit to be simulated.

Returns:

TensorNetwork – The tensor network representing the quantum circuit.

get_simulation_path(qc, max_time=60, max_repeats=1024, parallel_runs=1, dump_path=True, plot_ring=False)[source]

Determine a simulation path via computing a contraction path using cotengra.

Parameters:
  • qc (QuantumCircuit) – The quantum circuit to be simulated.

  • max_time (int) – The maximum time in seconds to spend on optimization.

  • max_repeats (int) – The maximum number of repetitions for optimization.

  • parallel_runs (int) – The number of parallel runs for optimization.

  • dump_path (bool) – Whether to dump the path to a file.

  • plot_ring (bool) – Whether to plot the contraction tree as a ring.

Returns:

list[tuple[int, int]] – The simulation path as a list of tuples.

read_tensor_network_file(filename)[source]

Read a tensor network from a file.

Parameters:

filename (str) – The name of the file to read the tensor network from.

Returns:

list[Tensor] – The tensor network read from the file.

ddsim.pathstatevectorsimulator module

Backend for DDSIM.

class PathStatevectorSimulatorBackend[source]

Bases: PathQasmSimulatorBackend

Python interface to MQT DDSIM Simulation Path Framework.

property target: Target

Return the target of the backend.

ddsim.provider module

Provider for DDSIM backends.

class DDSIMProvider[source]

Bases: object

Provider for DDSIM backends.

backends(name=None, filters=None, **kwargs)[source]

Return a list of backends matching the specified criteria.

Parameters:
Return type:

list[BackendV2]

get_backend(name=None, **kwargs)[source]

Return a backend matching the specified criteria.

Parameters:
  • name (str | None) – Name of the backend.

  • kwargs (Any) – Additional filtering criteria.

Return type:

BackendV2

ddsim.pyddsim module

Python interface for the MQT DDSIM quantum circuit simulator

class CircuitSimulator

Bases: pybind11_object

__init__(self: mqt.ddsim.pyddsim.CircuitSimulator, circ: object, approximation_step_fidelity: float = 1.0, approximation_steps: int = 1, approximation_strategy: str = 'fidelity', seed: int = -1) None
expectation_value(self: mqt.ddsim.pyddsim.CircuitSimulator, observable: object) float
export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.CircuitSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.CircuitSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.CircuitSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.CircuitSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.CircuitSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.CircuitSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.CircuitSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.CircuitSimulator) dict[str, str]

Get additional statistics provided by the simulator

class ConstructionMode

Bases: pybind11_object

Members:

recursive

sequential

__init__(self: mqt.ddsim.pyddsim.ConstructionMode, value: int) None
property name
recursive = <ConstructionMode.recursive: 1>
sequential = <ConstructionMode.sequential: 0>
property value
class DeterministicNoiseSimulator

Bases: pybind11_object

__init__(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, circ: object, approximation_step_fidelity: float = 1.0, approximation_steps: int = 1, approximation_strategy: str = 'fidelity', seed: int = -1, noise_effects: str = 'APD', noise_probability: float = 0.01, amp_damping_probability: float | None = 0.02, multi_qubit_gate_factor: float = 2) None
export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) dict[str, str]

Get additional statistics provided by the simulator

class HybridCircuitSimulator

Bases: pybind11_object

__init__(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, circ: object, approximation_step_fidelity: float = 1.0, approximation_steps: int = 1, approximation_strategy: str = 'fidelity', seed: int = -1, mode: mqt.ddsim.pyddsim.HybridMode = <HybridMode.amplitude: 1>, nthreads: int = 2) None
export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_final_amplitudes(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) list[complex]
get_max_matrix_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_mode(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) mqt.ddsim.pyddsim.HybridMode
get_name(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) dict[str, str]

Get additional statistics provided by the simulator

class HybridMode

Bases: pybind11_object

Members:

DD

amplitude

DD = <HybridMode.DD: 0>
__init__(self: mqt.ddsim.pyddsim.HybridMode, value: int) None
amplitude = <HybridMode.amplitude: 1>
property name
property value
class PathCircuitSimulator

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: mqt.ddsim.pyddsim.PathCircuitSimulator, circ: object, config: mqt.ddsim.pyddsim.PathSimulatorConfiguration = { “mode”: “sequential” }) -> None

  2. __init__(self: mqt.ddsim.pyddsim.PathCircuitSimulator, circ: object, mode: mqt.ddsim.pyddsim.PathSimulatorMode = <PathSimulatorMode.sequential: 0>, bracket_size: int = 2, starting_point: int = 0, gate_cost: list[int] = [], seed: int = 0) -> None

export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.PathCircuitSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.PathCircuitSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.PathCircuitSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.PathCircuitSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.PathCircuitSimulator) list[complex]

Get the state vector resulting from the simulation.

set_simulation_path(self: mqt.ddsim.pyddsim.PathCircuitSimulator, path: list[tuple[int, int]], assume_correct_order: bool = False) None
set_tolerance(self: mqt.ddsim.pyddsim.PathCircuitSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.PathCircuitSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.PathCircuitSimulator) dict[str, str]

Get additional statistics provided by the simulator

class PathSimulatorConfiguration

Bases: pybind11_object

Configuration options for the Path Simulator

__init__(self: mqt.ddsim.pyddsim.PathSimulatorConfiguration) None
property bracket_size

Size of the brackets one wants to combine

property gate_cost

A list that contains the number of gates which are considered in each step

json(self: mqt.ddsim.pyddsim.PathSimulatorConfiguration) nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>
property mode

Setting the mode used for determining a simulation path

property seed

Seed for the simulator

property starting_point

Start of the alternating or gate_cost strategy

class PathSimulatorMode

Bases: pybind11_object

Members:

sequential

pairwise_recursive

cotengra

bracket

alternating

gate_cost

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: mqt.ddsim.pyddsim.PathSimulatorMode, value: int) -> None

  2. __init__(self: mqt.ddsim.pyddsim.PathSimulatorMode, arg0: str) -> None

alternating = <PathSimulatorMode.alternating: 3>
bracket = <PathSimulatorMode.bracket: 2>
cotengra = <PathSimulatorMode.cotengra: 4>
gate_cost = <PathSimulatorMode.gate_cost: 5>
property name
pairwise_recursive = <PathSimulatorMode.pairwise_recursive: 1>
sequential = <PathSimulatorMode.sequential: 0>
property value
class StochasticNoiseSimulator

Bases: pybind11_object

__init__(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, circ: object, approximation_step_fidelity: float = 1.0, approximation_steps: int = 1, approximation_strategy: str = 'fidelity', seed: int = -1, noise_effects: str = 'APD', noise_probability: float = 0.01, amp_damping_probability: float | None = 0.02, multi_qubit_gate_factor: float = 2) None
export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) dict[str, str]

Get additional statistics provided by the simulator

class UnitarySimulator

Bases: pybind11_object

__init__(self: mqt.ddsim.pyddsim.UnitarySimulator, circ: object, approximation_step_fidelity: float = 1.0, approximation_steps: int = 1, approximation_strategy: str = 'fidelity', seed: int = -1, mode: mqt.ddsim.pyddsim.ConstructionMode = <ConstructionMode.recursive: 1>) None
construct(self: mqt.ddsim.pyddsim.UnitarySimulator) None

Construct the DD representing the unitary matrix of the circuit.

export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.UnitarySimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.UnitarySimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_construction_time(self: mqt.ddsim.pyddsim.UnitarySimulator) float
get_final_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int
get_max_matrix_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int
get_max_vector_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_mode(self: mqt.ddsim.pyddsim.UnitarySimulator) mqt.ddsim.pyddsim.ConstructionMode
get_name(self: mqt.ddsim.pyddsim.UnitarySimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.UnitarySimulator) float

Get the tolerance for the DD package.

set_tolerance(self: mqt.ddsim.pyddsim.UnitarySimulator, tol: float) None

Set the tolerance for the DD package.

statistics(self: mqt.ddsim.pyddsim.UnitarySimulator) dict[str, str]

Get additional statistics provided by the simulator

dump_tensor_network(circ: object, filename: str) None

dump a tensor network representation of the given circuit

get_matrix(sim: mqt.ddsim.pyddsim.UnitarySimulator, mat: numpy.ndarray[numpy.complex128]) None

ddsim.qasmsimulator module

Backend for DDSIM.

class QasmSimulatorBackend(name='qasm_simulator', description='MQT DDSIM QASM Simulator')[source]

Bases: BackendV2

Python interface to MQT DDSIM.

static assign_parameters(quantum_circuits, parameter_values)[source]

Assign parameter values to the circuits.

Parameters:
Returns:

list[QuantumCircuit] – The bound circuits.

Raises:

ValueError – If the number of circuits does not match the number of provided parameter sets.

property max_circuits: int | None

Return the maximum number of circuits that can be run in a single job.

run(quantum_circuits, parameter_values=None, **options)[source]

Run a quantum circuit or list of quantum circuits on the DDSIM backend.

Parameters:
Returns:

DDSIMJob – The DDSIM job

property target: Target

Return the target of the backend.

ddsim.statevectorsimulator module

Backend for DDSIM.

class StatevectorSimulatorBackend[source]

Bases: QasmSimulatorBackend

Python interface to MQT DDSIM.

property target: Target

Return the target of the backend.

ddsim.unitarysimulator module

Backend for DDSIM Unitary Simulator.

class UnitarySimulatorBackend[source]

Bases: QasmSimulatorBackend

Decision diagram-based unitary simulator.

property target: Target

Return the target of the backend.

ddsim.primitives module

Module for Qiskit Primitives.

class Estimator(options=None, abelian_grouping=False)[source]

Bases: Estimator

DDSIM implementation of qiskit’s sampler.

Code adapted from Qiskit’s BackendEstimator class.

property preprocessed_circuits: tuple[list[QuantumCircuit], list[list[QuantumCircuit]]]

Generate quantum circuits for states and observables produced by preprocessing.

Returns: Tuple: A tuple containing two entries:

  • List: Quantum circuits list entered in run() method.

  • List: Quantum circuit representations of the observables.

class Sampler(*, options=None)[source]

Bases: Sampler

Sampler implementation using QasmSimulatorBackend.

property backend: QasmSimulatorBackend

The backend used by the sampler.

property num_circuits: int

The number of circuits stored in the sampler.

Module contents

MQT DDSim Python Package.

class CircuitSimulator

Bases: pybind11_object

expectation_value(self: mqt.ddsim.pyddsim.CircuitSimulator, observable: object) float
export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.CircuitSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.CircuitSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.CircuitSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.CircuitSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.CircuitSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.CircuitSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.CircuitSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.CircuitSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.CircuitSimulator) dict[str, str]

Get additional statistics provided by the simulator

class ConstructionMode

Bases: pybind11_object

Members:

recursive

sequential

property name
recursive = <ConstructionMode.recursive: 1>
sequential = <ConstructionMode.sequential: 0>
property value
class DDSIMProvider[source]

Bases: object

Provider for DDSIM backends.

backends(name=None, filters=None, **kwargs)[source]

Return a list of backends matching the specified criteria.

Parameters:
Return type:

list[BackendV2]

get_backend(name=None, **kwargs)[source]

Return a backend matching the specified criteria.

Parameters:
  • name (str | None) – Name of the backend.

  • kwargs (Any) – Additional filtering criteria.

Return type:

BackendV2

class DeterministicNoiseSimulator

Bases: pybind11_object

export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.DeterministicNoiseSimulator) dict[str, str]

Get additional statistics provided by the simulator

class HybridCircuitSimulator

Bases: pybind11_object

export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_final_amplitudes(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) list[complex]
get_max_matrix_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_mode(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) mqt.ddsim.pyddsim.HybridMode
get_name(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.HybridCircuitSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.HybridCircuitSimulator) dict[str, str]

Get additional statistics provided by the simulator

class HybridMode

Bases: pybind11_object

Members:

DD

amplitude

DD = <HybridMode.DD: 0>
amplitude = <HybridMode.amplitude: 1>
property name
property value
class PathCircuitSimulator

Bases: pybind11_object

export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.PathCircuitSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.PathCircuitSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.PathCircuitSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.PathCircuitSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.PathCircuitSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.PathCircuitSimulator) list[complex]

Get the state vector resulting from the simulation.

set_simulation_path(self: mqt.ddsim.pyddsim.PathCircuitSimulator, path: list[tuple[int, int]], assume_correct_order: bool = False) None
set_tolerance(self: mqt.ddsim.pyddsim.PathCircuitSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.PathCircuitSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.PathCircuitSimulator) dict[str, str]

Get additional statistics provided by the simulator

class PathSimulatorConfiguration

Bases: pybind11_object

Configuration options for the Path Simulator

property bracket_size

Size of the brackets one wants to combine

property gate_cost

A list that contains the number of gates which are considered in each step

json(self: mqt.ddsim.pyddsim.PathSimulatorConfiguration) nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>
property mode

Setting the mode used for determining a simulation path

property seed

Seed for the simulator

property starting_point

Start of the alternating or gate_cost strategy

class PathSimulatorMode

Bases: pybind11_object

Members:

sequential

pairwise_recursive

cotengra

bracket

alternating

gate_cost

alternating = <PathSimulatorMode.alternating: 3>
bracket = <PathSimulatorMode.bracket: 2>
cotengra = <PathSimulatorMode.cotengra: 4>
gate_cost = <PathSimulatorMode.gate_cost: 5>
property name
pairwise_recursive = <PathSimulatorMode.pairwise_recursive: 1>
sequential = <PathSimulatorMode.sequential: 0>
property value
class StochasticNoiseSimulator

Bases: pybind11_object

export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_max_matrix_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_vector_node_count(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_name(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) float

Get the tolerance for the DD package.

get_vector(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) list[complex]

Get the state vector resulting from the simulation.

set_tolerance(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, tol: float) None

Set the tolerance for the DD package.

simulate(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator, shots: int) dict[str, int]

Simulate the circuit and return the result as a dictionary of counts.

statistics(self: mqt.ddsim.pyddsim.StochasticNoiseSimulator) dict[str, str]

Get additional statistics provided by the simulator

class UnitarySimulator

Bases: pybind11_object

construct(self: mqt.ddsim.pyddsim.UnitarySimulator) None

Construct the DD representing the unitary matrix of the circuit.

export_dd_to_graphviz_file(self: mqt.ddsim.pyddsim.UnitarySimulator, filename: str, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) None

Write a Graphviz representation of the currently stored DD to a file.

export_dd_to_graphviz_str(self: mqt.ddsim.pyddsim.UnitarySimulator, colored: bool = True, edge_labels: bool = False, classic: bool = False, memory: bool = False, format_as_polar: bool = True) str

Get a Graphviz representation of the currently stored DD.

get_active_matrix_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the number of active matrix nodes, i.e., the number of matrix DD nodes in the unique table with a non-zero reference count.

get_active_vector_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the number of active vector nodes, i.e., the number of vector DD nodes in the unique table with a non-zero reference count.

get_construction_time(self: mqt.ddsim.pyddsim.UnitarySimulator) float
get_final_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int
get_max_matrix_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the maximum number of (active) matrix nodes, i.e., the maximum number of matrix DD nodes in the unique table at any point during the simulation.

get_max_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int
get_max_vector_node_count(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the maximum number of (active) vector nodes, i.e., the maximum number of vector DD nodes in the unique table at any point during the simulation.

get_mode(self: mqt.ddsim.pyddsim.UnitarySimulator) mqt.ddsim.pyddsim.ConstructionMode
get_name(self: mqt.ddsim.pyddsim.UnitarySimulator) str

Get the name of the simulator

get_number_of_qubits(self: mqt.ddsim.pyddsim.UnitarySimulator) int

Get the number of qubits

get_tolerance(self: mqt.ddsim.pyddsim.UnitarySimulator) float

Get the tolerance for the DD package.

set_tolerance(self: mqt.ddsim.pyddsim.UnitarySimulator, tol: float) None

Set the tolerance for the DD package.

statistics(self: mqt.ddsim.pyddsim.UnitarySimulator) dict[str, str]

Get additional statistics provided by the simulator

dump_tensor_network(circ: object, filename: str) None

dump a tensor network representation of the given circuit

get_matrix(sim: mqt.ddsim.pyddsim.UnitarySimulator, mat: numpy.ndarray[numpy.complex128]) None