catalyst.autograph_ignore_fallbacks¶
- autograph_ignore_fallbacks = False¶
Specify whether AutoGraph should avoid raising warnings when conversion fails and control flow instead falls back to being interpreted by Python at compile-time.
Example
In certain cases, AutoGraph will fail to convert control flow (for example, when an object that can not be converted to a JAX array is indexed in a loop), and will raise a warning informing of the failure.
>>> @qjit(autograph=True) ... @qml.qnode(dev) ... def f(): ... x = ["0.1", "0.2", "0.3"] ... for i in range(3): ... qml.RX(float(x[i]), wires=i) ... return qml.expval(qml.PauliZ(0)) Warning: Tracing of an AutoGraph converted for loop failed with an exception: ... If you intended for the conversion to happen, make sure that the (now dynamic) loop variable is not used in tracing-incompatible ways, for instance by indexing a Python list with it. In that case, the list should be wrapped into an array.
Setting this variable to
True
will suppress warning messages:>>> catalyst.autograph_strict_conversion = False >>> catalyst.autograph_ignore_fallbacks = True >>> @qjit(autograph=True) ... @qml.qnode(dev) ... def f(): ... x = ["0.1", "0.2", "0.3"] ... for i in range(3): ... qml.RX(float(x[i]), wires=i) ... return qml.expval(qml.PauliZ(0)) >>> f() array(0.99500417)
- Type
bool
code/api/catalyst.autograph_ignore_fallbacks
Download Python script
Download Notebook
View on GitHub