-
Notifications
You must be signed in to change notification settings - Fork 1
Adding noise statements to squin #211
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a2ab3a5
initial noise statements sketch
johnzl-777 619518c
Merge branch 'main' into 166-add-noise-statements-to-squin
johnzl-777 747d8fc
remove snakecase, fix wrappers
johnzl-777 f1cde89
Merge branch 'main' into 166-add-noise-statements-to-squin
weinbe58 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from . import op as op, wire as wire, qubit as qubit | ||
from . import op as op, wire as wire, noise as noise, qubit as qubit | ||
from .groups import wired as wired, kernel as kernel |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Put all the proper wrappers here | ||
|
||
from kirin.lowering import wraps as _wraps | ||
|
||
from bloqade.squin.op.types import Op | ||
|
||
from . import stmts as stmts | ||
|
||
|
||
@_wraps(stmts.PauliError) | ||
def pauli_error(basis: Op, p: float) -> Op: ... | ||
|
||
|
||
@_wraps(stmts.PPError) | ||
def pp_error(op: Op, p: float) -> Op: ... | ||
|
||
|
||
@_wraps(stmts.Depolarize) | ||
def depolarize(n_qubits: int, p: float) -> Op: ... | ||
|
||
|
||
@_wraps(stmts.PauliChannel) | ||
def pauli_channel(n_qubits: int, params: tuple[float, ...]) -> Op: ... | ||
|
||
|
||
@_wraps(stmts.QubitLoss) | ||
def qubit_loss(p: float) -> Op: ... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from kirin import ir | ||
|
||
dialect = ir.Dialect(name="squin.noise") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from kirin import ir, types | ||
from kirin.decl import info, statement | ||
|
||
from bloqade.squin.op.types import OpType | ||
|
||
from ._dialect import dialect | ||
|
||
|
||
@statement | ||
class NoiseChannel(ir.Statement): | ||
pass | ||
|
||
|
||
@statement(dialect=dialect) | ||
class PauliError(NoiseChannel): | ||
basis: ir.SSAValue = info.argument(OpType) | ||
p: ir.SSAValue = info.argument(types.Float) | ||
result: ir.ResultValue = info.result(OpType) | ||
|
||
|
||
@statement(dialect=dialect) | ||
class PPError(NoiseChannel): | ||
""" | ||
Pauli Product Error | ||
""" | ||
|
||
op: ir.SSAValue = info.argument(OpType) | ||
p: ir.SSAValue = info.argument(types.Float) | ||
result: ir.ResultValue = info.result(OpType) | ||
|
||
|
||
@statement(dialect=dialect) | ||
class Depolarize(NoiseChannel): | ||
""" | ||
Apply n-qubit depolaize error to qubits | ||
NOTE For Stim, this can only accept 1 or 2 qubits | ||
""" | ||
|
||
n_qubits: int = info.attribute(types.Int) | ||
p: ir.SSAValue = info.argument(types.Float) | ||
result: ir.ResultValue = info.result(OpType) | ||
|
||
|
||
@statement(dialect=dialect) | ||
class PauliChannel(NoiseChannel): | ||
# NOTE: | ||
# 1-qubit 3 params px, py, pz | ||
# 2-qubit 15 params pix, piy, piz, pxi, pxx, pxy, pxz, pyi, pyx ..., pzz | ||
# TODO add validation for params (maybe during lowering via custom lower?) | ||
n_qubits: int = info.attribute() | ||
params: ir.SSAValue = info.argument(types.Tuple[types.Vararg(types.Float)]) | ||
result: ir.ResultValue = info.result(OpType) | ||
|
||
|
||
@statement(dialect=dialect) | ||
class QubitLoss(NoiseChannel): | ||
# NOTE: qubit loss error (not supported by Stim) | ||
p: ir.SSAValue = info.argument(types.Float) | ||
result: ir.ResultValue = info.result(OpType) |
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.
Uh oh!
There was an error while loading. Please reload this page.