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

LABS using circuit? #28

Closed
jmlarson1 opened this issue Dec 19, 2023 · 9 comments · Fixed by #31
Closed

LABS using circuit? #28

jmlarson1 opened this issue Dec 19, 2023 · 9 comments · Fixed by #31

Comments

@jmlarson1
Copy link

Is there an example where QOKit evaluates the LABS circuit instead of the statevector simulation?

In the qaoa_objective_labs file:

from .qaoa_circuit_labs import get_parameterized_qaoa_circuit

I see that the circuit is imported, but I don't see where it is ever used/evaluated? Isn't this necessary for large N?

(I see QOKit has this implemented for portfolio optimization though.)

@mmenickelly

@rsln-s
Copy link
Contributor

rsln-s commented Dec 19, 2023

@jmlarson1, thank you for raising this issue!

This is indeed a bug as the support for Qiskit simulation leveraging the parameterized QAOA circuit appears to have been lost. Somehow, this has escaped our test coverage, which is unfortunate.

The short of it is that simply instantiating parameterized QAOA circuit and passing it to get_qaoa_objective should work.

We will aim to resolve this soon (though possibly after the holidays).

@jmlarson1
Copy link
Author

Many of us, including @Shagun-G are interested in having this functionality

@rsln-s
Copy link
Contributor

rsln-s commented Dec 19, 2023

@jmlarson1 @Shagun-G @mmenickelly:
I added a quick hot fix in #30 that should address your needs. Here is a quick test that the implementation is correct:

import numpy as np
from qokit.parameter_utils import get_best_known_parameters_for_LABS_wrt_overlap_for_p
from qokit.qaoa_objective_labs import get_qaoa_labs_objective

N = 7
p = 8
gamma, beta = get_best_known_parameters_for_LABS_wrt_overlap_for_p(N, p)

f1 = get_qaoa_labs_objective(N, p, parameterization="gamma beta", simulator="auto")
f2 = get_qaoa_labs_objective(N, p, parameterization="gamma beta", simulator="qiskit")

assert np.isclose(f1(gamma, beta), f2(gamma, beta))

@jmlarson1
Copy link
Author

Thank you. I need to try a different build because I get an error:

Traceback (most recent call last):
  File "/home/jlarson/QOKit/ruslan_rocks.py", line 2, in <module>
    from qokit.parameter_utils import get_best_known_parameters_for_LABS_wrt_overlap_for_p
  File "/home/jlarson/QOKit/qokit/__init__.py", line 6, in <module>
    from .qaoa_objective import get_qaoa_objective
  File "/home/jlarson/QOKit/qokit/qaoa_objective.py", line 10, in <module>
    import numba.cuda
  File "/home/jlarson/.local/lib/python3.10/site-packages/numba/__init__.py", line 55, in <module>
    _ensure_critical_deps()
  File "/home/jlarson/.local/lib/python3.10/site-packages/numba/__init__.py", line 42, in _ensure_critical_deps
    raise ImportError("Numba needs NumPy 1.24 or less")
ImportError: Numba needs NumPy 1.24 or less

@rsln-s
Copy link
Contributor

rsln-s commented Dec 20, 2023

I would suggest trying to re-install from source in a clean venv/conda environment.

@rsln-s
Copy link
Contributor

rsln-s commented Jan 5, 2024

@jmlarson1 was your issue resolved by #30?

@jmlarson1
Copy link
Author

Yes! The example works for me. Thank you.

Is there some obvious way to pass the desired number of shots to the get_qaoa_labs_objective method? f1(gamma, beta, shots=1000) would be nice, and would seem to match qokit/qaoa_circuit_portfolio.py where one can
execute(circuit, backend, shots=n_trials).

But that doesn't work (and I don't even see that kwargs are passed to get_qaoa_labs_objective).

@rsln-s
Copy link
Contributor

rsln-s commented Jan 19, 2024

The simulator does not support emulating shot-based noise. Only exact expectation value is returned currently.

@jmlarson1
Copy link
Author

That is understandable. Is there a shot-based get_qaoa_labs_objective (without a simulator, perhaps)?

@rsln-s rsln-s linked a pull request Jan 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants