VariableLocationGate

class VariableLocationGate[source]

Bases: ComposedGate

Gate that can multiplex multiple placements of another gate.

A VariableLocationGate continuously interpolates between multiple locations for another gate. To do this this composed gate becomes as large as the sum of all locations.

__init__(gate, locations, radixes=[])[source]

Create a gate that has parameterized location.

Parameters:
  • gate (Gate) – The gate to parameterize location for.

  • locations (Sequence[CircuitLocationLike]) – A sequence of locations. Each location represents a valid placement for gate.

  • radixes (Sequence[int]) – The number of orthogonal states for each qudit. Attempts to infer it from gate and locations if not specified.

Raises:

ValueError – If there are not enough locations or the locations are incorrectly sized.

Notes

The locations are calculated in their own space and are not relative to a circuit. This means you should consider the VariableLocationGate as its own circuit when deciding the locations. For example, if you want to multiplex the (2, 3) and (3, 5) placements of a CNOT on a 6-qubit circuit, then you would give the VariableLocationGate the (0, 1) and (1, 2) locations and place the VariableLocationGate on qubits (2, 3, 5) on the circuit.

Attributes

dim

The matrix dimension for this unitary.

name

The name of this gate.

num_params

The number of real parameters this unitary-valued function takes.

num_qudits

The number of qudits this unitary can act on.

qasm_name

The qasm identifier for this gate.

radixes

The number of orthogonal states for each qudit.

Methods

check_parameters(params)

Check parameters are valid and match the unitary.

get_grad([params])

Return the gradient for this gate.

get_inverse()

Return the gate's inverse as a gate.

get_inverse_params([params])

Return the parameters that invert the gate.

get_location(params)

Returns the gate's location.

get_qasm(params, location)

Returns the qasm string for this gate.

get_qasm_gate_def()

Returns a qasm gate definition block for this gate.

get_unitary([params])

Return the unitary for this gate, see Unitary for more.

get_unitary_and_grad([params])

Return the unitary and gradient for this gate.

is_constant()

Return true if this unitary doesn't take parameters.

is_differentiable()

Check if all sub gates are differentiable.

is_locally_optimizable()

Check if all sub gates are locally optimizable.

is_parameterized()

Return true if this unitary is parameterized.

is_qubit_only()

Return true if this unitary can only act on qubits.

is_qudit_only(radix)

Return true if this unitary can only act on radix-qudits.

is_qutrit_only()

Return true if this unitary can only act on qutrits.

is_self_inverse([params])

Checks whether the unitary is its own inverse.

optimize(env_matrix)

Return the optimal parameters with respect to an environment matrix.

split_params(params)

Split params into subgate params and location params.

with_all_frozen_params(params)

Freeze all of a gate's parameters so they don't change from optimization.

with_frozen_params(frozen_params)

Freeze some of a gate's parameters so they don't change from optimization.