Feat/bumper - #43
Open
Katie1harrison wants to merge 38 commits into
Open
Conversation
…e-token and astt-ype-qumode
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
Feat/qumode
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
Fix/qumode subscript op 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
|
|
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>
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add bumper attributes to the
unitarydata typeSummary
support for assigning bumper-level constraints to the
unitarydata 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.
Exact bumper count
Meaning:
Maximum bumper count
Meaning:
Valid Examples
Exact bumper count
Maximum bumper count
Reassigning the bumper count
Incrementing the bumper count
Invalid Examples
Attribute before declaration
Missing value
Missing assignment operator
Missing unitary identifier
unitary u; .bumper = 4;Attribute inside the declaration
Instead use
Attribute on another data type
qubit q; q.bumper = 4;Implementation
This PR extends the parser to recognize unitary attribute assignments of the form
For example,
is parsed as
ubumper=4The same grammar also supports
and
Design Decisions
bumperandbumper_maxare identifiersRather than introducing new lexer keywords, both
bumperandbumper_maxare parsed as identifiers following the.operator.For example,
Attributes are separate statements
Attributes are assigned after a unitary declaration.
rather than