-
Notifications
You must be signed in to change notification settings - Fork 1
TerminalLogicalMeasurement implementation #627
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
8 commits
Select commit
Hold shift + click to select a range
58f7bfe
reshuffled some things, structure up for debate
johnzl-777 921618c
Merge branch 'main' into 609-create-terminalmeasure-statement
johnzl-777 67b4de2
Merge branch 'main' into 609-create-terminalmeasure-statement
david-pl 724b019
add docstring to original statement
johnzl-777 d2d7027
reshuffle to try and avoid import errors
johnzl-777 6d5c786
fix obnoxious circular import problem
johnzl-777 b56f9f0
add test
johnzl-777 136ed03
add back the physical qubit number per patch type - accidentally remo…
johnzl-777 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 +1 @@ | ||
| from .groups import logical as logical | ||
| from .dialects import logical as logical |
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,3 +0,0 @@ | ||
| from .logical_validation.analysis import ( | ||
| GeminiLogicalValidationAnalysis as GeminiLogicalValidationAnalysis, | ||
| ) | ||
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 +1,2 @@ | ||
| from . import impls as impls, analysis as analysis # NOTE: register methods | ||
| from . import impls as impls # NOTE: register methods | ||
| from .analysis import GeminiLogicalValidationAnalysis as GeminiLogicalValidationAnalysis |
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 @@ | ||
| from . import logical as logical |
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,4 @@ | ||
| from . import stmts as stmts | ||
| from .groups import kernel as kernel | ||
| from ._dialect import dialect as dialect | ||
| from ._interface import terminal_measure as terminal_measure |
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("logical") |
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,30 @@ | ||
| from typing import TypeVar | ||
|
|
||
| from kirin import lowering | ||
| from kirin.dialects import ilist | ||
|
|
||
| from bloqade.types import Qubit, MeasurementResult | ||
|
|
||
| from .stmts import TerminalLogicalMeasurement | ||
|
|
||
| Len = TypeVar("Len", bound=int) | ||
| CodeN = TypeVar("CodeN", bound=int) | ||
|
|
||
|
|
||
| @lowering.wraps(TerminalLogicalMeasurement) | ||
| def terminal_measure( | ||
| qubits: ilist.IList[Qubit, Len], | ||
| ) -> ilist.IList[ilist.IList[MeasurementResult, CodeN], Len]: | ||
| """Perform measurements on a list of logical qubits. | ||
|
|
||
| Measurements are returned as a nested list where each member list | ||
| contains the individual measurement results for the constituent physical qubits per logical qubit. | ||
|
|
||
| Args: | ||
| qubits (IList[Qubit, Len]): The list of logical qubits to measure. | ||
|
|
||
| Returns: | ||
| IList[IList[MeasurementResult, CodeN], Len]: A nested list containing the measurement results, | ||
| where each inner list corresponds to the measurements of the physical qubits that make up each logical qubit. | ||
| """ | ||
| ... | ||
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
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,32 @@ | ||
| from kirin import ir, types, lowering | ||
| from kirin.decl import info, statement | ||
| from kirin.dialects import ilist | ||
|
|
||
| from bloqade.types import QubitType, MeasurementResultType | ||
|
|
||
| from ._dialect import dialect | ||
|
|
||
| Len = types.TypeVar("Len", bound=types.Int) | ||
| CodeN = types.TypeVar("CodeN", bound=types.Int) | ||
|
|
||
|
|
||
| @statement(dialect=dialect) | ||
| class TerminalLogicalMeasurement(ir.Statement): | ||
johnzl-777 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Perform measurements on a list of logical qubits. | ||
|
|
||
| Measurements are returned as a nested list where each member list | ||
| contains the individual measurement results for the constituent physical qubits per logical qubit. | ||
|
|
||
| Args: | ||
| qubits (IList[QubitType, Len]): The list of logical qubits | ||
|
|
||
| Returns: | ||
| IList[IList[MeasurementResultType, CodeN], Len]: A nested list containing the measurement results, | ||
| where each inner list corresponds to the measurements of the physical qubits that make up each logical qubit. | ||
| """ | ||
|
|
||
| traits = frozenset({lowering.FromPythonCall()}) | ||
| qubits: ir.SSAValue = info.argument(ilist.IListType[QubitType, Len]) | ||
| result: ir.ResultValue = info.result( | ||
| ilist.IListType[ilist.IListType[MeasurementResultType, CodeN], Len] | ||
| ) | ||
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
Oops, something went wrong.
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.