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)

Steps

  1. 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()
    )
    
  2. 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()
    )
    
  3. 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 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.

  4. 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.

  5. 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

See Also

Next Step

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