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] Calculating Histogram fails when selecting 'StronglyEntanglingLayers' #12

Closed
stroblme opened this issue Apr 24, 2024 · 2 comments
Closed
Assignees
Milestone

Comments

@stroblme
Copy link
Member

stroblme commented Apr 24, 2024

Error when using 'StronglyEntanglingLayers'.
Apparently fidelity calculation fails, thus histogram receives no update.

ValueError: operands could not be broadcast together with shapes (4,4) (0,4) 
Traceback (most recent call last):
  File "/home/lc3267/Documents/CodeWorkspace/Quantum-Surrogate-Project/app/pages/3-expressibility-viz.py", line 465, in update_output_probabilities
    x_samples, y_samples, z_samples = expr_sampler.sample_hist_state_fidelities(
  File "/home/lc3267/Documents/CodeWorkspace/Quantum-Surrogate-Project/app/utils/expressibility.py", line 160, in sample_hist_state_fidelities
    fidelities = self.sample_state_fidelities(bf=bf, pf=pf, ad=ad, pd=pd, dp=dp)
  File "/home/lc3267/Documents/CodeWorkspace/Quantum-Surrogate-Project/app/utils/expressibility.py", line 146, in sample_state_fidelities
    np.sqrt(sqrt_sv1 * sv[self.n_samples :] * sqrt_sv1),
  File "/home/lc3267/Documents/CodeWorkspace/Quantum-Surrogate-Project/.venv/lib/python3.10/site-packages/pennylane/numpy/tensor.py", line 155, in __array_ufunc__
    res = super().__array_ufunc__(ufunc, method, *args, **kwargs)
ValueError: operands could not be broadcast together with shapes (4,4) (0,4) 

168d9e9c-2b45-42ac-8ab7-0cf0743da256

@stroblme stroblme changed the title Calculating Histogram fails when selecting 'StronglyEntanglingLayers' [BUG] Calculating Histogram fails when selecting 'StronglyEntanglingLayers' Apr 25, 2024
@majafranz
Copy link
Collaborator

I think this is somehow related to qml.StronglyEntanglingLayers being not able to batch the weights, when computing the samples for the Expressibility.

Maybe we could have a look into qml.batch_params, but I wasn't able to get this running properly as well...

@stroblme stroblme added this to the QC-NHEP milestone Apr 26, 2024
@stroblme stroblme self-assigned this Apr 26, 2024
@majafranz
Copy link
Collaborator

This bug got fixed through using a custom implementation of the StronglyEntanglingLayers. For verification of this implementation see: cirKITers/qml-essentials#7

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

No branches or pull requests

2 participants