Skip to content

Feat/bumper - #43

Open
Katie1harrison wants to merge 38 commits into
openqasm:mainfrom
paragon-lab:feat/bumper
Open

Feat/bumper#43
Katie1harrison wants to merge 38 commits into
openqasm:mainfrom
paragon-lab:feat/bumper

Conversation

@Katie1harrison

Copy link
Copy Markdown

Add bumper attributes to the unitary data type

Summary

support for assigning bumper-level constraints to the unitary data type.

The new syntax introduces two attributes:

  • bumper – specifies the exact number of bumper levels.
  • bumper_max – specifies the maximum number of bumper levels the compiler may use.

note that setting bumper levels to a value does not retrospectively change the input unitary. rather we want both the unitary and bumper level information to be stored and accessed at compilation.####


Motivation

When compiling a target unitary into bosonic operations, the compiler may use additional bumper states during decomposition. This PR adds language support for allowing users to specify these constraints directly on a unitary.


Supported Grammar

Automatic bumper selection

If no bumper attribute is specified, the compiler is free to choose the number of bumper levels.

unitary u;

Exact bumper count

unitary u;
u.bumper = 4;

Meaning:

  • The compiler must use exactly 4 bumper levels.

Maximum bumper count

unitary u;
u.bumper_max = 3;

Meaning:

  • The compiler may use 0–3 bumper levels.

Valid Examples

Exact bumper count

unitary u;
u.bumper = 4;

Maximum bumper count

unitary u;
u.bumper_max = 3;

Reassigning the bumper count

unitary u;

u.bumper = 4;
u.bumper = 2;

Incrementing the bumper count

unitary u;

u.bumper = 4;
u.bumper += 2;

Invalid Examples

Attribute before declaration

u.bumper = 4;

Missing value

unitary u;
u.bumper =;

Missing assignment operator

unitary u;
u.bumper 4;

Missing unitary identifier

unitary u;
.bumper = 4;

Attribute inside the declaration

unitary u.bumper = 4;

Instead use

unitary u;
u.bumper = 4;

Attribute on another data type

qubit q;
q.bumper = 4;

Implementation

This PR extends the parser to recognize unitary attribute assignments of the form

Identifier "." Identifier AssignmentOperator Expression ";"

For example,

u.bumper = 4;

is parsed as

  • Unitary identifier: u
  • Attribute: bumper
  • Assignment operator: =
  • Expression: 4

The same grammar also supports

u.bumper += 2;

and

u.bumper_max = 3;

Design Decisions

bumper and bumper_max are identifiers

Rather than introducing new lexer keywords, both bumper and bumper_max are parsed as identifiers following the . operator.

For example,

u.bumper = 4;

Attributes are separate statements

Attributes are assigned after a unitary declaration.

unitary u;
u.bumper = 4;

rather than

unitary u.bumper = 4;

Katie1harrison and others added 25 commits June 11, 2026 17:23
Older flake8 4.0.1 crashes under Python 3.12's importlib.metadata.
Also apply small pre-commit whitespace/newline fixes and sync uv.lock.

Co-authored-by: Cursor <cursoragent@cursor.com>
Parse snap([θ…])-style calls as a single classical ASTAngleArray
argument, and move fork-local production rules into the 10000+ range
to avoid colliding with upstream numbering.

Co-authored-by: Cursor <cursoragent@cursor.com>
added  comments explaining how tokens are created
changed ASTTypeQubit to ASTTypQumode for Qumode token
Qumode (and mixed qubit/qumode) call-site args resolve and validate like qubits, with opaque snap/ecd/disp stubs for CV gates.

Co-authored-by: Cursor <cursoragent@cursor.com>
Register TOK_DISP / ASTDispGateNode, accept a complex parameter and qumode
target, and allow leading qubit controls only under ctrl/negctrl. Include
related tests and the preprocessor full-file read fix.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add builtin disp gate and qumode CV gate call support
Support explicit classical formals (angle/float/complex and arrays), typed
qubit/qumode operands, GateType compatibility (including array sizes), mixed
array+scalar call args, and angle-array body indexing across gates.

Co-authored-by: Cursor <cursoragent@cursor.com>
GateEOp construction was appending the bare target while the modifier
statement was also appended; skip or pop the target so only the wrapped
op remains in gate bodies.

Co-authored-by: Cursor <cursoragent@cursor.com>
Emit FullyTyped/FormalParamTypes/FormalQuantumTypes from ASTGateNode::print,
and encode complex/array formals plus qubit vs qumode in definition mangled
names (remangle after Formal* is attached).

Co-authored-by: Cursor <cursoragent@cursor.com>
…othing is set, the default number of bumper levels in not zero. rather it's left open ended and will in the future allow for the compiler to choose the optimal number of bumper levels. the other two options are either to set a max number of bumper levels or to set and exact number of bumper levels
@Katie1harrison
Katie1harrison requested a review from a team as a code owner July 30, 2026 19:45
@CLAassistant

CLAassistant commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ Katie1harrison
❌ joshmtlau
You have signed the CLA already but the status is still pending? Let us recheck it.

joshmtlau and others added 3 commits July 30, 2026 14:54
Rename quantum carriers to Operands/OperandParams and GateOperandParam
(keeping mangler tag GQP), materialize qumode formals as ASTQumodeNode,
and attach BinaryOp/UnaryOp trees on disp complex Params instead of
folding through angle→real+0i.

Co-authored-by: Cursor <cursoragent@cursor.com>
Real literals and expressions against complex formals (and builtin disp) become MPComplex directly instead of angle coercion; document call-site GateQOpList as a representation quirk.

Co-authored-by: Cursor <cursoragent@cursor.com>
joshmtlau and others added 10 commits July 30, 2026 17:29
Support gate foo[uint N](array[T, N] …) with inferred or explicit N at
calls, and move array-initialization notes to GitHub issue #11.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce Fock control distinct from qubit ctrl(n), switch templates and
Fock levels to square brackets, and allow arithmetic in ctrl[…] brackets.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace opaque SNAP with a typed cvgates definition, keep induction
indices and template bindings intact for lowering, and drop a local
issue draft already filed as GitHub #15.

Co-authored-by: Cursor <cursoragent@cursor.com>
Store float/mpdecimal (and call-site conversions) in Params as declared types,
use angle arrays for SNAP, and document the stable disp/snap/ecd call contract
plus project stable vs WIP split for compiler consumers.

Co-authored-by: Cursor <cursoragent@cursor.com>
…um-params

Typed gate declarations with fixed numbers of parameters
unitary u = {
    {1, 0},
    {0, 1}
};

semantic analysis will need to check

are all rows the same length?
is the matrix square?
are the entries valid numeric/complex expressions?

does it satisfy U†U=I?
Add Matrix Definitions for the Unitary Data Type
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