Skip to content
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

Retrieve intermediate adapt vqe information. #26

Open
justinlietz opened this issue Dec 10, 2024 · 1 comment
Open

Retrieve intermediate adapt vqe information. #26

justinlietz opened this issue Dec 10, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@justinlietz
Copy link
Collaborator

Along with returning the final results, it would be useful to somehow access the result at intermediate steps of the calculation. Perhaps an optional list parameter could be supplied where the results from each step could be appended. Alternatively, a file could be provided where the results are stashed.

@justinlietz justinlietz added the enhancement New feature or request label Dec 10, 2024
@ikkoham
Copy link

ikkoham commented Dec 12, 2024

I thought it might be a good idea to allow saving and loading as a feature on the cudaq primitive side.
For example,

import os
os.environ["SAVE_PRIMITIVES"] = True
# optional? os.environ["SAVE_PRIMITIVES_DIR"] = "./some_nice_directory/"

result = cudaq.observe(kernel, operator)
print(result.primitive_id) # prints some id

# retrive from id
result2 = cudaq.retrieve_primitives(result.primitive_id)

assert result == result2

# you can retrieve the job from the filename
result3 = cudaq.retrieve_primitives("./filename.pr")

assert result == result3

and user can get the inputs like

# result has the input kernel and operator
assert kernel == result3.kernel
assert operator == result3.spin_operator

# or the input could be handled by a separate class.
inputs = cudaq.get_primitive_inputs(result.primitive_id)
assert kernel == inputs.kernel
assert operator ==  inputs.spin_operator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants