qp.labs.tcdq.create_random_gates

create_random_gates(n_qubits, n_gates, min_weight=1, max_weight=2, seed=None)[source]

Generate a gate dictionary with randomly chosen qubit subsets.

Each gate acts on a uniformly random subset of qubits whose size is drawn uniformly from [min_weight, max_weight].

Parameters:
  • n_qubits (int) – Total number of qubits.

  • n_gates (int) – Number of gates (and trainable parameters) to generate.

  • min_weight (int) – Minimum number of qubits per gate. Defaults to 1.

  • max_weight (int) – Maximum number of qubits per gate. Defaults to 2.

  • seed (int) – Random seed for reproducibility. Defaults to None.

Returns:

A gate dictionary suitable for CircuitConfig.

Return type:

dict[int, list[list[int]]]

Example

>>> from pennylane.labs.tcdq import create_random_gates
>>> gates = create_random_gates(n_qubits=6, n_gates=10, max_weight=3, seed=0)
>>> len(gates)
10