LocalNoisePass#

class LocalNoisePass(*args, **kwargs)[source]#

Bases: TransformationPass

Transpiler pass to insert noise into a circuit.

The noise in this pass is defined by a noise function or callable with signature

def func(
    inst: Instruction,
    qubits: Optional[List[int]] = None
) -> InstructionLike:

For every instance of one of the reference instructions in a circuit the supplied function is called on that instruction and the returned noise is added to the circuit. This noise can depend on properties of the instruction it is called on (for example parameters or duration) to allow inserting parameterized noise models.

Several methods for adding the constructed errors to circuits are supported and can be set by using the method kwarg. The supported methods are

  • "append": add the return of the callable after the instruction.

  • "prepend": add the return of the callable before the instruction.

  • "replace": replace the instruction with the return of the callable.

    If the return is None, the instruction will be removed.

Initialize noise pass.

Parameters:
  • func – noise function func(inst, qubits) -> InstructionLike.

  • op_types – Optional, single or list of instruction types to apply the noise function to. If None the noise function will be applied to all instructions in the circuit.

  • method – method for inserting noise. Allow methods are ‘append’, ‘prepend’, ‘replace’.

Raises:

TranspilerError – if an invalid option is specified.

Attributes

is_analysis_pass#

Check if the pass is an analysis pass.

If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.

is_transformation_pass#

Check if the pass is a transformation pass.

If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).

Methods

__call__(circuit: QuantumCircuit, property_set: PropertySet | dict | None = None) QuantumCircuit#

Runs the pass on circuit.

Parameters:
  • circuit – The dag on which the pass is run.

  • property_set – Input/output property set. An analysis pass might change the property set in-place.

Returns:

If on transformation pass, the resulting QuantumCircuit. If analysis pass, the input circuit.

execute(passmanager_ir: PassManagerIR, state: PassManagerState, callback: Callable = None) tuple[PassManagerIR, PassManagerState]#

Execute optimization task for input Qiskit IR.

Parameters:
  • passmanager_ir – Qiskit IR to optimize.

  • state – State associated with workflow execution by the pass manager itself.

  • callback – A callback function which is caller per execution of optimization task.

Returns:

Optimized Qiskit IR and state of the workflow.

name() str#

Name of the pass.

run(dag: DAGCircuit) DAGCircuit[source]#

Run the LocalNoisePass pass on dag. :param dag: DAG to be changed.

Returns:

A changed DAG.

Raises:

TranspilerError – if generated operation is not valid.

update_status(state: PassManagerState, run_state: RunState) PassManagerState#

Update workflow status.

Parameters:
  • state – Pass manager state to update.

  • run_state – Completion status of current task.

Returns:

Updated pass manager state.