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

Error returning depth from circuit with only Classical ops #1673

Closed
sjdilkes opened this issue Nov 11, 2024 · 1 comment · Fixed by #1707
Closed

Error returning depth from circuit with only Classical ops #1673

sjdilkes opened this issue Nov 11, 2024 · 1 comment · Fixed by #1707
Assignees

Comments

@sjdilkes
Copy link
Contributor

The following code snippet:

from pytket.circuit import (
    Circuit,
    MultiBitOp,
    SetBitsOp,
)
from pytket.pauli import Pauli



set_bits = SetBitsOp([True, True])
multi_bit = MultiBitOp(set_bits, 2)
eq_pred_values = [True, False, False, True]
and_values = [bool(i) for i in [0, 0, 0, 1]]

circ = Circuit(4, 4, name="test")
circ.add_gate(multi_bit, [0, 1, 2, 3])

circ.add_c_predicate(eq_pred_values, [0, 1], 2, "EQ")
circ.add_c_modifier(and_values, [1], 2)

circ.measure_all()


print(circ.depth())

gives:

[tket] [critical] Assertion '!"RAW hazard created in slicing"' (../../src/Circuit/macro_circ_info.cpp : get_next_b_frontier : 400) failed.  Aborting.
@cqc-alec
Copy link
Collaborator

cqc-alec commented Dec 2, 2024

This issue is not specific to classical ops, but can arise with conditional ops as well. For example, this circuit:

c = Circuit(2, 2)
c.X(1, condition_bits=[0, 1], condition_value=3)
c.Y(1, condition_bits=[0], condition_value=1)
c.Measure(0, 0)

results in the same assertion error when c.depth() is called.

This is the DAG:
Circuit.gv.pdf

The problem is that both the Boolean edges originating from c[0], including the one terminating in the Y operation, are in the initial b_frontier_t; but the Quantum wire from the X to the Y operation is not in the initial unit_frontier_t.

This is quite reminiscent of #1357 : in both cases the issue occurs when there are multiple paths in the DAG leading from the source to the target of a Boolean wire.

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 a pull request may close this issue.

2 participants