-
Notifications
You must be signed in to change notification settings - Fork 1
Implement pyqrack interpreter method for qasm2 glob.u gate #152
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 5 commits
8f20684
5878705
9e72ff3
7f03965
93ef3c8
0dd6b31
e13a264
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 |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| from typing import Any | ||
|
|
||
| from kirin import interp | ||
| from kirin.dialects import ilist | ||
|
|
||
| from bloqade.pyqrack.reg import ( | ||
| CBitRef, | ||
|
|
@@ -9,7 +12,7 @@ | |
| PyQrackQubit, | ||
| ) | ||
| from bloqade.pyqrack.base import PyQrackInterpreter | ||
| from bloqade.qasm2.dialects import core | ||
| from bloqade.qasm2.dialects import core, glob | ||
|
|
||
|
|
||
| @core.dialect.register(key="pyqrack") | ||
|
|
@@ -77,3 +80,18 @@ def creg_eq( | |
| return (False,) | ||
|
|
||
| return (all(left is right for left, right in zip(lhs, rhs)),) | ||
|
|
||
| @interp.impl(glob.UGate) | ||
| def ugate(self, interp: PyQrackInterpreter, frame: interp.Frame, stmt: glob.UGate): | ||
| registers: ilist.IList[PyQrackReg, Any] = frame.get(stmt.registers) | ||
| theta, phi, lam = ( | ||
| frame.get(stmt.theta), | ||
| frame.get(stmt.phi), | ||
| frame.get(stmt.lam), | ||
| ) | ||
|
|
||
| for qreg in registers: | ||
| for qarg in qreg: | ||
|
||
| if qarg.is_active(): | ||
| interp.memory.sim_reg.u(qarg.addr, theta, phi, lam) | ||
| return () | ||
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.
This method needs to be implemented in a method table registered by
glob.dialect. The convention is to put a method table inside a module with the same name as the dialect.