Create a FAST Gate Selector

Goal

Construct a FAST gate selector for iterative/adaptive VQE, optionally configuring its metric, sampler, number of shots, and selector options. See Gate Selection to learn more about gate selectors.

Prerequisites

  • (Optional) A sampler if you want to configure the heuristic-gradient path (see Create a Sampler)

  • (Optional) An estimator if you want to use heuristic-selected-CI (see Create an Estimator)

Choices

  • Quick start: default FAST gate selector

    If nothing else is specified, the default metric for the gate selector is the heuristic gradient.

    import qrunch as qc
    
    gate_selector = (
        qc.gate_selector_creator()
        .fast()
        .create()
    )
    
  • Explicitly select the heuristic-gradient metric

    Identical to the default, but shown here for clarity.

    import qrunch as qc
    
    gate_selector = (
        qc.gate_selector_creator()
        .fast()
        .with_heuristic_gradient()
        .create()
    )
    
  • Use the heuristic-selected-CI metric (requires an estimator)

    The heuristic-selected-CI metric needs expectation values, so an estimator must be provided. See Create an Estimator for details. If None is passed for the estimator, i.e., (with_heuristic_selected_ci(estimator=None)), the code will use the default estimator.

    import qrunch as qc
    
    gate_selector = (
        qc.gate_selector_creator()
        .fast()
        .with_heuristic_selected_ci(estimator)
        .create()
    )
    

    See Create an Estimator for how to create an estimator.

  • Provide a sampler for the heuristic-gradient path

    Both the heuristic-gradient and the heuristic-selected-CI metrics rely on sampling. You can supply the sampler and, optionally, the number of shots to use.

    import qrunch as qc
    
    gate_selector = (
        qc.gate_selector_creator()
        .fast()
        .with_heuristic_gradient()
        .with_sampler(user_sampler)
        .with_shots(shots=1000)   # finite-shots sampling
        .create()
    )
    

    See Create a Sampler for how to create a sampler.

    Note

    with_shots(shots=None) is only valid with a state-vector simulator (no sampling noise). For hardware-like runs, use a positive integer.

Configure selector options

You can pass a FastGateSelectorOptions instance to adjust the behavior of the FAST gate selector.

import qrunch as qc

options = qc.options.FastGateSelectorOptions()  # use defaults; see API for fields

gate_selector = (
      qc.gate_selector_creator()
      .fast()
      .with_heuristic_gradient()
      .with_options(options)
      .create()
)

Verify the Result

  • The gate_selector is now a configured FAST gate selector instance suitable for Adaptive VQE

  • Integrate it into a VQE calculator, as explained in Build a VQE Calculator

See Also

Next Step

You can use the gate selector to build a VQE calculator: