-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add caching capabilities to QiskitDevice
.
#165
Labels
enhancement
New feature or request
Comments
@antalszava I'm curious if the caching in the device is superceded by the caching in the This new caching capability is accessible via the new QNode: dev = qml.device('qiskit.aer', wires=2)
cache = {}
@qml.qnode(dev, cache=cache)
def expval_circuit(params):
qml.templates.BasicEntanglerLayers(params, wires=wires, rotation=qml.RX)
return qml.expval(qml.Hermitian(hamiltonian, wires=wires))
@qml.qnode(dev, cache=cache)
def var_circuit(params):
qml.templates.BasicEntanglerLayers(params, wires=wires, rotation=qml.RX)
return qml.var(qml.Hermitian(hamiltonian, wires=wires)) >>> print(expval_circuit(params), var_circuit(params)))
-2.6224875809703287, 0.011605015096940896
>>> print(cache)
{-2104543859499562169: array([-2.62248758]), 3268478774057874589: array([0.01160502])}
>>> print(expval_circuit(params), var_circuit(params))) # evaluate QNodes again
-2.6224875809703287, 0.011605015096940896
>>> dev.num_executions # only the first two executions will register
2 |
@josh146 oh that's a great point! I think so 🤔 Should the |
Good idea! |
Cool, added it 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The PennyLane
QubitDevice
class allows caching certain circuit executions. Once the same circuit is being executed multiple times, cached values may be used to provide the result of circuit executions.This capability could also be added to
QiskitDevice
.The text was updated successfully, but these errors were encountered: