
    {	i                         S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
Jr  SS	KJr  SS
KJr  SSKJrJrJrJrJr  SSKJr  \R0                  " \5      r " S S\
5      rg)z
Aer qasm simulator backend.
    NOptions)	BackendV2   )__version__   )
AerBackendAerError)AerBackendConfiguration)target_to_backend_properties)cpp_execute_circuitsavailable_methodsavailable_devicesMAX_QUBITS_STATEVECTORBASIS_GATES)aer_controller_executec                     ^  \ rS rSrSr\r\" / SQ5      \" / SQ5      \" / SQ5      \" / SQ5      \" / SQ5      \" / SQ5      \" / S	Q5      \" / S
Q5      S.r\" \	" \S   5      R                  \S   5      R                  \S   5      R                  \S   5      R                  \S   5      R                  \S   5      R                  \S   5      5      =\S'   \S'   S\\SSSSS\" S5      SS\S   \S   / S.r/ SQrSrSrSr S*U 4S jjr\S 5       rU 4S jr\S  5       rS! rS" rS# rS$ rU 4S% jrS& rS+S' jrS( rS)r U =r!$ ),AerSimulator'   a'U  
Noisy quantum circuit simulator backend.

**Configurable Options**

The `AerSimulator` supports multiple simulation methods and
configurable options for each simulation method. These may be set using the
appropriate kwargs during initialization. They can also be set of updated
using the :meth:`set_options` method.

Run-time options may also be specified as kwargs using the :meth:`run` method.
These will not be stored in the backend and will only apply to that execution.
They will also override any previously set options.

For example, to configure a density matrix simulator with a custom noise
model to use for every execution

.. code-block:: python

    noise_model = NoiseModel.from_backend(backend)
    backend = AerSimulator(method='density_matrix',
                            noise_model=noise_model)

**Simulating an IBM Quantum Backend**

The simulator can be automatically configured to mimic an IBM Quantum backend using
the :meth:`from_backend` method. This will configure the simulator to use the
basic device :class:`NoiseModel` for that backend, and the same basis gates
and coupling map.

.. code-block:: python

    backend = AerSimulator.from_backend(backend)

**Returning the Final State**

The final state of the simulator can be saved to the returned
``Result`` object by appending the
:func:`~qiskit_aer.library.save_state` instruction to a
quantum circuit. The format of the final state will depend on the
simulation method used. Additional simulation data may also be saved
using the other save instructions in :mod:`qiskit.provider.aer.library`.

**Simulation Method Option**

The simulation method is set using the ``method`` kwarg. A list supported
simulation methods can be returned using :meth:`available_methods`, these
are

* ``"automatic"``: Default simulation method. Select the simulation
  method automatically based on the circuit and noise model.

* ``"statevector"``: A dense statevector simulation that can sample
  measurement outcomes from *ideal* circuits with all measurements at
  end of the circuit. For noisy simulations each shot samples a
  randomly sampled noisy circuit from the noise model.

* ``"density_matrix"``: A dense density matrix simulation that may
  sample measurement outcomes from *noisy* circuits with all
  measurements at end of the circuit.

* ``"stabilizer"``: An efficient Clifford stabilizer state simulator
  that can simulate noisy Clifford circuits if all errors in the noise
  model are also Clifford errors.

* ``"extended_stabilizer"``: An approximate simulated for Clifford + T
  circuits based on a state decomposition into ranked-stabilizer state.
  The number of terms grows with the number of non-Clifford (T) gates.

* ``"matrix_product_state"``: A tensor-network statevector simulator that
  uses a Matrix Product State (MPS) representation for the state. This
  can be done either with or without truncation of the MPS bond dimensions
  depending on the simulator options. The default behaviour is no
  truncation.

* ``"unitary"``: A dense unitary matrix simulation of an ideal circuit.
  This simulates the unitary matrix of the circuit itself rather than
  the evolution of an initial quantum state. This method can only
  simulate gates, it does not support measurement, reset, or noise.

* ``"superop"``: A dense superoperator matrix simulation of an ideal or
  noisy circuit. This simulates the superoperator matrix of the circuit
  itself rather than the evolution of an initial quantum state. This method
  can simulate ideal and noisy gates, and reset, but does not support
  measurement.

* ``"tensor_network"``: A tensor-network based simulation that supports
  both statevector and density matrix. Currently there is only available
  for GPU and accelerated by using cuTensorNet APIs of cuQuantum.

**GPU Simulation**

By default all simulation methods run on the CPU, however select methods
also support running on a GPU if qiskit-aer was installed with GPU support
on a compatible NVidia GPU and CUDA version.

+--------------------------+---------------+
| Method                   | GPU Supported |
+==========================+===============+
| ``automatic``            | Sometimes     |
+--------------------------+---------------+
| ``statevector``          | Yes           |
+--------------------------+---------------+
| ``density_matrix``       | Yes           |
+--------------------------+---------------+
| ``stabilizer``           | No            |
+--------------------------+---------------+
| ``matrix_product_state`` | No            |
+--------------------------+---------------+
| ``extended_stabilizer``  | No            |
+--------------------------+---------------+
| ``unitary``              | Yes           |
+--------------------------+---------------+
| ``superop``              | No            |
+--------------------------+---------------+
| ``tensor_network``       | Yes(GPU only) |
+--------------------------+---------------+

Running a GPU simulation is done using ``device="GPU"`` kwarg during
initialization or with :meth:`set_options`. The list of supported devices
for the current system can be returned using :meth:`available_devices`.

For multiple shots simulation, OpenMP threads should be exploited for
multi-GPUs. Number of GPUs used for multi-shots is reported in
metadata ``gpu_parallel_shots_`` or is batched execution is done reported
in metadata ``batched_shots_optimization_parallel_gpus``.
For large qubits circuits with multiple GPUs, number of GPUs is reported
in metadata ``chunk_parallel_gpus`` in ``cacheblocking``.

If AerSimulator is built with cuStateVec support, cuStateVec APIs are enabled
by setting ``cuStateVec_enable=True``.

* ``target_gpus`` (list): List of GPU's IDs starting from 0 sets
  the target GPUs used for the simulation.
  If this option is not specified, all the available GPUs are used for
  chunks/shots distribution.

**Additional Backend Options**

The following simulator specific backend options are supported

* ``method`` (str): Set the simulation method (Default: ``"automatic"``).
  Use :meth:`available_methods` to return a list of all availabe methods.

* ``device`` (str): Set the simulation device (Default: ``"CPU"``).
  Use :meth:`available_devices` to return a list of devices supported
  on the current system.

* ``precision`` (str): Set the floating point precision for
  certain simulation methods to either ``"single"`` or ``"double"``
  precision (default: ``"double"``).

* ``executor`` (futures.Executor or None): Set a custom executor for
  asynchronous running of simulation jobs (Default: None).

* ``max_job_size`` (int or None): If the number of run circuits
  exceeds this value simulation will be run as a set of of sub-jobs
  on the executor. If ``None`` simulation of all circuits are submitted
  to the executor as a single job (Default: None).

* ``max_shot_size`` (int or None): If the number of shots of a noisy
  circuit exceeds this value simulation will be split into multi
  circuits for execution and the results accumulated. If ``None``
  circuits will not be split based on shots. When splitting circuits
  use the ``max_job_size`` option to control how these split circuits
  should be submitted to the executor (Default: None).

  a noise model exceeds this value simulation will be splitted into
  sub-circuits. If ``None``  simulator does noting (Default: None).

* ``enable_truncation`` (bool): If set to True this removes unnecessary
  qubits which do not affect the simulation outcome from the simulated
  circuits (Default: True).

* ``zero_threshold`` (double): Sets the threshold for truncating
  small values to zero in the result data (Default: 1e-10).

* ``validation_threshold`` (double): Sets the threshold for checking
  if initial states are valid (Default: 1e-8).

* ``max_parallel_threads`` (int): Sets the maximum number of CPU
  cores used by OpenMP for parallelization. If set to 0 the
  maximum will be set to the number of CPU cores (Default: 0).

* ``max_parallel_experiments`` (int): Sets the maximum number of
  experiments that may be executed in parallel up to the
  max_parallel_threads value. If set to 1 parallel circuit
  execution will be disabled. If set to 0 the maximum will be
  automatically set to max_parallel_threads (Default: 1).

* ``max_parallel_shots`` (int): Sets the maximum number of
  shots that may be executed in parallel during each experiment
  execution, up to the max_parallel_threads value. If set to 1
  parallel shot execution will be disabled. If set to 0 the
  maximum will be automatically set to max_parallel_threads.
  Note that this cannot be enabled at the same time as parallel
  experiment execution (Default: 0).

* ``max_memory_mb`` (int): Sets the maximum size of memory
  to store quantum states. If quantum states need more, an error
  is thrown unless -1 is set. In general, a state vector of n-qubits
  uses 2^n complex values (16 Bytes).
  If set to 0, the maximum will be automatically set to
  the system memory size (Default: 0).

* ``cuStateVec_enable`` (bool): This option enables accelerating by
  cuStateVec library of cuQuantum from NVIDIA, that has highly optimized
  kernels for GPUs (Default: False). This option will be ignored
  if AerSimulator is not built with cuStateVec support.

* ``blocking_enable`` (bool): This option enables parallelization with
  multiple GPUs or multiple processes with MPI (CPU/GPU). This option
  is only available for ``"statevector"``, ``"density_matrix"`` and
  ``"unitary"`` (Default: False).

* ``blocking_qubits`` (int): Sets the number of qubits of chunk size
  used for parallelizing with multiple GPUs or multiple processes with
  MPI (CPU/GPU). 16*2^blocking_qubits should be less than 1/4 of the GPU
  memory in double precision. This option is only available for
  ``"statevector"``, ``"density_matrix"`` and ``"unitary"``.
  This option should be set when using option ``blocking_enable=True``
  (Default: 0).
  If multiple GPUs are used for parallelization number of GPUs is
  reported to ``chunk_parallel_gpus`` in ``cacheblocking`` metadata.

* ``chunk_swap_buffer_qubits`` (int): Sets the number of qubits of
  maximum buffer size (=2^chunk_swap_buffer_qubits) used for multiple
  chunk-swaps over MPI processes. This parameter should be smaller than
  ``blocking_qubits`` otherwise multiple chunk-swaps is disabled.
  ``blocking_qubits`` - ``chunk_swap_buffer_qubits`` swaps are applied
  at single all-to-all communication. (Default: 15).

* ``batched_shots_gpu`` (bool): This option enables batched execution
  of multiple shot simulations on GPU devices for GPU enabled simulation
  methods. This optimization is intended for statevector simulations with
  noise models, or statevecor and density matrix simulations with
  intermediate measurements and can greatly accelerate simulation time
  on GPUs. If there are multiple GPUs on the system, shots are distributed
  automatically across available GPUs. Also this option distributes multiple
  shots to parallel processes of MPI (Default: False).
  If multiple GPUs are used for batched exectuion number of GPUs is
  reported to ``batched_shots_optimization_parallel_gpus`` metadata.
  ``cuStateVec_enable`` is not supported for this option.

* ``batched_shots_gpu_max_qubits`` (int): This option sets the maximum
  number of qubits for enabling the ``batched_shots_gpu`` option. If the
  number of active circuit qubits is greater than this value batching of
  simulation shots will not be used. (Default: 16).

* ``num_threads_per_device`` (int): This option sets the number of
  threads per device. For GPU simulation, this value sets number of
  threads per GPU. This parameter is used to optimize Pauli noise
  simulation with multiple-GPUs (Default: 1).

* ``shot_branching_enable`` (bool): This option enables/disables
  applying shot-branching technique to speed up multi-shots of dynamic
  circutis simulations or circuits simulations with noise models.
  (Default: False).
  Starting from single state shared with multiple shots and
  state will be branched dynamically at runtime.
  This option can decrease runs of shots if there will be less branches
  than number of total shots.
  This option is available for ``"statevector"``, ``"density_matrix"``
  and ``"tensor_network"``.
  WARNING: `shot_branching` option is unstable on MacOS currently

* ``shot_branching_sampling_enable`` (bool): This option enables/disables
  applying sampling measure if the input circuit has all the measure
  operations at the end of the circuit. (Default: False).
  Because measure operation branches state into 2 states, it is not
  efficient to apply branching for measure.
  Sampling measure improves speed to get counts for multiple-shots
  sharing the same state.
  Note that the counts obtained by sampling measure may not be as same as
  the counts calculated by multiple measure operations,
  becuase sampling measure takes only one randome number per shot.
  This option is available for ``"statevector"``, ``"density_matrix"``
  and ``"tensor_network"``.

* ``accept_distributed_results`` (bool): This option enables storing
  results independently in each process (Default: None).

* ``runtime_parameter_bind_enable`` (bool): If this option is True
  parameters are bound at runtime by using multi-shots without constructing
  circuits for each parameters. For GPU this option can be used with
  ``batched_shots_gpu`` to run with multiple parameters in a batch.
  (Default: False).

These backend options only apply when using the ``"statevector"``
simulation method:

* ``statevector_parallel_threshold`` (int): Sets the threshold that
  the number of qubits must be greater than to enable OpenMP
  parallelization for matrix multiplication during execution of
  an experiment. If parallel circuit or shot execution is enabled
  this will only use unallocated CPU cores up to
  max_parallel_threads. Note that setting this too low can reduce
  performance (Default: 14).

* ``statevector_sample_measure_opt`` (int): Sets the threshold that
  the number of qubits must be greater than to enable a large
  qubit optimized implementation of measurement sampling. Note
  that setting this two low can reduce performance (Default: 10)

These backend options only apply when using the ``"stabilizer"``
simulation method:

* ``stabilizer_max_snapshot_probabilities`` (int): set the maximum
  qubit number for the :class:`~qiskit_aer.library.SaveProbabilities` instruction (Default: 32).

These backend options only apply when using the ``"extended_stabilizer"``
simulation method:

* ``extended_stabilizer_sampling_method`` (string): Choose how to simulate
  measurements on qubits. The performance of the simulator depends
  significantly on this choice. In the following, let n be the number of
  qubits in the circuit, m the number of qubits measured, and S be the
  number of shots (Default: resampled_metropolis).

  - ``"metropolis"``: Use a Monte-Carlo method to sample many output
    strings from the simulator at once. To be accurate, this method
    requires that all the possible output strings have a non-zero
    probability. It will give inaccurate results on cases where
    the circuit has many zero-probability outcomes.
    This method has an overall runtime that scales as n^{2} + (S-1)n.

  - ``"resampled_metropolis"``: A variant of the metropolis method,
    where the Monte-Carlo method is reinitialised for every shot. This
    gives better results for circuits where some outcomes have zero
    probability, but will still fail if the output distribution
    is sparse. The overall runtime scales as Sn^{2}.

  - ``"norm_estimation"``: An alternative sampling method using
    random state inner products to estimate outcome probabilities. This
    method requires twice as much memory, and significantly longer
    runtimes, but gives accurate results on circuits with sparse
    output distributions. The overall runtime scales as Sn^{3}m^{3}.

* ``extended_stabilizer_metropolis_mixing_time`` (int): Set how long the
  monte-carlo method runs before performing measurements. If the
  output distribution is strongly peaked, this can be decreased
  alongside setting extended_stabilizer_disable_measurement_opt
  to True (Default: 5000).

* ``extended_stabilizer_approximation_error`` (double): Set the error
  in the approximation for the extended_stabilizer method. A
  smaller error needs more memory and computational time
  (Default: 0.05).

* ``extended_stabilizer_norm_estimation_samples`` (int): The default number
  of samples for the norm estimation sampler. The method will use the
  default, or 4m^{2} samples where m is the number of qubits to be
  measured, whichever is larger (Default: 100).

* ``extended_stabilizer_norm_estimation_repetitions`` (int): The number
  of times to repeat the norm estimation. The median of these reptitions
  is used to estimate and sample output strings (Default: 3).

* ``extended_stabilizer_parallel_threshold`` (int): Set the minimum
  size of the extended stabilizer decomposition before we enable
  OpenMP parallelization. If parallel circuit or shot execution
  is enabled this will only use unallocated CPU cores up to
  max_parallel_threads (Default: 100).

* ``extended_stabilizer_probabilities_snapshot_samples`` (int): If using
  the metropolis or resampled_metropolis sampling method, set the number of
  samples used to estimate probabilities in a probabilities snapshot
  (Default: 3000).

These backend options only apply when using the ``matrix_product_state``
simulation method:

* ``matrix_product_state_max_bond_dimension`` (int): Sets a limit
  on the number of Schmidt coefficients retained at the end of
  the svd algorithm. Coefficients beyond this limit will be discarded.
  (Default: None, i.e., no limit on the bond dimension).

* ``matrix_product_state_truncation_threshold`` (double):
  Discard the smallest coefficients for which the sum of
  their squares is smaller than this threshold.
  (Default: 1e-16).

* ``mps_sample_measure_algorithm`` (str): Choose which algorithm to use for
  ``"sample_measure"`` (Default: "mps_apply_measure").

  - ``mps_probabilities``: This method first constructs the probability
    vector and then generates a sample per shot. It is more efficient for
    a large number of shots and a small number of qubits, with complexity
    O(2^n * n * D^2) to create the vector and O(1) per shot, where n is
    the number of qubits and D is the bond dimension.

  - ``mps_apply_measure``: This method creates a copy of the mps structure
    and measures directly on it. It is more efficient for a small number of
    shots, and a large number of qubits, with complexity around
    O(n * D^2) per shot.

* ``mps_log_data`` (bool): if True, output logging data of the MPS
  structure: bond dimensions and values discarded during approximation.
  (Default: False)

* ``mps_swap_direction`` (str): Determine the direction of swapping the
  qubits when internal swaps are inserted for a 2-qubit gate.
  Possible values are "mps_swap_right" and "mps_swap_left".
  (Default: "mps_swap_left")

* ``chop_threshold`` (float): This option sets a threshold for
  truncating snapshots (Default: 1e-8).

* ``mps_parallel_threshold`` (int): This option sets OMP number threshold (Default: 14).

* ``mps_omp_threads`` (int): This option sets the number of OMP threads (Default: 1).

* ``mps_lapack`` (bool): This option indicates to compute the SVD function
  using OpenBLAS/Lapack interface (Default: False).

These backend options only apply when using the ``tensor_network``
simulation method:

* ``tensor_network_num_sampling_qubits`` (int): is used to set number
  of qubits to be sampled in single tensor network contraction when
  using sampling measure. (Default: 10)

* ``use_cuTensorNet_autotuning`` (bool): enables auto tuning of plan
  in cuTensorNet API. It takes some time for tuning, so enable if the
  circuit is very large. (Default: False)

These backend options apply in circuit optimization passes:

* ``fusion_enable`` (bool): Enable fusion optimization in circuit
  optimization passes [Default: True]
* ``fusion_verbose`` (bool): Output gates generated in fusion optimization
  into metadata [Default: False]
* ``fusion_max_qubit`` (int): Maximum number of qubits for a operation generated
  in a fusion optimization. A default value (``None``) automatically sets a value
  depending on the simulation method: [Default: None]
* ``fusion_threshold`` (int): Threshold that number of qubits must be greater
  than or equal to enable fusion optimization. A default value automatically sets
  a value depending on the simulation method [Default: None]

``fusion_enable`` and ``fusion_threshold`` are set as follows if their default
values (``None``) are configured:

+--------------------------+----------------------+----------------------+
| Method                   | ``fusion_max_qubit`` | ``fusion_threshold`` |
+==========================+======================+======================+
| ``statevector``          | 5                    | 14                   |
+--------------------------+----------------------+----------------------+
| ``density_matrix``       | 2                    | 7                    |
+--------------------------+----------------------+----------------------+
| ``unitary``              | 5                    | 7                    |
+--------------------------+----------------------+----------------------+
| ``superop``              | 2                    | 7                    |
+--------------------------+----------------------+----------------------+
| other methods            | 5                    | 14                   |
+--------------------------+----------------------+----------------------+

)quantum_channel
qerror_locroerrorkraussave_expvalsave_expval_varsave_probabilitiessave_probabilities_dictsave_amplitudessave_amplitudes_sqsave_density_matrix
save_statesave_statevectorsave_statevector_dictset_statevectorif_elsefor_loop
while_loop
break_loopcontinue_loop
initializeresetswitch_casedelay)r   r   r   r   superopr!   r   r   r   r   r    r   set_density_matrixr%   r&   r'   r(   r)   r+   r,   r-   )r   r   r   r   r   r   r   r   r!   save_matrix_product_stater"   r    r   r   set_matrix_product_stater%   r&   r'   r(   r)   r*   r+   r,   r-   )r   r   r   r   r   r   r   r   r!   save_cliffordsave_stabilizerset_stabilizerr%   r&   r'   r(   r)   r+   r,   r-   )r   r   r   r"   r+   r-   )r!   save_unitaryset_unitaryr+   r-   )	r   r   r   r.   r!   save_superopset_superopr+   r-   )r   r   r   r   r.   r!   r   r   r   r   r    r   r   r"   r#   r$   r/   r*   r+   r,   r-   )statevectordensity_matrixmatrix_product_state
stabilizerextended_stabilizerunitaryr.   tensor_networkr9   r<   r:   r;   r>   r.   r?   N	automaticaer_simulatorz$https://github.com/Qiskit/qiskit-aerT    .AzA C++ Qasm simulator with noise)backend_namebackend_versionn_qubitsurl	simulatorlocalconditionalmemory	max_shotsdescriptioncoupling_mapbasis_gatescustom_instructionsgates)	r@   r9   r:   r<   r;   r=   r>   r.   r?   )CPUGPUThrustc                   > [        5       U l        [        R                  c  [	        U R                  5      [        l        [        R
                  c1  [        [        R                  [        R                  5      [        l        Uc$  [        R                  " [        R                  5      nSUR                  ;  ay  SnSnUR                  5        H  u  pUS:X  a  U	nUS:X  d  M  U	nM     US;  a  U=R                  SU 3-  sl        US;  a&  U=R                  SU 3R                  5       -  sl        U R                  S   U l        [         T
U ]E  UUUUUS	9  S
UR                  5       ;   a  U R%                  US
   5        g g )Nfromr@   rQ   methoddevice)Nr@   _)NrQ   )
propertiesprovidertargetbackend_optionsrN   )r   _controllerr   _AVAILABLE_DEVICESr   _AVAILABLE_METHODSr   _SIMULATION_METHODSr   	from_dict_DEFAULT_CONFIGURATIONrC   itemslower_BASIS_GATES_cached_basis_gatessuper__init___check_basis_gates)selfconfigurationrY   rZ   r[   r\   rV   rW   keyvalue	__class__s             [/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_aer/backends/aer_simulator.pyrh   AerSimulator.__init__  sk    23 **2.?@P@P.QL+**2.?00,2Q2Q/L+
  3==l>a>abM 333 FF-335
(?"F(?"F	 6
 00**&l:*]***&l.@.@.BB* $(#4#4[#A !+ 	 	
 O1133##OM$BC 4    c                 R   [        SL0 SS_SS_SS_SS_S	S _S
S _SS _SS_SS_SS _SS _SS _SS _SS _SS_SS_SS _SS _SS _SS _SS _SS _SS_SS _S S_S!S _S"S_S#S$_S%S&_S'S_S(S_S)S*_S+S,_S-S._S/S0_S1S2_S3S4_S5S6_S7S8_S9S6_S:S;_S<S=_S>S _S?S@_SAS_SBSC_SDSE_SFS*_SGS&_SHS_SIS,_SJS_SKS_6$ )MNshotsi   rV   r@   rW   rQ   	precisiondoubleexecutormax_job_sizemax_shot_sizeenable_truncationTzero_thresholdg|=validation_thresholdmax_parallel_threadsmax_parallel_experimentsmax_parallel_shotsmax_memory_mbfusion_enablefusion_verboseFfusion_max_qubitfusion_thresholdaccept_distributed_resultsrJ   noise_modelseed_simulatorcuStateVec_enableblocking_qubitsblocking_enablechunk_swap_buffer_qubitsbatched_shots_gpubatched_shots_gpu_max_qubits   num_threads_per_devicer   shot_branching_enableshot_branching_sampling_enablestatevector_parallel_threshold   statevector_sample_measure_opt
   %stabilizer_max_snapshot_probabilities    #extended_stabilizer_sampling_methodresampled_metropolis*extended_stabilizer_metropolis_mixing_timei  'extended_stabilizer_approximation_errorg?+extended_stabilizer_norm_estimation_samplesd   /extended_stabilizer_norm_estimation_repetitions   &extended_stabilizer_parallel_threshold2extended_stabilizer_probabilities_snapshot_samplesi  )matrix_product_state_truncation_thresholdgؗҜ<'matrix_product_state_max_bond_dimensionmps_sample_measure_algorithmmps_heuristicmps_log_datamps_swap_directionmps_swap_leftchop_thresholdg:0yE>mps_parallel_thresholdmps_omp_threads
mps_lapack"tensor_network_num_sampling_qubitsuse_cuTensorNet_autotuningruntime_parameter_bind_enable r   )clss    ro   _default_optionsAerSimulator._default_options  s    A
A
 A
 	A

 A
 A
 A
 A
 #A
 !A
 "&A
 "&A
 &*A
  $A
 A
  !A
" !#A
$ "%A
& "'A
( (,)A
* +A
, -A
.  /A
2 $3A
6 !7A
8 "9A
: &*;A
> $?A
@ *,AA
B $%CA
F #(GA
H ,1IA
L ,.MA
N ,.OA
R 35SA
V 1GWA
X 8<YA
Z 59[A
\ 9<]A
^ =>_A
` 47aA
b @DcA
f 7<gA
h 59iA
j *9kA
l mA
n  /oA
p  qA
r $&sA
t uA
v wA
z 02{A
| (-}A
@ +0AA
 A	
rq   c                    > [         TU ]  5       n[        U R                  SS5      nUb  UR	                  5       (       a  U$ S[        U R                  R                  5      S-   -  nUSS  SU S[        U5       S3$ )	z)String representation of an AerSimulator.r   N r   
znoise_model=))	rg   __repr__getattroptionsis_ideallenrn   __name__repr)rj   displayr   padrn   s       ro   r   AerSimulator.__repr__;  s~    '"$dllM4@+"6"6"8"8NS001A56#2,r#l43D2EQGGrq   c                 @   [        U[        5      (       a  UR                  c  SnOUR                  n[        SUR                   S3UR
                  UR                  UR                  / [        S5      [        UR                  R                  5       5      UR                  US9	n[        UR                  5      nUR                  nO[        S[!        U5       S35      eSU;  a0  S	S
KJn  UR'                  U5      nUR)                  5       (       d  XS'   U " SXEUS.UD6n	U	$ )z"Initialize simulator from backend.z$created by AerSimulator.from_backendzaer_simulator_from(r   rB   )	rC   rD   rE   rN   rP   rK   rM   max_experimentsrL   z8The backend argument requires a BackendV2 object, not a z objectr   r   )
NoiseModel)rk   rY   r[   r   )
isinstancer   rL   r   namerD   
num_qubitsoperation_namesintlistrM   	get_edgesmax_circuitsr   r[   	TypeErrortypenoise.noise_modelr   from_backendr   )
r   backendr   rL   rk   rY   r[   r   r   sims
             ro   r   AerSimulator.from_backendD  s    gy))""*D%11327<<.B ' 7 7 ++#33c(!'"6"6"@"@"BC ' 4 4'
M 6gnnEJ^^FMdSZm_\cd  ' 7$11':K'')))4& _V_W^_
rq   c                 B    [         R                   " U R                  5      $ )(Return the available simulation methods.)copyr_   rj   s    ro   r   AerSimulator.available_methodsl  s    yy0011rq   c                 h    SU R                   ;   a  S/$ [        R                  " U R                  5      $ )r   _gpurR   )r   r   r^   r   s    ro   r   AerSimulator.available_devicesp  s*    TYY7Nyy0011rq   c                 6   [         R                   " U R                  5      nU R                  R                  5        H  u  p#[	        XU5        M     [        U R                  SS5      nU R                  U   Ul        U R                  UR                  -   Ul
        U$ )zsReturn the simulator backend configuration.

Returns:
    BackendConfiguration: the configuration for the backend.
rV   r@   )r   _configuration_options_configurationrc   setattrr   r   _CUSTOM_INSTRrO   rf   rN   )rj   configrl   valrV   s        ro   rk   AerSimulator.configurationv  s     4../3399;HCF% < x= &*%7%7%?"!558R8RRrq   c                 4    [        U R                  XU5      nU$ )z Execute circuits on the backend.)r   r]   )rj   aer_circuitsr   r   rets        ro   _execute_circuitsAerSimulator._execute_circuits  s    "4#3#3\PVW
rq   c                 >  > US:X  a  U R                  X5        g US:X  aF  Ub2  X R                  5       ;  a  [        SU SU R                  5        35      eU R                  U5        US:X  a  U R	                  U5        [
        TU ]  X5        US;   a  U R                  5       U l        US;   a  SU R                  ;  a  US:X  ah  S	U l	        US
:w  a[  U =R                  SU 3-  sl	        [        U R                  SS5      nUS:w  a&  U =R                  SU 3R                  5       -  sl	        US:X  ak  [        U R                  SS5      nS	U l	        US
:w  aF  U =R                  SU 3-  sl	        US:w  a'  U =R                  SU 3R                  5       -  sl	        g g g g g g )NrO   rV   zInvalid simulation method z. Available methods are: rN   )rV   r   rN   )rV   rW   rU   rA   r@   rX   rW   rQ   auto)_set_configuration_optionr   r
   _set_method_configri   rg   
set_option_basis_gatesrf   r   r   r   rd   )rj   rl   rm   rW   rV   rn   s        ro   r   AerSimulator.set_option  s   ''**36(? U2H2H2J%J0 8!33568  ##E*-##E*3&::'+'8'8':D$ &&TYY&(? /DI+		q[0	!(x!G!U? II1VH););)==I(?$T\\8VDF /DI,		q\1	 E> II1UG):):)<<I * - # ' 'rq   c                    SU R                   ;   a  U R                   S   $ [        U R                  SS5      nU R                  U   nU R                  R
                  nU(       a  [        U5      R                  U5      nOUn[        U R                  SS5      nU(       a  UR
                  nUR                  U5      nOSnU(       d  [        R                  SUUU5        [        U5      $ )zReturn simulator basis gates.

This will be the option value of basis gates if it was set,
otherwise it will be the intersection of the configuration, noise model
and method supported basis gates.
rN   rV   r@   r   NzThe intersection of configuration basis gates (%s), simulation method basis gates (%s), and noise model basis gates (%s) is empty)r   r   _optionsre   r   rN   setintersectionr   loggerwarningsorted)rj   rV   method_gatesconfig_gatesrN   r   noise_gatess          ro   r   AerSimulator._basis_gates  s     D777..}== +>((0**66l+88FK&K dllM4@%11K%22;?KKNN8  k""rq   c                    US:X  a	  Sn[         nO[US:X  a  Sn[         S-  nOIUS:X  a  Sn[         S-  nO7US:X  a  S	n[         S
-  nO%US:X  a  SnSnOUS:X  a  SnSnOUS:X  a  SnSnOSnSnU R                  R                  (       a9  [        [	        [        [        U R                  R                  5      5      5      S-   nU R                  SU5        U R                  SU5        g)z.Set non-basis gate options when setting methodr9   z&A C++ statevector simulator with noiser:   z)A C++ density matrix simulator with noiser   r>   zA C++ unitary matrix simulatorr.   z)A C++ superop matrix simulator with noise   r;   z/A C++ matrix product state simulator with noise?   r<   z.A C++ Clifford stabilizer simulator with noisei'  r=   z9A C++ Clifford+T extended stabilizer simulator with noiseNr   rL   rE   )r   r   rM   maxr   mapr   )rj   rV   rL   rE   s       ro   r   AerSimulator._set_method_config  s     ]"BK-H''EK-2Hy :K-2Hy EK-2H--KKH|#JKH,,UKH KH++4C)<)<)I)I JKLqPH&&}kB&&z8<rq   c                     [        U R                  SS5      nUS:w  a.  U H'  nX0R                  U   ;  d  M  [        SU SU S35      e   g g )NrV   r@   zInvalid gate z for simulation method .)r   r   re   r
   )rj   rN   rV   gates       ro   ri   AerSimulator._check_basis_gates  sY    x=[ #0088"]4&8OPVxWX#YZZ $ !rq   )rf   r]   r   )NNNN)N)"r   
__module____qualname____firstlineno____doc__r   re   r   r   r   unionr   r   r   rb   r`   r_   _SIMULATION_DEVICESr^   rh   classmethodr   r   r   r   r   rk   r   r   r   r   ri   __static_attributes____classcell__)rn   s   @ro   r   r   '   s   HT L 
8 !
2 !'!
8 
0  &	 
 
 

 !
UcMN 8>M-()	}\*	+	}-.	/	}34	5	}Y'	(	}Y'	(	}-.	/8 M$-4 (&*5X8";/,[9"
 2 JN,D\ B
 B
HH % %N22$
"=H%#N!=F[ [rq   r   )r  r   loggingqiskit.providers.optionsr   qiskit.providers.backendr   versionr   
aerbackendr	   r
   backendconfigurationr   backendpropertiesr   backend_utilsr   r   r   r   r   controller_wrappersr   	getLoggerr   r   r   r   rq   ro   <module>r     sS      , . ! , 9 ;  8			8	$Z[: Z[rq   