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

[BUG] QNG functionality depending on Batch Size #31

Open
stroblme opened this issue Oct 10, 2023 · 2 comments
Open

[BUG] QNG functionality depending on Batch Size #31

stroblme opened this issue Oct 10, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@stroblme
Copy link
Member

Describe the bug
When choosing a batch size that is not log2, QNG fails.

To Reproduce
Set split optimizer to QNG (quantum model) and batch size to e.g. 10 and then run kedro.

Expected behavior
No problems

Screenshots
image
image

Hardware
N/A

Additional context
N/A

@stroblme stroblme added the bug Something isn't working label Oct 10, 2023
@stroblme
Copy link
Member Author

stroblme commented Oct 10, 2023

Ok, so I tracked it down to a problem with calculating the metric tensor.
Apparently the batched input isn't expected in those calculations and when interpreting the output of the quantum circuit, pennylane expects a shape of 2^n (at least it tries to squeezes the result in such a shape).
This however causes weird behavior where the combination of actual number of qubits and the batch size relates in such a way that only n_qubits*batch_size being log2 succeed.
However, if by chance, we have such a configuration, calculation takes almost forever because the metric tensor matrix then spans a n_qubits*batch_size matrix.

@stroblme
Copy link
Member Author

stroblme commented Oct 10, 2023

Fixed it by adjusting the processing_fn method in metric_tensor.py such that it averages over all probs within a batch before processing the covariance matrices (needed for gradient calc and root cause of above mentioned problem).
However, processing is (still?) terribly slow.. maybe I'm missing sth.?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant