Skip to content
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

[GQSP] Negative powers and Hamiltonian simulation #669

Closed
wants to merge 35 commits into from

Conversation

anurudhp
Copy link
Contributor

No description provided.

@anurudhp anurudhp force-pushed the gqsp-hamiltonian-simulation branch 3 times, most recently from 37b9fc7 to 7cccd4c Compare February 17, 2024 18:35
@anurudhp anurudhp force-pushed the gqsp-hamiltonian-simulation branch 2 times, most recently from 3c989ba to c7b6337 Compare February 26, 2024 21:51
@anurudhp anurudhp marked this pull request as ready for review February 26, 2024 22:06
@anurudhp anurudhp force-pushed the gqsp-hamiltonian-simulation branch from 4928ba4 to 287efdf Compare February 26, 2024 22:18
@anurudhp
Copy link
Contributor Author

@tanujkhattar I've implemented the hamiltonian simulation now, along with the call graph. I added unittests with randomly generated select and prepare oracles. I'm still debugging why the expected block doesn't match e^iHt. In the meantime could you review the rest of the code?

@tanujkhattar
Copy link
Collaborator

I'll take a look soon, thanks for the update

@anurudhp anurudhp force-pushed the gqsp-hamiltonian-simulation branch 2 times, most recently from 4bf5990 to 2264b4b Compare March 5, 2024 14:03
@cached_property
def gqsp(self) -> GeneralizedQSP:
return GeneralizedQSP.from_qsp_polynomial(
self.walk_operator, self.approx_cos, negative_power=self.degree
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've narrowed down the issue to this: as the $e^{it\cos\theta}$ approximation is very accurate, it forces $Q = 0$, and therefore all the QSP angles (thetas) are also 0. This gives us the trivial final unitary $U^d$ (d = degree), and not $P(U)$.

Mathematically this makes sense as the only polynomial s.t. $|P(e^{i\theta})| = 1$ is $P(z) = z^k$. But in practice we just have a really good approximation and $Q \approx 0$, which gets treated as $Q = 0$. I'm not sure how to fix this.

@tanujkhattar

@anurudhp anurudhp force-pushed the gqsp-hamiltonian-simulation branch from 7a8369f to fc01bc9 Compare March 15, 2024 08:39
Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a round of comments for code organization and cleanup while I think more about the hamiltonian simulation issue. Thanks for doing this!

qualtran/bloqs/generalized_qsp.py Show resolved Hide resolved
qualtran/bloqs/generalized_qsp.py Show resolved Hide resolved
qualtran/bloqs/generalized_qsp.py Show resolved Hide resolved
@@ -239,9 +260,11 @@ def safe_angle(x):
class GeneralizedQSP(GateWithRegisters):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create a new subpackage for qualtran/bloqs/qsp/ and move the generalized qsp code inside the new folder. We can have two files right now

  1. qualtran/bloqs/qsp/generalized_qsp.py - This should have GeneralizedQSP, gqsp_phase_factors, gqsp_complementary_polynomial (rename qsp to gqsp in the last 2 functions)
  2. qualtran/bloqs/qsp/polynomial_approximations.py - This file can have functions which return coefficeints for commonly used polynomial approximations. For example: approx_exp_cos(precision, scaling_const) and approx_exp_sin(precision, scaling_const), which returns coefficients of the Jacobi-anger polynomial approximation which can be called directly from the HamiltonianSimulationViaGQSP Bloq.

For HamiltonianSimulationByGQSP, we can create a new subpackage for bloqs/hamiltonian_simulation/ and move HamiltonianSimulationByGQSP there. But this can be done once the above refactorings are complete to avoid merge conflicts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For GeneralizedQSP, add a bloq_example, autogenerate the notebook from docstrings (you can add manually add more cells and they'll be preserve during the autogeneration process), add bloq_autotester tests and assert_decompose_is_consistent_with_t_complexity.

Does it make sense to show some kind of symbolic analysis in GQSP? The current API won't support it since we expect P and Q to be tuples of complex numbers and we currently don't have a way to specify sequences of variable symbolic lengths but we can file an issue to track this if there's a nice example where users would benefit from seeing the cost of applying GQSP as in terms of symbolic parameters they care about (for example hamiltonian simulation).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being refactored in #848, #851

qualtran/bloqs/generalized_qsp_test.py Show resolved Hide resolved
@anurudhp
Copy link
Contributor Author

anurudhp commented Apr 2, 2024

Split into #802, #810, #848, #851

@anurudhp anurudhp closed this Apr 2, 2024
@anurudhp anurudhp deleted the gqsp-hamiltonian-simulation branch April 3, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants