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

Pj/dta2 412/update detailed hardware model #157

Merged
merged 96 commits into from
Jul 15, 2024

Conversation

pediejo
Copy link
Collaborator

@pediejo pediejo commented Jul 9, 2024

Description

The purpose of this PR is to enable making detailed and accurate resource estimates for the DetailedIonTrapArchitectureModel (e.g. numbers of ions used for different purposes). The implementation of this PR led us to realize how to make a more tight accounting of resources at the logical architecture level. Thus, there have also been changes to how the number of qubits and surface code cycles are counted in the space vs time optimal compilations. We split the explanation of these changes in two:

Detailed Ion Trap Architecture Changes

Challenge: The challenge is that the numbers of ions in each elementary logic unit (ELU) depend on the functional designation of that ELU (e.g. data ELU vs bus ELU). Accordingly, the get_hardware_resource_estimates method requires information about the numbers of these ELUs. The previous version of BenchQ did not expose this accounting.

Solution: To enable this accounting, several objects have been introduced:

  • BusArchitectureResourceInfo: This data class stores resource information about the quantum computation after it has been compiled to this logical architecture and before it has been compiled to the physical architecture. As such, the object serves as a resource estimate for a kind of intermediate representation that could apply in principle to multiple physical architectures (assuming they have the same physical error rate).
  • ELUResourceInfo: This data class is specific to ion traps and stores information about the counts of ions for different uses within the ELU.
  • DetailedIonTrapArchitectureResourceInfo: This data class stores the ELUResourceInfo objects for each of the ELU designations in the architecture.

The functions used to account for the intra-ELU ion usage were developed by Ilia Khait and implemented by @pediejo.

Logical Architecture Resource Accounting Changes

Challenge: In generating resources using this updated accounting, we noticed that the counts for the numbers of magic state factories in the time optimal case were quite high.

Solution: We now loop through each subroutine and each layer of each subroutine to determine the maximum number of parallel T measurements that would need to be made at any one time and use this to determine the time-optimal magic state factory counts. For the space-optimal accounting, there is just one magic state factory and so all T measurements are made sequentially. Furthermore, the logic for estimating the space-optimal vs time-optimal cases has been simplified and diagrams have been added to explain the accounting. Lastly, in the estimate_resources_from_compiled_implementation function, the logical architecture resource info object is computed, used to get the hardware resource estimates, and then appended to the output GraphResourceInfo data class. This exposes the logical architecture resource info more readily to users.

General notes

  • Several names have been updated for clarification (e.g. "Tstate-to-Tgate"->"T measurement", "entanglement"->"graph state prep", code_distance->data_and_bus_code_distance)
  • The QubitAllocation functionality was removed and replaced by the logical architecture resource info object.
  • Tests have been added for the new detailed ion trap functionality and the logical architecture resource accounting.

Please verify that you have completed the following steps

  • [] I have self-reviewed my code.
  • [] I have included test cases validating introduced feature/fix.

@pediejo pediejo requested a review from max-radin as a code owner July 9, 2024 16:14
@pediejo pediejo requested a review from KaterinaGratsea July 9, 2024 16:14
@pediejo pediejo requested a review from max-radin July 11, 2024 12:20
Copy link
Collaborator

@max-radin max-radin left a comment

Choose a reason for hiding this comment

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

@pediejo it looks like the changes to the ResourceInfo docstring did not go through, maybe you have some uncommitted or unpushed changes? Otherwise looks good!

Copy link

github-actions bot commented Jul 11, 2024

🚀 Code Coverage

-------------------------------------------------------------------------------
You are using PYTHON: my_little_venv/bin/python3
Python Version: Python 3.11.9
Repository: https://github.com/zapatacomputing/benchq
Python Modules Covered: src.benchq/problem_embeddings/block_encodings src.benchq/problem_embeddings/qaoa src.benchq/problem_embeddings/time_marching src.benchq/problem_embeddings/qsp src.benchq/problem_embeddings/trotter src.benchq/algorithms/data_structures src.benchq/algorithms/gsee src.benchq/problem_ingestion/solid_state_hamiltonians src.benchq/problem_ingestion/plasma_hamiltonians src.benchq/problem_ingestion/molecular_hamiltonians src.benchq/compilation/graph_states src.benchq/compilation/circuits
-------------------------------------------------------------------------------
my_little_venv/bin/python3 -m coverage report --show-missing
Name                                                                                    Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------------------------------------------------
src/benchq/algorithms/data_structures/algorithm_implementation.py                          20      1    95%   37
src/benchq/algorithms/data_structures/error_budget.py                                      19      0   100%
src/benchq/algorithms/gsee/ld_gsee.py                                                      15      0   100%
src/benchq/algorithms/gsee/qpe_gsee.py                                                     16     16     0%   1-24
src/benchq/algorithms/profolio_optimization.py                                              6      6     0%   4-27
src/benchq/algorithms/time_evolution.py                                                    30      0   100%
src/benchq/compilation/circuits/compile_to_native_gates.py                                121      1    99%   149
src/benchq/compilation/circuits/pyliqtr_transpilation.py                                   32      0   100%
src/benchq/compilation/graph_states/circuit_compilers.py                                   36     15    58%   14-19, 92-93, 97-104
src/benchq/compilation/graph_states/compiled_data_structures.py                            54      1    98%   102
src/benchq/compilation/graph_states/implementation_compiler.py                             42      4    90%   86-89
src/benchq/compilation/graph_states/initialize_julia.py                                    14      0   100%
src/benchq/compilation/graph_states/substrate_scheduler/python_substrate_scheduler.py      30      6    80%   36, 44, 52, 57-59
src/benchq/conversions/_circuit_translations.py                                            28      1    96%   53
src/benchq/conversions/_openfermion_pyliqtr.py                                             18      0   100%
src/benchq/conversions/_operator_translations.py                                           30      4    87%   35, 40, 45, 58
src/benchq/decoder_modeling/decoder.py                                                     48      1    98%   116
src/benchq/decoder_modeling/decoder_resource_estimator.py                                  30      0   100%
src/benchq/magic_state_distillation/autoccz_factories.py                                   45      0   100%
src/benchq/magic_state_distillation/litinski_factories.py                                   9      0   100%
src/benchq/magic_state_distillation/small_footprint_factories.py                            8      8     0%   1-81
src/benchq/mlflow/data_logging.py                                                          44      1    98%   43
src/benchq/problem_embeddings/block_encodings/double_factorized_hamiltonian.py             14      0   100%
src/benchq/problem_embeddings/block_encodings/offset_tridiagonal.py                        27      0   100%
src/benchq/problem_embeddings/block_encodings/offset_tridiagonal_utils.py                  40      0   100%
src/benchq/problem_embeddings/qaoa/_qaoa.py                                                14      4    71%   47-50
src/benchq/problem_embeddings/qpe.py                                                       29      0   100%
src/benchq/problem_embeddings/qsp/_lin_and_dong_qsp.py                                     34      0   100%
src/benchq/problem_embeddings/qsp/_qsp.py                                                 114      2    98%   313, 315
src/benchq/problem_embeddings/qsp/get_qsp_phases.py                                       193    184     5%   79-182, 203-225, 239-261, 277-284, 304-371, 397-428
src/benchq/problem_embeddings/qsp/get_qsp_polynomial.py                                    42      3    93%   112-115
src/benchq/problem_embeddings/quantum_program.py                                          106     28    74%   42, 56-59, 78, 86, 96, 143-149, 152-155, 169-176, 184-188
src/benchq/problem_embeddings/time_marching/_time_marching.py                             107     14    87%   75, 287-314
src/benchq/problem_embeddings/time_marching/compression_gadget.py                          13      0   100%
src/benchq/problem_embeddings/time_marching/matrix_properties.py                           13      0   100%
src/benchq/problem_embeddings/trotter/_trotter.py                                          12      2    83%   13, 26
src/benchq/problem_ingestion/hamiltonian_from_file.py                                      74      2    97%   94, 120
src/benchq/problem_ingestion/molecular_hamiltonians/_common_molecules.py                   13      0   100%
src/benchq/problem_ingestion/molecular_hamiltonians/_compute_lambda.py                     18      0   100%
src/benchq/problem_ingestion/molecular_hamiltonians/_hamiltonian_generation.py            161     11    93%   136, 139, 145, 148, 167, 230, 240, 322-324, 539
src/benchq/problem_ingestion/plasma_hamiltonians/vlasov.py                                 12      0   100%
src/benchq/problem_ingestion/solid_state_hamiltonians/fermi_hubbard.py                      7      3    57%   17-29
src/benchq/problem_ingestion/solid_state_hamiltonians/heisenberg.py                        20     14    30%   19-44
src/benchq/problem_ingestion/solid_state_hamiltonians/ising.py                             90     43    52%   17-24, 42-49, 53-75, 79-91
src/benchq/quantum_hardware_modeling/devitt_surface_code.py                                14      0   100%
src/benchq/quantum_hardware_modeling/fowler_surface_code.py                                 6      0   100%
src/benchq/quantum_hardware_modeling/hardware_architecture_models.py                      117      6    95%   50, 93, 207-211, 264, 270
src/benchq/resource_estimators/azure_estimator.py                                          42     29    31%   19, 58-73, 86-119
src/benchq/resource_estimators/default_estimators.py                                       69     43    38%   129-131, 164, 178-192, 234-281, 292-309
src/benchq/resource_estimators/graph_estimator.py                                         129      9    93%   131, 312, 385-389, 405-417
src/benchq/resource_estimators/openfermion_estimator.py                                    61      2    97%   68, 172
src/benchq/resource_estimators/resource_info.py                                            75      0   100%
src/benchq/timing.py                                                                       17      0   100%
src/benchq/visualization_tools/plot_graph_state.py                                         76     69     9%   19-230
src/benchq/visualization_tools/plot_substrate_scheduling.py                                28     15    46%   26-47
src/benchq/visualization_tools/resource_allocation.py                                     119     53    55%   112-115, 119-143, 146-220
---------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                    2601    601    77%

@max-radin max-radin self-requested a review July 15, 2024 18:37
@pediejo pediejo merged commit abad8c9 into main Jul 15, 2024
6 checks passed
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.

3 participants