-
Notifications
You must be signed in to change notification settings - Fork 53
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
Create SparseMatrix
block encoding
#1143
Conversation
698fa9d
to
ca47003
Compare
@mpharrigan PTAL! |
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.
lgtm! % nits
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.
just a couple style things looks pretty nice 👍
alpha = bloq.alpha | ||
bb = BloqBuilder() | ||
system = bb.add_register("system", 2) | ||
ancilla = cast(Soquet, bb.add(IntState(0, 3))) |
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.
do you actually need this cast
?
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.
It is for making my IDE type checker (Pylance) happier. Mypy is more forgiving here.
bb = BloqBuilder() | ||
system = bb.add_register("system", 2) | ||
ancilla = cast(Soquet, bb.add(IntState(0, 3))) | ||
system, ancilla = bb.add_t(bloq, system=system, ancilla=ancilla) |
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.
you can still use add
here (which will return either a single value or a tuple depending on the bloq signature (this is how python function calls work))
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.
If I'm correct, you're expressing the same preference here as you did in #1158 (comment).
Is it a strong stylistic preference in Qualtran to use add
over add_t
? I didn't see this preference expressed in the documentation of BloqBuilder.add_t
.
Add an instance of
BlockEncoding
that builds a block encoding of a sparse-access matrix givenoracles for the indices of non-zero entries in each row / column and an oracle for its entries.
For now, we test its behavior using oracles for a matrix with the same entry in every position.
Oracles for diagonal and tridiagonal matrices are planned next.