-
Notifications
You must be signed in to change notification settings - Fork 120
Implement Y basis initialization/measurement block #719
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
Open
inmzhang
wants to merge
45
commits into
main
Choose a base branch
from
feat/y-basis-block
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
2935073
Add `gen` as dependency
inmzhang 08b756d
Move `PauliBasis` and `ExtendedBasis` enums into `tqec.utils.enums`
inmzhang 1b3fe8b
Add S gate teleportation to gallery
inmzhang 2376a4b
Use uppercase for `PauliBasis` enum values
inmzhang e164975
Add Y basis supports for memory and move rotation gallery function
inmzhang ab7f183
Implement y-basis circuit with `gen`
inmzhang c07f161
Merge branch 'main' into feat/y-basis-block
inmzhang cc07ce8
Rename `Block` as `LayeredBlock`
inmzhang 3e65cb9
Fix the issues resulted from uppercasing the `PauliBasis` and `Extend…
inmzhang 7e17f0a
Introduces `InjectedBlock` type and `Block` base type
inmzhang 0bef212
Add spec information for `YHalfCube`
inmzhang 67b4398
Implement Y basis block generator
inmzhang a09b842
Enable adding `InjectedBlock` instances to `TopologicalComputationGraph`
inmzhang 715ddf4
Do not shift the block graph's z position and attach layer's z inform…
inmzhang 6a8ff75
Add Y observable information to abstract observable
inmzhang 89ff33b
Fix typo
inmzhang d54f927
Fix left PauliBasis uppercase issue
inmzhang 2263bc0
Deduplicate position z values to fix tests
inmzhang 55a1d02
Fix abstract observable test
inmzhang 12922dd
Fix typo
inmzhang 816376f
Add observable instructions at the factory level
inmzhang 136e7bd
Add very ugly proof of concept implementation of tree circuit injection
inmzhang 468e9b6
refactor the injection code but still complex
inmzhang 75fb81b
Allow empty sequenced layers and fix tests
inmzhang d82359a
Split large chunks into smaller one to get the auto-solved measuremen…
inmzhang b42852b
Merge branch 'main' into feat/y-basis-block
inmzhang a352245
Add S gate gallery notebook
inmzhang 26699d9
Bump the detector database version as a breaking change
inmzhang 6e4d129
Apply suggestions from code review
inmzhang 1b1fe5e
Add `pymatching>=2.3.1` to docs dependency group and bump pymatching …
inmzhang 6f00fe6
Fix ax label
inmzhang 90f7f1d
Do not bump major version of detector database
inmzhang dd04ef2
remove empty moments after building circuit
inmzhang e2484e1
Update links in the notebook
inmzhang 5719232
Merge branch 'main' into feat/y-basis-block
inmzhang 3f3f7de
Add S gate gallery to `index.rst`
inmzhang 28f6e8d
Y half cube updates (#736)
KabirDubey 08acc94
Revert the changes of class abstraction
inmzhang b8ef1e5
Do not early return when the Y-port check passes and revert changes m…
inmzhang 020a151
improve test coverage
inmzhang 15365fe
Merge main
inmzhang 92476ed
xor cube top observable qubits together
inmzhang bc034bb
Add test script
inmzhang 4d0afbb
dirty fix for automatic flow solving
inmzhang bcad2d8
Merge branch 'main' into feat/y-basis-block
inmzhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| from tqec import BlockGraph, NoiseModel, compile_block_graph | ||
| from tqec.compile.convention import FIXED_BOUNDARY_CONVENTION | ||
| from tqec.utils.position import Position3D | ||
|
|
||
| g = BlockGraph() | ||
|
|
||
| n0 = g.add_cube(Position3D(0, 0, 0), "ZZX") | ||
| n1 = g.add_cube(Position3D(1, 0, 0), "XZX") | ||
| n2 = g.add_cube(Position3D(-1, 0, 0), "XZX") | ||
| n3 = g.add_cube(Position3D(0, 1, 0), "ZXX") | ||
| n4 = g.add_cube(Position3D(0, -1, 0), "ZXX") | ||
|
|
||
| n5 = g.add_cube(Position3D(1, 0, 1), "Y") | ||
| n6 = g.add_cube(Position3D(-1, 0, 1), "Y") | ||
| n7 = g.add_cube(Position3D(0, 1, 1), "Y") | ||
| n8 = g.add_cube(Position3D(0, -1, 1), "Y") | ||
|
|
||
| g.add_pipe(n0, n1) | ||
| g.add_pipe(n0, n2) | ||
| g.add_pipe(n0, n3) | ||
| g.add_pipe(n0, n4) | ||
| g.add_pipe(n1, n5) | ||
| g.add_pipe(n2, n6) | ||
| g.add_pipe(n3, n7) | ||
| g.add_pipe(n4, n8) | ||
|
|
||
| correlation_surface = g.find_correlation_surfaces()[0] | ||
| g.view_as_html( | ||
| "test.html", show_correlation_surface=correlation_surface, pop_faces_at_directions=("+Z", "-Y") | ||
| ) | ||
|
|
||
| cg = compile_block_graph(g, observables=[correlation_surface], convention=FIXED_BOUNDARY_CONVENTION) | ||
| circuit = cg.generate_stim_circuit(k=3) | ||
|
|
||
| # circuit.to_file("sliding_annotated.stim") | ||
| noisy_circuit = NoiseModel.uniform_depolarizing(1e-3).noisy_circuit(circuit) | ||
| # noisy_circuit.detector_error_model().to_file("sliding.dem") | ||
| # explained = noisy_circuit.explain_detector_error_model_errors( | ||
| # dem_filter=stim.DetectorErrorModel("error(0.001931182734310662227) D1 D3 D20 D22") | ||
| # ) | ||
|
|
||
| # noisy_circuit.to_file("test2.stim") | ||
| # noisy_circuit.detector_error_model().to_file("test.dem") | ||
| # noisy_circuit.detector_error_model( | ||
| # decompose_errors=True, block_decomposition_from_introducing_remnant_edges=True | ||
| # ) | ||
| # errors = noisy_circuit.explain_detector_error_model_errors( | ||
| # dem_filter=stim.DetectorErrorModel("error(6.669779853440971351e-05) D494 D604 D611 D640 D673") | ||
| # ) | ||
| # print(errors[0]) | ||
|
|
||
|
|
||
| logical_error = noisy_circuit.shortest_graphlike_error( | ||
| ignore_ungraphlike_errors=False, canonicalize_circuit_errors=True | ||
| ) | ||
| # html_str = gen.stim_circuit_html_viewer(noisy_circuit, known_error=explained) | ||
| # html_str = gen.stim_circuit_html_viewer(noisy_circuit, known_error=logical_error) | ||
| # with open("stim_circuit.html", "w") as f: | ||
| # print(html_str, file=f) | ||
| print("Length of shortest graphlike error:", len(logical_error)) | ||
|
|
||
|
|
||
| # SAVE_DIR = Path("results") | ||
| # | ||
| # | ||
| # def generate_graphs() -> None: | ||
| # zx_graph = g.to_zx_graph() | ||
| # | ||
| # stats = start_simulation_using_sinter( | ||
| # g, | ||
| # range(1, 4), | ||
| # list(numpy.logspace(-4, -1, 10)), | ||
| # NoiseModel.uniform_depolarizing, | ||
| # manhattan_radius=2, | ||
| # observables=[correlation_surface], | ||
| # num_workers=cpu_count(), | ||
| # max_shots=1_000_000, | ||
| # max_errors=5_000, | ||
| # decoders=["pymatching"], | ||
| # print_progress=True, | ||
| # ) | ||
| # | ||
| # for i, stat in enumerate(stats): | ||
| # fig, ax = plt.subplots() | ||
| # sinter.plot_error_rate( | ||
| # ax=ax, | ||
| # stats=stat, | ||
| # x_func=lambda stat: stat.json_metadata["p"], | ||
| # group_func=lambda stat: stat.json_metadata["d"], | ||
| # ) | ||
| # plot_observable_as_inset(ax, zx_graph, correlation_surface) | ||
| # ax.grid(axis="both") | ||
| # ax.legend() | ||
| # ax.loglog() | ||
| # ax.set_title("Logical CNOT Error Rate") | ||
| # ax.set_xlabel("Physical Error Rate") | ||
| # ax.set_ylabel("Logical Error Rate") | ||
| # fig.savefig(SAVE_DIR / f"ghz_result_observable_{i}.png") | ||
| # | ||
| # | ||
| # def main(): | ||
| # SAVE_DIR.mkdir(exist_ok=True) | ||
| # generate_graphs() | ||
| # | ||
| # | ||
| # if __name__ == "__main__": | ||
| # main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.