Skip to content

Add end to end qubitization example for 2D Hubbard model from Linear T complexity paper#224

Merged
tanujkhattar merged 16 commits intomainfrom
hubbard_qubitization
May 23, 2023
Merged

Add end to end qubitization example for 2D Hubbard model from Linear T complexity paper#224
tanujkhattar merged 16 commits intomainfrom
hubbard_qubitization

Conversation

@tanujkhattar
Copy link
Collaborator

@tanujkhattar tanujkhattar commented May 11, 2023

Implements SELECT and PREPARE for Hubbard model as described in Section V of https://arxiv.org/abs/1805.03662

Uses the newly added SELECT / PREPARE oracles to construct a Qubitization walk operator and perform Heisenberg limited phase estimation on the walk operator. Outputs resource counts for a 10x10 hubbard model grid in under ~1 second.

Fixes #31

@tanujkhattar tanujkhattar mentioned this pull request May 11, 2023
Copy link
Collaborator

@fdmalone fdmalone left a comment

Choose a reason for hiding this comment

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

Looks great up to a bit more exposition in the notebook. In particular I think it's a great place to compare to the linear T paper in a bit more depth. They provide formula and make approximations for the T complexity so it should be possible to include a few more figures and comment on where the missing T gates are.

"This follows section V. of the [Linear T Paper](https://arxiv.org/abs/1805.03662).\n",
"\n",
"The Hubbard model is a special case of the electronic structure Hamiltonian\n",
"restricted to spins on a planar grid.\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd be careful saying spins here, it's still a fermionic model and spins have some separate meaning in the model condensed matter world. Also it's not really rrestricted to live in a plane. The 1D and 3D Hubbard models are well defined models.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was inspired from the following paragraph in the paper:

image

Can I reword to "The 2D Hubbard model is a special case of the electronic structure Hamiltonian
with fermions restricted on a planar grid." ? Can you suggest a better wording?

"- `x_dim`: the number of sites along the x axis.\n",
"- `y_dim`: the number of sites along the y axis.\n",
"- `t`: coefficient for XZX and YZY terms in the Hubbard model hamiltonian.\n",
"- `mu`: coefficeint for single body Z term and two-body ZZ terms in the Hubbard model hamiltonian.\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is mu? I think you're calling mu = 4 t below, but it seems a bit unusual to me, normally one measures things in units of t, U = 4 t is just intermediate coupling.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there a better name for this coefficient than coefficient for Z and ZZ terms?

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I set mu = 4 t below because the paper gives resource estimates for cases when mu = 4 t

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

The u in 57 is the same as the u in 56 right? When I saw mu I thought $\mu$ which also unfortunately crops up in the Hubbard model literature ( $\mu$ is the chemical potential). u is just the usual Hubbard U I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I rename mu to u ? There is already a capital U so I'm not sure if it'll cause more confusion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should just be u? They use capital U to mean something else in the paper.

Copy link
Collaborator Author

@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.

@fdmalone I've addressed all of your comments and also updated the notebook to show comparison of T-complexity costs obtained by our SELECT / PREPARE gates with the formulas given the paper. Specifically, the T-complexity for SELECT matches exactly (10*N + logN) and for PREPARE the paper only specifies an asymptotic cost of O(logN) whereas we demonstrate exact constant factors of 32 * logN in the paper.

I've also made the SVG diagrams nicer to include the T-complexity cost for each operation within the diagram. This is helpful to visualize the contribution of each operation in the decomposition.

This is ready for a re-review, PTAL!

@tanujkhattar
Copy link
Collaborator Author

tanujkhattar commented May 23, 2023

@fdmalone I also fixed the formula for calculating m_bits for heisenberg limited phase estimation (which I will move to a separate gate in a follow up PR).

Now, for a 20 x 20 2D Hubbard model grid, the end to end resource costs for heisenberg limited phase estimation using constants same as Table-IV of the paper gives the following resource costs:

T-count:   4.90109e+09
Rotations: 9.43787e+06
Cliffords: 2.31972e+10

Comparing to Table-IV, this is now much closer than the approximated number of 1.2e10. I claim that our number now is more accurate because the paper does a few upper bound approximations and this difference can be accounted for if we take just 2 extra bits of precisions when doing phase estimation.

image

"plt.xlabel('N')\n",
"plt.ylabel('T-costs')\n",
"plt.title('$SELECT_{Hubbard}$')\n",
"plt.plot(x, y, label='$10 * N + 14 * logN - 8$')\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I might just add marker="o" here or your favourite symbol. It's nice to see the specific points. But feel free to ignore.

Copy link
Collaborator

@fdmalone fdmalone left a comment

Choose a reason for hiding this comment

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

LGTM % optional markers in plot, what are the [@t:28,...] bits in the controls? Screenshot 2023-05-23 at 10 33 07 AM

@tanujkhattar
Copy link
Collaborator Author

what are the [@t:28,...] bits in the controls?

I updated the plotting code to also print the resource counts (number of T-gates and rotation gates) for each gate in the circuit. This is indicated by setting an additional flag when plotting the decomposition of an operation - display_gate_and_compilation(select, include_costs=True)

@tanujkhattar tanujkhattar enabled auto-merge (squash) May 23, 2023 17:37
Comment on lines +67 to +69
"metadata": {
"cq.autogen": "_make_SelectHubbard.md"
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

so these cells were originally auto-generated using the jupyter autogen functionality in my PR. can you add their entries back in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we have support for auto generating multiple cells (like for SELECT and PREPARE) using the autogen feature? I thought we were restricted to the simpler cases of generating 1 cell per notebook (eg: what was done in _make_SelectHubbard ) and thus I decided to remove tha autogen functionality.

@tanujkhattar tanujkhattar disabled auto-merge May 23, 2023 17:44
"plt.xlabel('N')\n",
"plt.ylabel('T-costs')\n",
"plt.title('$PREPARE_{Hubbard}$')\n",
"plt.plot(x, y_t, label='$O(logN)$ T-cost', marker=\"o\")\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find these labels confusing. the first is the actual T cost, right? so why is it labeled with big-O?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, because we don't have a simple formula for the exact T-cost since PrepareUniformSuperposition's cost depends on the factorization of the integer. Thus, it's upper bounded by O(logN) as given in the paper. I also plot an upper bounding constant.


Args:
x_dim: the number of sites along the x axis.
y_dim: the number of sites along the y axis.
Copy link
Collaborator

Choose a reason for hiding this comment

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

document control_val; should this be cv like elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, but I want to punt the renaming of control_val to cvs for a later PR since it would also change the interface from Optional[int] to Tuple[int, ...].

@tanujkhattar tanujkhattar merged commit 65bc8ec into main May 23, 2023
@mpharrigan mpharrigan deleted the hubbard_qubitization branch November 20, 2023 20:02
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.

Add notebook simulating Hubbard Model using Qubitization

4 participants