Skip to content

Support for adding barriers and delays to Circuit #974

@rmshaffer

Description

@rmshaffer

Describe the feature you'd like

Users should be able to add barriers and delays to Circuit objects using the same syntax as gates.

Implementing barrier and delay instructions should involve minimal complexity. OpenQASM supports both the barrier and delay instructions at the program level, so we could simply add these instructions in global scope in the resulting OpenQASM program.

For example, the code may look like:

circ = Circuit().x(0).barrier([0, 1]).x(0).delay(0, 1e-6)
print(circ)

which would output something like:

T  : |0|1|2|     3     |
                     
q0 : -X-|-X-delay(1e-6)-
        |            
q1 : ---|---------------

T  : |0|1|2|     3     |

How would this feature be used? Please describe.

The barrier and delay instructions are useful when precise timing of quantum operations is needed within a program. One example is in #417, where the time of measurement needs to be determined precisely.

Describe alternatives you've considered

Today, the Braket service supports barrier and delay as OpenPulse instructions, which is a workaround for achieving this functionality. For example, the program below contains a barrier on qubits $0 and $1 inside a cal block:

program = Program(source="""OPENQASM 3.0;
bit[1] b;
x $0;
cal {
    waveform t = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    play(q0_drive, t);
    barrier $0, $1;
}
b[0] = measure $0;
""")

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions