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

Update GST to take in gates.Unitary #1587

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Update GST to take in gates.Unitary #1587

wants to merge 13 commits into from

Conversation

mho291
Copy link
Contributor

@mho291 mho291 commented Feb 12, 2025

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.

Comment on lines 301 to 308
if isinstance(params, list):
init_args = signature(gate).parameters
valid_angles = [arg for arg in init_args if arg in angles]
angle_values = dict(zip(valid_angles, params))
else:
init_args = signature(gate).parameters
valid_angles = [arg for arg in init_args if arg in matrix]
angle_values = dict(zip(valid_angles, [params]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if isinstance(params, list):
init_args = signature(gate).parameters
valid_angles = [arg for arg in init_args if arg in angles]
angle_values = dict(zip(valid_angles, params))
else:
init_args = signature(gate).parameters
valid_angles = [arg for arg in init_args if arg in matrix]
angle_values = dict(zip(valid_angles, [params]))
if not isinstance(params, list):
params = [params]
init_args = signature(gate).parameters
valid_angles = [arg for arg in init_args if arg in angles]
angle_values = dict(zip(valid_angles, params))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @renatomello for spotting this. I have made the changes. But still trying to get it to work. It's currently complaining

FAILED tests/test_tomography_gate_set_tomography.py::test_GST[numpy-False-target_gates0] - ValueError: axes don't match array
FAILED tests/test_tomography_gate_set_tomography.py::test_GST[numpy-True-target_gates0] - ValueError: axes don't match array
FAILED tests/test_tomography_gate_set_tomography.py::test_GST[qibojit-numba-False-target_gates0] - ValueError: axes don't match array
FAILED tests/test_tomography_gate_set_tomography.py::test_GST[qibojit-numba-True-target_gates0] - ValueError: axes don't match array

Will keep trying to debug.

@@ -233,8 +235,7 @@ def GST(
gate_set (tuple or set or list): set of :class:`qibo.gates.Gate` and parameters to run
GST on.
E.g. gate_set = [(gates.RX, [np.pi/3]), gates.Z, (gates.PRX, [np.pi/2, np.pi/3]),
(gates.GPI, [np.pi/7]), gates.CNOT,
(gates.Unitary, (np.array([[1,0],[0,1]])))]
(gates.GPI, [np.pi/7]), gates.CNOT]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docstring is generating a warning when the documentation is compiled because of identation. I fixed it in #1584. Please look at it to also fix it here.

@mho291
Copy link
Contributor Author

mho291 commented Mar 4, 2025

Hi @MatteoRobbiati, I need some advice with this. When I run the pytests locally, they pass. But here, they always run into dimension error:

FAILED tests/test_tomography_gate_set_tomography.py::test_GST[qiboml-pytorch-False-target_gates0] - RuntimeError: permute(sparse_coo): number of dimensions in the tensor input does not match the length of the desired ordering of dimensions i.e. input.dim() = 1 is not equal to len(dims) = 2

Could there be an issue with qiboml-pytorch?

Thanks so much!

@MatteoRobbiati
Copy link
Contributor

Could there be an issue with qiboml-pytorch?

Ehi @mho291! Thanks for asking :)
I tested locally your branch and in my case I get the same failure, but on all the backends (numpy, qibojit, pytorch, tensorflow), so ig the source of the problem is elsewhere.
It seems to me the problem is appearing when calling this line in gates.py.

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 this pull request may close these issues.

3 participants