CQCL / pytket-phir

pytket-phir is a circuit analyzer and translator from pytket to PHIR.
https://cqcl.github.io/pytket-phir/
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

`IndexError` adding command with no qubits #61

Closed cqc-alec closed 10 months ago

cqc-alec commented 10 months ago
from pytket.circuit import Circuit
from pytket.phir.api import pytket_to_phir

c = Circuit(1)
a = c.add_c_register("a", 1)
b = c.add_c_register("b", 1)

c.add_c_copyreg(a, b)

phir = pytket_to_phir(c)

Output:

Traceback (most recent call last):
  File "/home/alec/r/pytket-phir/classical.py", line 10, in <module>
    phir = pytket_to_phir(c)
  File "/home/alec/r/pytket-phir/pytket/phir/api.py", line 54, in pytket_to_phir
    shards = sharder.shard()
  File "/home/alec/r/pytket-phir/pytket/phir/sharding/sharder.py", line 73, in shard
    self._process_command(command)
  File "/home/alec/r/pytket-phir/pytket/phir/sharding/sharder.py", line 105, in _process_command
    self._add_pending_sub_command(command)
  File "/home/alec/r/pytket-phir/pytket/phir/sharding/sharder.py", line 195, in _add_pending_sub_command
    qubit_key = command.qubits[0]
IndexError: list index out of range

(I have seen #25 and maybe this is covered by that but it looks like a different issue since from the description there I would have expected a NotImplementedError.)

qartik commented 10 months ago

Sharding happens way before phir generation, probably more related to https://github.com/CQCL/pytket-phir/issues/14, cc'ing @neal-erickson