Skip to content

Adding box pragma support to QASM compiler #2571

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

idavis
Copy link
Collaborator

@idavis idavis commented Jun 30, 2025

Adding support for boxed expressions and pragmas for them when integrating with the Q# compiler.

When working in OpenQASM with the QDK, we can now use pragmas to denote parameterless void functions to call at the beginning and/or end of boxed expressions. They can additionally leverage simulatable intrinsic functions which will flow through to code generation.

OPENQASM 3.0;
include "stdgates.inc";
#pragma qdk.box.open box_begin
#pragma qdk.box.close box_end

@SimulatableIntrinsic
def box_begin() {}

@SimulatableIntrinsic
def box_end() {}

qubit q;
box {
    x q;
}
output bit c;
c = measure q;
define void @ENTRYPOINT__main() #0 {
block_0:
  call void @box_begin()
  call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*))
  call void @box_end()
  call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*))
  call void @__quantum__rt__tuple_record_output(i64 0, i8* null)
  ret void
}

@idavis idavis self-assigned this Jun 30, 2025
@idavis idavis requested a review from orpuente-MS June 30, 2025 17:28
@idavis idavis mentioned this pull request Jul 1, 2025
21 tasks
@idavis idavis force-pushed the iadavis/box-pragma branch from e17c0d1 to 59f3de6 Compare July 1, 2025 16:34
@idavis idavis marked this pull request as ready for review July 1, 2025 16:44
@idavis idavis requested review from minestarks and swernli as code owners July 1, 2025 16:44
Copy link
Collaborator

@swernli swernli left a comment

Choose a reason for hiding this comment

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

Looks good with a few minor comments. On the naming front, assuming we either ignore the syntax highlighting quirk or fix it, I think keeping the naming used in here (qdk.box.open) is good.

@idavis idavis requested a review from billti as a code owner July 2, 2025 19:09
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