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

Add Azure model #568

Merged
merged 43 commits into from
Dec 19, 2023
Merged

Add Azure model #568

merged 43 commits into from
Dec 19, 2023

Conversation

NoureldinYosri
Copy link
Contributor

Reproduction of the estimates in https://arxiv.org/abs/2211.07629

This PR replaces #327 and uses the infrastrucutre introduced in #357, #378 and #461

fixes #269

@NoureldinYosri NoureldinYosri changed the title azure model Add Azure model Dec 7, 2023
Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

some initial nits

qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
qualtran/surface_code/azure_cost_model.ipynb Show resolved Hide resolved
qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
"\n",
"Where $a$ and $b$ are constants that depend on the gate set and the approximation protocol. Table 1 of [Kliuchnikov et al](https://arxiv.org/abs/2203.10064) gives estimates for those constants for different combinations of gate sets and protocols.\n",
"\n",
"In [Beverland et al](https://arxiv.org/abs/2211.07629), Although they don't specify the approximation algorithm their constants of $a=0.53, b=5.3$ are closest to the mixed fallback approximation protocol with a Clifford+T gate set constants of $a=0.53, b=4.86$. "
Copy link
Collaborator

Choose a reason for hiding this comment

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

confusing sentence construction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rewritten

"source": [
"### Magic State Factory\n",
"\n",
"The magic state factory in our case is a T-state factory. The paper describes 15-to-1 factories in Appendix C, but only the overall summary in Table VII in terms of physical qubits count and generation time is used in estimation in Appendix F."
Copy link
Collaborator

Choose a reason for hiding this comment

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

physical qubits count -> physical qubit count

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also don't really understand what's trying to be expressed in this paragraph. Overall: this notebook should stand alone without having intimate knowledge of the appendices of the referenced paper.

"Appendix F" is used in many places in the write-up. I would probably put something near the top

The paper describes the formulas used for estimating cost in the various appendices. The final estimates are brought together (??) in Appendix F. Throughout, we reproduce the costs from the paper; in particular Appendix F.

Then throughout, don't say appendix F unless you're referring to an equation or something.

Only physical qubit count and generation time is used in the estimation in the Beverland paper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
"\n",
"Other authors (e.g. [Fowler, Gidney](https://arxiv.org/abs/1808.06709)) assume that the entire process takes a specific time (e.g. $\\approx 1\\mu s$).\n",
"\n",
"In Qualtran, we use \"error detection circuit time\" rather than fall to the low level hardware parameters. "
Copy link
Collaborator

Choose a reason for hiding this comment

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

"error detection circuit time" isn't what the parameter is actually called. These should be consistent (or consistent-ish).

I like that you contrast the two ways of putting in the physical assumptions. It would be nice for this final sentence to say which one Qualtran follows. If I understand correctly, we're using a Gidney Fowler parameter even though it has this decomposition in the azure model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rewritten

"metadata": {},
"source": [
"Comparing our esimates of $Q = 230, C_{min} = 1.8 \\times 10^5, M = 6 \\times 10^5$ to the paper estimates of \n",
"$Q = 230, C_{min} = 1.5 \\times 10^5, M = 2.4 \\times 10^6$. We find a match for $Q$ and $C_{min}$ however we are off by 4x for the number of T gates $M$.\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

explain the cause of this discrepancy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is the next paragraph

qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
"metadata": {},
"outputs": [],
"source": [
"'algorithm run time of %g seconds' % (qec.error_detection_circuit_time_us(d) * 1e-6 * c_min)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

use f-strings or .format()

qualtran/surface_code/azure_cost_model.ipynb Outdated Show resolved Hide resolved
Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

can you remove the doc rst file changes from this PR. I need to think about organization. Otherwise, looks good to merge

@NoureldinYosri NoureldinYosri enabled auto-merge (squash) December 15, 2023 20:06
@NoureldinYosri NoureldinYosri merged commit 42e0e85 into main Dec 19, 2023
9 checks passed
fpapa250 pushed a commit to fpapa250/Qualtran that referenced this pull request Jan 19, 2024
mpharrigan added a commit that referenced this pull request Jan 30, 2024
* Add SimpleAddConstant bloq

* Address many comments on the simple add constant bloq

* Make modifications to SimpleAddConstant to address concerns

* Use bit tools functions for getting bitstrings

* Reformat on_classical_vals and fix nits

* Add test failing due to uint to float bug

* Stash testing changes before adding MultiControlX

* Add MultiControlX() bloq with functional classical simulation

* Small linting changes

* Add one more correctness test

* Add SimpleAddConstant bloq

* Address many comments on the simple add constant bloq

* Make modifications to SimpleAddConstant to address concerns

* Use bit tools functions for getting bitstrings

* Reformat on_classical_vals and fix nits

* [autodoc] multi_control_multi_target_pauli  (#532)

* sympy in autogen

* bloq example for multi_control_multi_target_pauli

* add to docs

* [autodoc] addition bloqs (#519)

* import sympy everywhere

* default directory for notebooks

* Add bloq examples for addition module

* Factor out generic bloqs for testing (#564)

* Use Oracles for sparse select and prepare (#546)

* Use select and prepare oracle.

* Format.

* Fix imports.

* Fix argument.

* Fix docstring.

* Address review comments.

---------

Co-authored-by: Matthew Harrigan <[email protected]>

* Adjoint protocol (#565)

* Adjoint protocol

* get block encoding working

* Address review 1

* Pylint

* Fixes bug with addition endianness. (#576)

* Fix bug with addition endianness.

* Test no decompose in same unit test as decompose.

---------

Co-authored-by: Matthew Harrigan <[email protected]>

* Bump jupyter-server from 2.11.0 to 2.11.2 in /dev_tools/requirements/envs (#563)

Bump jupyter-server in /dev_tools/requirements/envs

Bumps [jupyter-server](https://github.com/jupyter-server/jupyter_server) from 2.11.0 to 2.11.2.
- [Release notes](https://github.com/jupyter-server/jupyter_server/releases)
- [Changelog](https://github.com/jupyter-server/jupyter_server/blob/main/CHANGELOG.md)
- [Commits](jupyter-server/jupyter_server@v2.11.0...v2.11.2)

---
updated-dependencies:
- dependency-name: jupyter-server
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Sparse decomp select (#547)

* Use select and prepare oracle.

* Format.

* Fix imports.

* Fix argument.

* Fix docstring.

* Sparse SELECT decomposition.

* Temporarily delete sparse notebook.

* Remove unused import.

---------

Co-authored-by: Matthew Harrigan <[email protected]>

* Initial overview documentation of protocols (#504)

* Use public default fallbacks

* Initial overview documentation of protocols

* reword

---------

Co-authored-by: Fionn Malone <[email protected]>

* An assortment of generalizers (#554)

* Generalizers

* revert this one

* pylint

* Add test failing due to uint to float bug

* Stash testing changes before adding MultiControlX

* Add resource estimation chem tutorial (#529)

* Add block encoding bloq.

* Fix dagger method.

* Fix evolve if bloq has no adjoint.

* Fix CSwap wiresymbols.

* Work on tidy THC prepare.

* Use SelectOracle in THC.

* Refactor THC prepare.

* Use CSwap not CSwapApprox.

* Fix THC Prepare.

1. Use prepare oracle and expose necessary ancilla.
2. Use CSwaps not CSwapApprox.
3. Use bitsize as input for contstructor rather than epsilon.

* Fix docs.

* Use new autodoc.

* Move control register to selection register.

The control registers for the SelectOracle are used for building a
controlled walk operator, not any internal controls used by select.

* Add control_val to THC select.

* Remove print.

* Resource estimation tutorial.

* Tidy.

* Reuse controlled Z block for DF and THC.

* Tidy up notebook.

* Fix format error.

* Fixup merge

* Remove oks.

---------

Co-authored-by: Matthew Harrigan <[email protected]>

* Sparse decomposition for  prepare (#548)

* Use select and prepare oracle.

* Format.

* Fix imports.

* Fix argument.

* Fix docstring.

* Sparse SELECT decomposition.

* Temporarily delete sparse notebook.

* Decomposition for sparse prepare.

* Add back notebook.

* Use algorithm from reference rather than triu.

* Remove duplicate property.

* Beware thresholding in assertion.

* Fix fp float multiplication formula.

* Address review comment.

* Rename select (#552)

* Single factorization bloqs.

* Use OF test params.

* Better unit tests.

* Better tests.

* Remove unused import.

* Fix QROM data size for SF and add note / reference.

* Remove duplicate num_aux / unused variables.

* Add missing __init__.

* Add missing init / license.

* Format.

* Use select and prepare oracle.

* Format.

* Fix imports.

* Fix argument.

* Fix docstring.

* Sparse SELECT decomposition.

* Temporarily delete sparse notebook.

* Decomposition for sparse prepare.

* Add back notebook.

* Address review comments.

* Fix test.

* Replace select.py with select_bloq.py.

* Errant select.py.

* Remove aspirational factory method.

* Fix notebook errors.

* Fix lint error.

---------

Co-authored-by: Matthew Harrigan <[email protected]>

* Add Azure model (#568)

* [physical costing] Grid search best parameters with multiple CCZ factories (#561)

* grid search best params

* multifactory added, some documentation of CCZ grid search, THC compilation notebook

* fix docstrings and minor edits

* Added references

* format

* Remove outdated test, fix docstrings

* format

* format

* gitignore vscode settings

* add test based on THC

* format

---------

Co-authored-by: Matthew Harrigan <[email protected]>

* Rename qro(a)m target registers to avoid name collision with named qubits (#577)

* Rename qro(a)m target registers to avoid name collision with named qubits.

If the number of data sets is >= 10 collisions could occur (see #556).

* Fix alt_mu/nu register size.

* Add link to issue.

* Fix bug in auto generated `_decompose_with_context_` from `decompose_bloq` in GateWithRegisters (#542)

* Fix bug in auto generated _decompose_with_context_ from decompose_bloq in GateWithRegisters

* cleanup

* Add test for interop qubit manager

* Add test for auto generated decompose from context

* Idiomatic adjoints for bloqs (#566)

* Basic bloqs support adjoint

* And.uncompute

* Overhaul

* validate MultiAnd fix

* Fix porting util example

* Alloc/Free adjoint

* Revert comparison.py overhaul

* Lint

* Fix notebook's usage of MultiAnd

---------

Co-authored-by: Fionn Malone <[email protected]>

* More idiomatic adjoint changes (#583)

* [autodoc] Chemistry algorithms (#578)

* Use autodoc in first quantization.

* Remove old doc autogeneration.

* Remove duplicate select.

* Add autodocs.

* Autodoc for trotter.

* Fix format and no return.

* Add trotter bloqs notebook and fix some typos.

* Add THC too.

* Chebyshev polynomial block encoding (#510)

* Add chebyshev polynomial block encoding.

Adds a Reflection bloq which is quite common (often used to
implement 2|0><0| - 1). This is a multi-controlled pauli Z up to some
phases, wrap this in a bloq to make nicer diagrams.

Also update notebook for MCP following autodocgen.

* Add test.

* pretty_name - > short_name.

* Remove sparse select. (#586)

* Remove sparse select.

* Fix lint error.

* Add `QFTPhaseGradient` which synthesizes rotations via addition into gradient register (#505)

* Add QFTPhaseGradient which synthesizes rotations via addition into gradient register

* Address comments by Matt and Fionn

* Add tests for PlusEqualProduct and fix bug in on_classical_vals

* Routine maintenance of the docs (#584)

* Update generated notebooks v1

* Update generated notebooks v2

* document how to preview the docs

* Support inline block math in html output

* Rename misspelled notebook

* Include notebooks in toc

* Add `HammingWeightPhasingViaPhaseGradient` Bloq (#509)

* Add HammingWeightPhasingViaPhaseGradient Bloq

* Address nits and comments

* Fix docstring

* Fix docstrings and add more tests

* Add tutorial on writing chemistry algorithms in qualtran (#558)

* Fix imports.

* Sparse SELECT decomposition.

* Decomposition for sparse prepare.

* Add back notebook.

* Replace select.py with select_bloq.py.

* WIP.

* Finish tutorial.

* Allow a block size parameter for black box qroam.

* Fix missing import.

* Fix lint errors.

* Add test for chem tutorials and run notebooks.

* Fix notebook.

* Fix lint errors.

* Fix test.

* Remove errant notebook.

* Fix argument.

* suppress output from `assert_valid_bloq_decomposition`

* Address review comments.

---------

Co-authored-by: Matthew Harrigan <[email protected]>

* Move ControlledBloq to `_infra` (#587)

Co-authored-by: Fionn Malone <[email protected]>

* Update NDArray proto and serialization to avoid running eval on serialized code (#588)

* Update NDArray proto and serialization to avoid running eval on serialized code

* Fix format

* GQSP: Implement complementary polynomial computation (#581)

* implement complementary polynomial computation (theorem 4 of https://arxiv.org/abs/2308.01501)

* fix pylint

* minor refactor

* fix tests for real polynomials

* run more tests with symbolic matrices.

* add more comments

* fix lint error

* fix typos + add comment on why larger_roots / smaller_roots are swapped

* remove np.around for Q

* typo complimentary -> complementary

* Add SimpleAddConstant classical sim tests

* Fix some unit tests to work with merged MultiControlX()

* Silencing pylint warnings

* Added tracking issues for TODOs

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Matthew Harrigan <[email protected]>
Co-authored-by: Fionn Malone <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Noureldin <[email protected]>
Co-authored-by: Stefano Polla <[email protected]>
Co-authored-by: Tanuj Khattar <[email protected]>
Co-authored-by: Anurudh Peduri <[email protected]>
@mpharrigan mpharrigan deleted the azure_model branch February 27, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Physical costing cleanup
2 participants