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

TensorNetwork converter fails if the circuit has classical registers #44

Open
PabloAndresCQ opened this issue Nov 16, 2023 · 2 comments

Comments

@PabloAndresCQ
Copy link
Collaborator

If the pytket.Circuit has any classical register, when calling TensorNetwork on it, we get the following error:

Traceback (most recent call last):
  File "/home/aborgna/src/check-circ-eq/check_eq.py", line 112, in <module>
    run(MAX_QUBITS, results)
  File "/home/aborgna/src/check-circ-eq/check_eq.py", line 75, in run
    is_eq = test_equivalence(new_circ, old_circ)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aborgna/src/check-circ-eq/check_eq.py", line 30, in test_equivalence
    ket_net = TensorNetwork(ket_circ)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aborgna/src/check-circ-eq/venv/lib/python3.11/site-packages/pytket/extensions/cutensornet/tensor_network_convert.py", line 87, in __init__
    self._output_index_to_qubit = {
                                  ^
  File "/home/aborgna/src/check-circ-eq/venv/lib/python3.11/site-packages/pytket/extensions/cutensornet/tensor_network_convert.py", line 88, in <dictcomp>
    oi: qname_to_q[qname] for oi, qname in self._graph.output_names.items()
        ~~~~~~~~~~^^^^^^^
KeyError: 'c[0]'

This error occurs even if there are no operations acting on the classical registers. The issue seems to be that self._graph.output_names includes all wires, not only quantum ones.


This issue was found by Agustin Borgna.

@PabloAndresCQ
Copy link
Collaborator Author

My suggestion is that we check for classical registers at the beginning of the conversion and, if we find any, raise a UserError with a message saying something like "Classical registers are not supported. Please remove all classical registers from your circuit."

@erinaldiq
Copy link
Collaborator

Oh, I also got the same error, and I was not sure what to do. Is the solution for this to simply remove all classical registers?

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