qml.workflow.construct_execution_config

construct_execution_config(qnode, resolve=True)[source]

Constructs the execution configuration of a QNode instance.

Parameters
  • qnode (QNode) – the qnode we want to get execution configuration for

  • resolve (bool) – Whether or not to validate and fill in undetermined values like “best”. Defaults to True.

Returns

the execution configuration

Return type

config (qml.devices.ExecutionConfig)

Example

@qml.qnode(qml.device("default.qubit", wires=1))
def circuit(x):
    qml.RX(x, 0)
    return qml.expval(qml.Z(0))

First, let’s import pprint to make it easier to read the execution configuration objects.

>>> from pprint import pprint

If we wish to construct an unresolved execution configuration, we can specify resolve=False. This will leave properties like gradient_method and interface in their unrefined state (e.g. "best" or "auto" respectively).

>>> config = qml.workflow.construct_execution_config(circuit, resolve=False)(1)
>>> pprint(config)
ExecutionConfig(grad_on_execution=None,
                use_device_gradient=None,
                use_device_jacobian_product=False,
                gradient_method='best',
                gradient_keyword_arguments={},
                device_options={},
                interface=<Interface.AUTO: 'auto'>,
                derivative_order=1,
                mcm_config=MCMConfig(mcm_method=None, postselect_mode=None),
                convert_to_numpy=True)

Specifying resolve=True will then resolve these properties appropriately for the given QNode configuration that was provided,

>>> resolved_config = qml.workflow.construct_execution_config(circuit, resolve=True)(1)
>>> pprint(resolved_config)
ExecutionConfig(grad_on_execution=False,
                use_device_gradient=True,
                use_device_jacobian_product=False,
                gradient_method='backprop',
                gradient_keyword_arguments={},
                device_options={'max_workers': None,
                                'prng_key': None,
                                'rng': Generator(PCG64) at 0x15F6BB680},
                interface=<Interface.NUMPY: 'numpy'>,
                derivative_order=1,
                mcm_config=MCMConfig(mcm_method=None, postselect_mode=None),
                    convert_to_numpy=True)