PennyLaneAI / catalyst

A JIT compiler for hybrid quantum programs in PennyLane
https://docs.pennylane.ai/projects/catalyst
Apache License 2.0
122 stars 27 forks source link

Fix cache for callbacks #907

Closed erick-xanadu closed 1 month ago

erick-xanadu commented 1 month ago

Context: callback cache should take into account input types as well as output types. The following simple example illustrates when a callback would have different mismatching inputs yet always returns the same type.

@pure_callback
def always_return_float(x) -> float:
    if x == 0.0:
        return x
    else:
        return x + 0.0

Description of the Change: Adds input types as part of the cache key

Benefits: No error.

Possible Drawbacks:

Related GitHub Issues: Fixes #851