-
Notifications
You must be signed in to change notification settings - Fork 0
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
Instr #46
Conversation
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Hello @stroblme! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2024-11-15 12:52:37 UTC |
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
|
||
if main_data["number_qubits"] > 1: | ||
instructor.model.params = instructor.model.params | ||
ent_cap = instructor.meyer_wallach( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there might be an issue with qml-essentials here, when setting the n_qubits > 1. I get the following stack trace (when removing the try-catch), when resetting and starting the training (e.g. Ansatz=Circuit19, n_qubits=2, n_layers=2):
Traceback (most recent call last):
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/dash/dash.py", line 1376, in dispatch
ctx.run(
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/dash/_callback.py", line 507, in add_context
raise err
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/dash/_callback.py", line 496, in add_context
output_value = _invoke_callback(func, *func_args, **func_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/dash/_callback.py", line 43, in _invoke_callback
return func(*args, **kwargs) # %% callback invoked %%
^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/app/pages/1-training.py", line 441, in training
data = instructor.calc_hist(
^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/app/utils/instructor.py", line 166, in calc_hist
.sample_coefficients(self.model, noise_params=noise_params, cache=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/qml_essentials/coefficients.py", line 30, in sample_coefficients
coeffs = coefficients(partial_circuit, 1, model.degree)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/pennylane/fourier/coefficients.py", line 178, in coefficients
return _coefficients_no_filter(f, degree, use_broadcasting)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/pennylane/fourier/coefficients.py", line 262, in _coefficients_no_filter
f_out = f(sampling_point)
^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/qml_essentials/model.py", line 483, in __call__
return self._forward(
^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.11/site-packages/qml_essentials/model.py", line 616, in _forward
if len(result.shape) == 3 and result.shape[0] == 1:
^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'shape'
My guess is that this is somehow caused by implicitly setting the execution_type to density when comuting the Meyer-Wallach measure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! already addressed with cirKITers/qml-essentials/pull/61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah whoops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating qml-essentials version to 0.1.17 with 1acfbf0 does not fully solve this problem.
Now getting a different stack trace (probably related to implicitly setting the execution_type):
ERROR:app:Exception on /_dash-update-component [POST]
TypeError: only length-1 arrays can be converted to Python scalars
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/dash/dash.py", line 1376, in dispatch
ctx.run(
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/dash/_callback.py", line 507, in add_context
raise err
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/dash/_callback.py", line 496, in add_context
output_value = _invoke_callback(func, *func_args, **func_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/dash/_callback.py", line 43, in _invoke_callback
return func(*args, **kwargs) # %% callback invoked %%
^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/app/pages/1-training.py", line 440, in training
data = instructor.calc_hist(
^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/app/utils/instructor.py", line 166, in calc_hist
.sample_coefficients(self.model, noise_params=noise_params, cache=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/qml_essentials/coefficients.py", line 30, in sample_coefficients
coeffs = coefficients(partial_circuit, 1, model.degree)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/pennylane/fourier/coefficients.py", line 178, in coefficients
return _coefficients_no_filter(f, degree, use_broadcasting)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/mind-the-qapp/.venv/lib/python3.12/site-packages/pennylane/fourier/coefficients.py", line 263, in _coefficients_no_filter
f_discrete[nvec] = f_out if use_broadcasting else np.squeeze(f_out)
~~~~~~~~~~^^^^^^
ValueError: setting an array element with a sequence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thanks! Should we address the qml-essentials issue before merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's gooo
This PR tries to fix the adam issue by globalizing the instructor..
**Depends on #45 **