Skip to content

New Squin statements. #200

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

Merged
merged 6 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/bloqade/squin/op/stmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@
)


class U3(PrimitiveOp):
traits = frozenset({ir.Pure(), lowering.FromPythonCall(), Unitary(), FixedSites(1)})
theta: ir.SSAValue = info.argument(types.Float)
phi: ir.SSAValue = info.argument(types.Float)
lam: ir.SSAValue = info.argument(types.Float)
result: ir.ResultValue = info.result(OpType)


@statement(dialect=dialect)
class PhaseOp(PrimitiveOp):
"""
Expand Down Expand Up @@ -138,6 +146,18 @@
pass


@statement(dialect=dialect)
class CliffordString(ConstantUnitary):
Copy link

Choose a reason for hiding this comment

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

What is a CliffordString supposed to represent? PauliString has specific uses like defining a multi-qubit operator for measurement, control, or phase rotation. I am not familiar with "Clifford string".

traits = frozenset({ir.Pure(), lowering.FromPythonCall(), Unitary(), HasSites()})
string: str = info.attribute()

def verify(self) -> None:
if not set("XYZHS").issuperset(self.string):
raise ValueError(

Check warning on line 156 in src/bloqade/squin/op/stmts.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/squin/op/stmts.py#L155-L156

Added lines #L155 - L156 were not covered by tests
f"Invalid Clifford string: {self.string}. Must be a combination of 'X', 'Y', 'Z', 'H', and 'S'."
)


@statement(dialect=dialect)
class X(PauliOp):
pass
Expand Down
7 changes: 7 additions & 0 deletions src/bloqade/squin/qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class Apply(ir.Statement):
qubits: ir.SSAValue = info.argument(ilist.IListType[QubitType])


@statement(dialect=dialect)
class Broadcast(ir.Statement):
traits = frozenset({lowering.FromPythonCall()})
operator: ir.SSAValue = info.argument(OpType)
qubits: ir.SSAValue = info.argument(ilist.IListType[QubitType])


@statement(dialect=dialect)
class Measure(ir.Statement):
traits = frozenset({lowering.FromPythonCall()})
Expand Down