quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.23k stars 1.01k forks source link

random_quantum_circuit_generation.random_rotations_between_grid_interaction_layers_circuit should use device_graph instead of qubits #3833

Open mpharrigan opened 3 years ago

mpharrigan commented 3 years ago

The arguments for random_rotations_between_grid_interaction_layers_circuit combines qubits with pattern: Sequence[GridInteractionLayer] to figure out what pairs to activate.

This assumes that all neighboring GridQubits are able to be activated, which may not always be the case. It also prevents easy adaptability to other topologies or other qubit types. [Granted, this would be a little more work since GridInteractionLayer is pretty griddy, but we really only use a containment check so other types of xxInteractionLayers could be introduced]

The newer parallel-xeb fidelity code uses a device_graph argument where nodes are qubits and edges give couplable pairs. We should modify the code to accept a device graph. This can be done in a backwards compatible way by checking if qubits were passed and using cirq.contrib.routing.gridqubits_to_graph_device, which should be made faster and put into regular cirq

mpharrigan commented 3 years ago

There's also a problem if you are operating on a topology that is a subset of a grid, for example: a line. The random circuit function for cycles divisible by 4 + 1 or 2 may not add any entangling layers.

Options:

  1. have the random generation function ignore the gridinteractionlayers that don't produce interactions. This would solve the issue at hand but wouldn't produce optimal circuits if you had a line of qubits that was snaked on a diagonal or something
  2. Have a special function or pattern to do random circuits on linear topologies
  3. Have a be-all-end-all random circuit generation function that works on arbitrary planar topologies by doing edge coloring to figure out activation orders.
  4. Enforce cycles divisible by len(pattern)