-
Notifications
You must be signed in to change notification settings - Fork 1
Support measuring registers in pyqrack #174
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
Changes from 6 commits
f110fe7
39dfff7
0cf41fd
28bc50d
6c14f4d
47375ed
bd040ed
0b1a721
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,11 +46,22 @@ class Measure(ir.Statement): | |
|
|
||
| name = "measure" | ||
| traits = frozenset({lowering.FromPythonCall()}) | ||
| qarg: ir.SSAValue = info.argument(QubitType) | ||
| qarg: ir.SSAValue = info.argument(QubitType | QRegType) | ||
| """qarg (Qubit): The qubit to measure.""" | ||
| carg: ir.SSAValue = info.argument(BitType) | ||
| carg: ir.SSAValue = info.argument(BitType | CRegType) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to add a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the type check test. FWIW, mixing the types would have already triggered a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to have the error at compile time compared to run time since in some cases you might not run the function with the simulator for awhile if at all. |
||
| """carg (Bit): The bit to store the result in.""" | ||
|
|
||
| def check_type(self) -> None: | ||
| qarg_is_qubit = self.qarg.type.is_subseteq(QubitType) | ||
| carg_is_bit = self.carg.type.is_subseteq(BitType) | ||
| if (qarg_is_qubit and not carg_is_bit) or (not qarg_is_qubit and carg_is_bit): | ||
| raise ir.TypeCheckError( | ||
| self, | ||
| "Can't perform measurement with single (qu)bit and an entire register!", | ||
| help="Instead of `measure(qreg[i], creg)` or `measure(qreg, creg[i])`" | ||
| "use `measure(qreg[i], creg[j])` or `measure(qreg, creg)`, respectively.", | ||
| ) | ||
|
|
||
|
|
||
| @statement(dialect=dialect) | ||
| class CRegEq(ir.Statement): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget an out the doc strings!