-
-
Notifications
You must be signed in to change notification settings - Fork 32
✨ Add Hybrid Mapping Extension + Hybrid Synthesis #832
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
Merged
Merged
Changes from all commits
Commits
Show all changes
412 commits
Select commit
Hold shift + click to select a range
70b91c8
🔥 removed AOD post optimizations
lsschmid c85d58a
🐛 avoid move and passby in same moveGroup
lsschmid a615144
🐛 fixed aod arrangement bugs.
lsschmid 00832ef
⚡️ slightly speed up bridge gate computation
lsschmid bd43bcf
Changed useBridge to a parameter maxDistanceBridge
lsschmid 1f64624
🐛 Fixed bug where two moves using same CoordIdx hat wrong ordering
lsschmid 6251949
🐛 Fixed missing qubits at schedule output due to use of set
lsschmid 21252eb
🐛 fixed missing controls during passby
lsschmid 79459e9
✨ addec getHwQubits for vector additional to set
lsschmid 13d22f2
🐛 fixed bug where swap distance instead of euclidean distance is calc…
lsschmid 9a6cb96
🐛 fixed bug where passBy and move on same atom was in one moveGroup
lsschmid a7a3a28
✨ added weight paramter to control static vs dynamic mapping
lsschmid 2059284
🐛 fixed missing controls during flying ancilla
lsschmid 646a37f
🐛 Throw error if more than one FA is used
lsschmid 7f1fb02
🐛 Fixed bug where move is added to previous movegroup although atom s…
lsschmid c7f11ca
✅ updated tests
lsschmid 52fedc1
🐛 Fixed independence of PassBy and FA
lsschmid 4ba54c8
🐛 Fixed error where PassBy used FA info for swapped directions
lsschmid 7caa6b8
🐛 Fixed error where PassBy is not created when there are not FA
lsschmid fa649a4
✨ Improved result output including AOD parameters
lsschmid 635adbc
🐛 Fixed Bridge gates not correctly removed from FrontLayerGates
lsschmid cadabad
🐛 Avoid unnecessary moves
lsschmid 94fbebc
🐛 Fixed/improved routing comparisons
lsschmid b54f451
🐛 Fixed problem where move does not provide distance reduction but ot…
lsschmid a7b2720
🐛 Fixed error where FA CZ is applied to qubit at position not qubit f…
lsschmid f00dd69
🐛 Fixed error of wrong Flying Ancilla indexing. Also, add AOD movemen…
lsschmid e11f0b9
🐛 fixed wrong indexing when combining AOD moves.
lsschmid 18a9cc1
⚡️ Speed up finding move position by only checking a subset of the po…
lsschmid e480fa7
⚡️ Only compute single Bridge-Path.
lsschmid bdb4152
⚡️ Speed up computation of free Coordinats by book-keeping a list of …
lsschmid 24bd27a
🔀 finish merging
lsschmid f07f27f
⬆️ use modified main version of mqt-core
lsschmid 3667200
🔀 merged until june main
lsschmid e9f6da9
🔀 merged main
lsschmid f69c31f
🔀 fixed merge bugs
lsschmid 337b263
✨ updated bindings and add return of mapping stats
lsschmid 98742d0
Removed comments on SWAP/Bridge decomposition
lsschmid 3f216d3
updated python bindings
lsschmid 7afa6dd
fixed error where one move is done for free by other activations (mer…
lsschmid b7e7013
fixed dynamic fidelity comparison
lsschmid dbe866a
only compute bridges comparable to swaps
lsschmid 95172ca
updated bridge search
lsschmid ef9e356
Collect more moves by considering more best positions
lsschmid 181f028
compute move dist reduction only if one of the qubits is moved
lsschmid 61d7b77
Improved/fixed comparison between move and passby
lsschmid 613cdf1
reworked moveComb cost computation
lsschmid e6757fd
Reworked parallel move cost computation
lsschmid 84e5903
Merge branch 'main' into na-hybrid-merge-main
lsschmid 5e2cc70
✅ updated test because of changed file name
lsschmid 47c8c70
✅ updated tests for hybrid synthesis mapper
lsschmid 756ec97
✅ updated mapping tests
lsschmid 3c61748
🐛 Fixed bug where excluded free coordinates are returned.
lsschmid ca581bc
🐛 Fixed bug multiple atoms are moved to same free coord.
lsschmid 8c3cc23
✅ modified architecture to make it use flying ancillas.
lsschmid 7d4378d
🐛 Fixed missing copying of decay weights for the Synthesis.
lsschmid 1582b65
🐛 deactivate most routing methods for >2 qubit gates.
lsschmid 5d03e85
✅ reduced number of tests.
lsschmid 7ee6d12
🐛 Remove unused findClosestAncillaCoord method and related references.
lsschmid 750da0a
🔥 Remove unused findQtargetSet method and related references.
lsschmid 05e3c03
✅ added HardwareQubit test and removed some not used lines.
lsschmid fd9a225
✅ added Mapping tests.
lsschmid ffce9c3
✅ added Utils tests.
lsschmid 97be84d
✅ added architecture tests.
lsschmid 50301c6
🔥 removed unused Layer code.
lsschmid 2040c37
🔥 removed unused Definitions.
lsschmid bef4296
✅ added scheduler tests.
lsschmid 14da944
🔥 removed unused move group post-processing.
lsschmid 6c3b9b8
🧪 changed arch to have more aod conflicts and removed case of no aod …
lsschmid 0886bd8
🔥 removed unused code in mapper tests.
lsschmid 9804c9c
✅ added mapper tests to test exceptions.
lsschmid baa5cf6
✅ improved mapper tests to include more output options.
lsschmid b82afcd
✅ improved mapper tests to include catch more cases and removed unuse…
lsschmid aad1e7c
✅ tested missing methods of hyrbid synthesis mapper.
lsschmid 3ea7b6e
✅ fixed failing test on sparse arch.
lsschmid a3f945c
✅ added one long shuttling test to trigger more shuttling cases.
lsschmid 5e0edc1
🎨 reworked some clang tidy errors.
lsschmid 0c2e072
🎨 reworked pragma once
lsschmid a060d77
🎨 reworked clang tidy HardwareQubits
lsschmid 0dd8aaa
🎨 reworked clang tidy Animation
lsschmid a299a29
🎨 reworked clang tidy Utils
lsschmid 91e70b9
🎨 reworked clang tidy Scheduler
lsschmid 1bfe788
🎨 reworked clang tidy AtomLayer
lsschmid 6ea07af
📝 added descriptions
lsschmid 989a08d
📝 added descriptions for Utils
lsschmid 540dade
📝 added descriptions for Scheduler
lsschmid 7412ab5
📝 added descriptions for Layer
lsschmid ccaaf06
📝 added descriptions for Definitions.
lsschmid 277922d
📝 added descriptions for Architecture.
lsschmid 08c6ea3
📝 added descriptions for AodConverter.
lsschmid 4bab3f6
📝 added descriptions for Mapping.
lsschmid 9890597
📝 added descriptions for SynthesisMapper.
lsschmid 56c3a32
📝 added descriptions for HardwareQubits.
lsschmid 7523b1b
📝 added descriptions for Mapper.
lsschmid 8fb4df2
🎨 reworked clang tidy Architecture
lsschmid 806f43d
🎨 reworked clang tidy AodConverter.
lsschmid 6f25163
🎨 reworked clang tidy Mapping.
lsschmid 06f63ca
🎨 reworked clang tidy HybridSynthesisMapper.
lsschmid 78d2278
🎨 reworked clang tidy Animation.
lsschmid b38d45c
🎨 reworked clang tidy Mapper.
lsschmid c8832c8
🎨 reworked clang tidy Mapper.
lsschmid 15e3c72
🎨 reworked clang tidy tests.
lsschmid 39bef0b
🎨 reworked clang tidy warnings.
lsschmid ad4e692
Merge branch 'main' into na-hybrid-merge-main
lsschmid d047a2f
🐍 Update Python bindings and tests.
lsschmid 1d39661
🐍 Moved hybrid synthesis mapper test files.
lsschmid e38d209
🐍 update Python bindings for HybridMapper.
lsschmid a9db8ba
🐛 added missing reset of the mapper stats.
lsschmid 357e40a
🐛 added "display" to default naviz style
lsschmid 633d0ed
🐛 avoid loading if no flying ancillas configured.
lsschmid 3e539b5
🐛 fixed aod move speedup in animation.
lsschmid f19cb73
🔥removed hybrid-specific animation style.
lsschmid 8c2f0b8
🐛avoid duplication of circuits in python binding for SynthesisMapper.
lsschmid 873274e
🐛avoid adding ancilla register multiple times for HybridSynthesisMapper.
lsschmid fcb84fb
📝Added documentation for Hybrid Neutral Atom Mapper.
lsschmid d76698d
Merge branch 'refs/heads/main' into na-hybrid-merge-main
lsschmid 82a8daa
📝Added documentation for Hybrid Neutral to README.md
lsschmid 2d6b2e6
Merge branch 'refs/heads/main' into na-hybrid-merge-main
lsschmid 10f8ca7
📝Added documentation for Hybrid Neutral to README.md
lsschmid 2bf1f48
✅ removed randomness from ImpossibleSwaps test.
lsschmid a7273bf
🚨 Fix clang warnings.
lsschmid 2abb870
📝changed docstrings to make clear that qasm is returned.
lsschmid e39bde3
📝 fixed minor errors in documentation.
lsschmid 2f04afe
📝 clarify opToNaViz doc string.
lsschmid b960f62
🎨add additional check when initializing Sythesis Mapper.
lsschmid 9937893
📝fixed non-exisiting throw statement in doc string
lsschmid 9d53342
🎨 improved checks for initialization of Synthesis Mapper.
lsschmid 80ea226
🎨 handle case where no center can be found.
lsschmid 0d9a40a
🎨 avoid mapping to copy the Quantum Computation.
lsschmid 06a5549
🎨 added additional check for the Mapping.
lsschmid 825e573
🎨 add comment on max bridge size.
lsschmid d5f541e
🎨 converted cout to SPDLOG
lsschmid 1528131
🎨 removed default constructor of Mapper and pointer problems.
lsschmid 5511ab4
🎨 log if animation files are asked for without scheduling.
lsschmid 5be628a
🎨 improve error message for initial Mapping
lsschmid de669aa
🎨 added default initialization of PassBy and FA.
lsschmid fa6b22f
🐛 fixed error where flying ancilla is computed for mulitqubit gates.
lsschmid c8fd4ad
🔥 removed unused code.
lsschmid 52d4ac6
🎨 improve handling of wrong indices during animation creation.
lsschmid 0666ed1
🎨 improve structure of evalSynthesisSteps.
lsschmid 34c449a
🎨 avoid change of passed qc by creating a copy.
lsschmid 0ccfc91
🎨 assign also other triangle of adjacency matrix.
lsschmid 191ec1b
🎨 improve invalid handling during graphMatching.
lsschmid 69a9164
🎨 changed meaning/use of shuttlingSpeedFactor.
lsschmid 79d769f
🎨 create AnimationAtoms only if animation is generated.
lsschmid 582816d
✅ use temp paths in python tests.
lsschmid 082f9ee
🐍 fixed keep alive python binding
lsschmid d60d294
🎨 improve bookkeeping of removeHwQubit
lsschmid f3ceea7
🔥 removed unused DAG generation.
lsschmid 3250b27
🎨 update types in MoveToAodConverter for consistency
lsschmid eef6845
🐛 reset multiQubitGates for each new circuit.
lsschmid b609bd3
🐛 fix updateBlockedQubits call to use HwQubits struct
lsschmid fbc86c6
✏️ Fixed Typo in Variable name.
lsschmid 7cef35e
🎨 update documentation for adjacency matrix to clarify its purpose in…
lsschmid a9cea4b
🎨 update file saving documentation to specify output formats for anim…
lsschmid 024873d
🎨 update documentation for animation artifacts to remove outdated fil…
lsschmid b47c27b
🐛 fix insertion logic in HybridNeutralAtomMapper to correctly advance…
lsschmid 5b588c1
🐛 add check for empty synthesis steps in evaluateSynthesisSteps to pr…
lsschmid 4c16c42
🐛 fix loop index in NeutralAtomArchitecture to start from 1 for corre…
lsschmid 5048d2c
🔥 removed problematic test.
lsschmid 04471d8
✅ extend minimal arch to two qubits to run laodArchitecures.
lsschmid 0fc8b32
🚨Fixed Clang warnings.
lsschmid 4e857e0
🐛 update test description for NeutralAtomMapperExceptions to clarify …
lsschmid 000916f
🎨 removed default constructor of NeutralAtomScheduler to avoid pointe…
lsschmid 00c6871
📝 updated documentation of schedule.
lsschmid 0bb3055
🐛 refactor gate time and fidelity handling to ensure explicit fallbac…
lsschmid 1cbd157
🎨 refactor parameter normalization to use fmod for improved accuracy …
lsschmid c567437
📝 update animation file documentation
lsschmid ef841d9
🎨 optimize loop bounds for bridge gate computation to prevent out-of-…
lsschmid c5e0d5f
🎨 add comment on default value in architecture.
lsschmid 4d5026b
🐛 add runtime checks for qubit mapping to ensure valid hardware qubit…
lsschmid 6c142a8
✅ update synthesis evaluation to include mapping verification and enh…
lsschmid 1835d77
🎨 add comments to clarify indices for ancillary registers in HybridNe…
lsschmid 57af6f9
🐛 refactor AodMove operation to improve type safety and reduce redund…
lsschmid 23e927a
🎨 mark placeInitAtoms method as const
lsschmid b8b5d70
🐍 updated docstring in python.
lsschmid 4faca35
🐛 Fixed wrong cast in swapDistance computation.
lsschmid 2d50696
🎨 avoid unused returned variable
lsschmid e823a8e
🐛 add assertion to validate number of qubits against available positions
lsschmid 334897b
🎨 used correct type synonym.
lsschmid 0064fb5
🐛 add Aod Information to python bindings.
lsschmid 3b83627
🐛 clean animation output.
lsschmid 75d11f1
✏️ fixed typo in test name
lsschmid c39397e
🎨 added info on lifetime in docstring
lsschmid 5d2edf0
🎨 comment on visualization output
lsschmid 8a62fea
🔥removed unused python binding.
lsschmid 135043b
🎨 add trailing period in python docstings.
lsschmid bff341d
🎨 update bridge length comment.
lsschmid 9dbf60d
🎨 update SchedulerResults Docstring.
lsschmid 04ab1f0
🎨 avoid unnecessary copy
lsschmid 8e7d531
✅ add checks for nAodActivate and nAodMove in test_scheduler
lsschmid 052478d
🎨 avoid uint and use HwQubit
lsschmid 9acddec
🎨 use temporary files for tests.
lsschmid b437b35
🎨 add check to avoid division by 0.
lsschmid 139c9b4
🎨 add check to avoid out of range.
lsschmid 6629074
🎨 add check to assure that aod variables have same size.
lsschmid 028d3b5
🎨 reworked AdjMatrix creation.
lsschmid 60e84c7
🎨 Changed uint32 to HwQubit
lsschmid 9d99116
🎨 update doc string (again) for Scheduler.
lsschmid 2134f9a
🚨 removed unused import for linter.
lsschmid 214889b
🎨Fix nodes sort comparator parameter types in graphMatching
lsschmid c46a38d
🎨added another Check for nAodLevels.
lsschmid 615dc1c
🎨change Qubit to HwQubit.
lsschmid 282b113
🎨fixed counter type.
lsschmid c9bd381
🎨fixed counter type.
lsschmid 90e72da
🎨fixed types in Mapping.
lsschmid 2ebc59a
Merge branch 'main' into na-hybrid-merge-main
lsschmid bb2f5da
🎨fixed types in Mapping again.
lsschmid a8259c2
🎨 changed MapperParams to avoid the use of Pointers.
lsschmid 99c19f1
🎨 changed unsigned substraction comparison.
lsschmid 6bc26b1
🎨 updated bindings docstring.
lsschmid 0866b6c
🎨 return circuit by const ref.
lsschmid 5e11c1a
🎨 use copy for complete remap
lsschmid d4597ba
Merge branch 'main' into na-hybrid-merge-main
lsschmid af3047c
🎨 add missing check.
lsschmid 6e2383e
🎨 remove throw from doc string.
lsschmid 80b42f5
🐛 fixed wrong call to compute Euclidean Distance.
lsschmid f27a120
🎨 improved impossible SWAP handling.
lsschmid 4c9c296
🔥removed unused RoutingType.
lsschmid 93fb7fd
🐛added flying ancillas to copyStateFrom
lsschmid 8fc3b6f
🐛 fixed wrong update of blocked qubits.
lsschmid 49c9e34
🐛 fixed wrong update of qubit usage.
lsschmid e15c387
🐛 extend coordUsages to FlyingAncillas.
lsschmid 6858379
🐛 extend coordUsages to FlyingAncillas clang fix
lsschmid 968bbf2
🎨 set default dynamic mapping weight to 1
lsschmid d0f38d6
🐛 fix problem that barrier is considered multi-qubit gate.
lsschmid 684f67c
🐛 fix removal of operation from front layer for Bridge, PassBy, FA.
lsschmid 3005b0a
🐛 fix bug where no bridge is found if no SWAP was found.
lsschmid 644f52b
🐛 fix bug routing does no end if last gate was a bridge gate.
lsschmid 923811a
🐛 improved bridge cost function.
lsschmid f668d08
🎨 changed ifndef to pragma once.
lsschmid ec7ecc8
🎨 add assert if MoveGroup has neither normal nor FA move.
lsschmid e3fb023
🎨 add < operator for AtomMove
lsschmid 9b42d14
🐍 make python bindings more consistent.
lsschmid 74758c0
🔥 removed unnecessary comment.
lsschmid 1514df4
🔥 removed another unnecessary comment.
lsschmid 23b25e8
🎨 changed std::cout to spdlog
lsschmid 699cdbb
🎨 removed this->
lsschmid 588fcf2
🐛 fix insertion logic for targetQubits in MoveToAodConverter
lsschmid dc87bfc
Merge branch 'main' into na-hybrid-merge-main
lsschmid 9fa38b7
✨ Update synthesis_mapper methods to include QASM suffix for clarity
lsschmid 735ee77
📝 updated CHANGELOG.md
lsschmid 08254f4
📝 updated UPGRADING.md
lsschmid d602473
🚨removed unused header
lsschmid a636bdf
🎨changed qasm suffix also for synthesized circuit.
lsschmid 6ad9d17
📝 updated to use new qasm suffix.
lsschmid ffa0787
🔥 removed default constructor for AodMove.
lsschmid c6404da
📝 added missing punctuation in docs.
lsschmid 64daf5a
🚨 added error handling for file opening in HybridNeutralAtomMapper
lsschmid a921751
📝 fixed typo in UPGRADING.md for clarity
lsschmid ecf97d2
Merge branch 'main' into na-hybrid-merge-main
lsschmid 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ mapping | |
| synthesis | ||
| na_state_prep | ||
| na_zoned_compiler | ||
| na_hybrid | ||
| references | ||
| CHANGELOG | ||
| UPGRADING | ||
|
|
||
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,287 @@ | ||
| --- | ||
| file_format: mystnb | ||
| kernelspec: | ||
| name: python3 | ||
| number_source_lines: true | ||
| --- | ||
|
|
||
| ```{code-cell} ipython3 | ||
| :tags: [remove-cell] | ||
| %config InlineBackend.figure_formats = ['svg'] | ||
| ``` | ||
|
|
||
| <style>.widget-subarea{display:none;} /*hide widgets as they do not work with sphinx*/</style> | ||
|
|
||
| # Hybrid Neutral Atom Routing and Mapping | ||
|
|
||
| Neutral-atom (NA) processors combine long-range, native multi-qubit interactions with high-fidelity atom transport. | ||
| HyRoNA, the hybrid mapper in MQT QMAP, exploits both capabilities: it adaptively mixes gate-based routing (SWAP/BRIDGE) | ||
| with atom transport to minimize latency and error. It pairs interaction-aware initial placement with fast, | ||
| capability-specific cost models and an ASAP scheduler that respects hardware constraints, and it emits hardware-native | ||
| programs plus optional animation files for visualization. | ||
|
|
||
| Below, we show how to use the Hybrid NA Mapper from Python on a small GHZ example and how to tune a few key parameters. | ||
|
|
||
| ## Example: GHZ state on a hybrid NA architecture | ||
|
|
||
| In this example, we prepare an 8-qubit GHZ state (similar to the [zoned compiler](na_zoned_compiler.md)) and map it to a hybrid NA architecture. | ||
|
|
||
| ```{code-cell} ipython3 | ||
|
|
||
| from qiskit import QuantumCircuit | ||
| # Build a compact GHZ(8) circuit (tree-like to keep depth small) | ||
|
|
||
| qc = QuantumCircuit(8) | ||
| qc.h(0) | ||
| qc.cx(0, 4) | ||
| qc.cx(0, 2) | ||
| qc.cx(4, 6) | ||
| qc.cx(0, 1) | ||
| qc.cx(2, 3) | ||
| qc.cx(4, 5) | ||
| qc.cx(6, 7) | ||
|
|
||
| qc.draw(output="mpl") | ||
|
|
||
| ``` | ||
|
|
||
| ### Load a hybrid NA architecture | ||
|
|
||
| The hybrid mapper expects an architecture specification in JSON. | ||
| This repository ships several ready-to-use examples. | ||
|
|
||
| ```{code-cell} ipython3 | ||
|
|
||
| from pathlib import Path | ||
| import tempfile | ||
| import os | ||
| from mqt.qmap.hybrid_mapper import NeutralAtomHybridArchitecture | ||
|
|
||
| # Create a minimal architecture from an in-code JSON string and instantiate | ||
| # the NeutralAtomHybridArchitecture using a temporary file. The mapper's | ||
| # constructor expects a filename, so we write the JSON to a temp file first. | ||
| arch_json = '''{ | ||
| "name": "example arch", | ||
| "properties": { | ||
| "nRows": 5, | ||
| "nColumns": 5, | ||
| "nAods": 1, | ||
| "nAodCoordinates": 1, | ||
| "interQubitDistance": 10, | ||
| "minimalAodDistance": 0.1, | ||
| "interactionRadius": 1, | ||
| "blockingFactor": 1 | ||
| }, | ||
| "parameters": { | ||
| "nQubits": 10, | ||
| "gateTimes": { | ||
| "none": 0.5 | ||
| }, | ||
| "gateAverageFidelities": { | ||
| "none": 0.999 | ||
| }, | ||
| "decoherenceTimes": { | ||
| "t1": 100000000, | ||
| "t2": 1500000 | ||
| }, | ||
| "shuttlingTimes": { | ||
| "move": 0.55, | ||
| "aod_move": 0.55, | ||
| "aod_activate": 20, | ||
| "aod_deactivate": 20 | ||
| }, | ||
| "shuttlingAverageFidelities": { | ||
| "move": 1, | ||
| "aod_move": 1, | ||
| "aod_activate": 1, | ||
| "aod_deactivate": 1 | ||
| } | ||
| } | ||
| }''' | ||
|
|
||
| with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".json") as _tmp: | ||
| _tmp.write(arch_json) | ||
| tmp_name = _tmp.name | ||
|
|
||
| arch = NeutralAtomHybridArchitecture(tmp_name) | ||
| # Clean up the temporary file | ||
| os.unlink(tmp_name) | ||
|
|
||
| print(f"Loaded architecture: {arch.name} with {arch.num_qubits} qubits.") | ||
|
|
||
| ``` | ||
|
|
||
| ### Map with HyRoNA | ||
|
|
||
| Mapping translates the algorithm to hardware-native operations using a combination of routing with SWAP/BRIDGE gates and | ||
| atom moves. What combination is used depends on the architecture capabilities and the mapper parameters. | ||
| Here, we show two examples: first, we only use gate-based routing, then we let the mapper decide freely. | ||
|
|
||
| ```{code-cell} ipython3 | ||
| from mqt.core import load | ||
| from mqt.qmap.hybrid_mapper import HybridNAMapper, MapperParameters | ||
|
|
||
| # Optional: tweak parameters (defaults are sensible for most cases) | ||
| params_shuttling = MapperParameters() | ||
| params_shuttling.gate_weight = 1.0 | ||
| params_shuttling.shuttling_weight = 0.0 # disables atom moves | ||
|
|
||
|
|
||
| mapper = HybridNAMapper(arch, params=params_shuttling) | ||
|
|
||
| # Convert the Qiskit circuit to an MQT QuantumComputation and map it | ||
| circ = load(qc) | ||
| mapper.map(circ) # optionally: mapper.map(circ, initial_mapping=InitialCircuitMapping.identity) | ||
|
|
||
| # Retrieve mapping statistics | ||
| mapper.get_stats() | ||
| ``` | ||
|
|
||
| Note, how we set `shuttling_weight` zero to disallow atom moves and only use SWAP gates for routing. | ||
|
|
||
| The idea of the hybrid mapper is to mix both capabilities or to automatically select the best one. | ||
| We now re-run the mapping with default parameters that allow both SWAPs and atom moves. | ||
|
|
||
| ```{code-cell} ipython3 | ||
| params_default = MapperParameters() | ||
|
|
||
| mapper.set_parameters(params_default) | ||
|
|
||
| mapper.map(circ) | ||
| mapper.get_stats() | ||
| ``` | ||
|
|
||
| Now the mapper uses atom moves only as they are the better option on this architecture where moves are unit fidelity and | ||
| gates are noisy. | ||
|
|
||
| ### Schedule the mapped circuit | ||
|
|
||
| Scheduling orders the mapped operations as-soon-as-possible while respecting hardware constraints. | ||
|
|
||
| ```{code-cell} ipython3 | ||
| # Schedule; set create_animation_csv=True to generate visualization data | ||
| results = mapper.schedule(verbose=False, create_animation_csv=False) | ||
|
|
||
| results | ||
| ``` | ||
|
|
||
| You can retrieve the mapped scheduled circuit (extended QASM2) and, if desired, the variant with explicit AOD movements equivalent to the operations done on the hardware. | ||
|
|
||
| ```{code-cell} ipython3 | ||
|
|
||
| mapped_qasm = mapper.get_mapped_qc_qasm() | ||
| # Print a snippet of the mapped QASM | ||
| print("\n... Mapped QASM snippet ...\n" + | ||
| "\n".join(mapped_qasm.splitlines()[:30])) | ||
|
|
||
| # AOD-annotated variant (hardware-native moves) | ||
| mapped_aod_qasm = mapper.get_mapped_qc_aod_qasm() | ||
| print("\n... AOD (converted) snippet ...\n" + "\n".join(mapped_aod_qasm.splitlines()[:30]) + "\n...") | ||
| ``` | ||
|
|
||
| Here, the `q` register corresponds to the 5x5=25 coordinates of the architecture and no longer to the circuit qubits. | ||
| The other registers are used for temporary storage and AOD control. | ||
|
|
||
| The second variant shows explicit AOD movements that correspond to the atom moves done on hardware. | ||
| Here, the AODs can be activated, moved, and deactivated to shuttle atoms around. | ||
| The first entry corresponds to the x-direction and the second to the y-direction; in each pair, the two numbers denote start and end coordinates. | ||
|
|
||
| ### Export animation files (optional) | ||
|
|
||
| HyRoNA can write animation output files that can be visualized with [MQT NAViz](https://github.com/munich-quantum-toolkit/naviz). | ||
| Typically one has to accelerate the shuttling speed for better visualization by setting `shuttling_speed_factor`. | ||
|
|
||
| ```{code-cell} ipython3 | ||
| # Re-run scheduling with animation output enabled | ||
| _ = mapper.schedule(verbose=False, create_animation_csv=True, shuttling_speed_factor=100) | ||
|
|
||
| # Save the files; the method writes `.naviz` and `.namachine` files | ||
| # next to the given base name | ||
| mapper.save_animation_files("ghz8_hyrona_animation") | ||
| ``` | ||
|
|
||
| This creates `.namachine` and `.naviz` files which can then be imported into | ||
| MQT NAViz for visualization. | ||
|
|
||
|  | ||
|
|
||
| ## Tuning the mapper | ||
|
|
||
| HyRoNA exposes a concise set of parameters via `MapperParameters`: | ||
|
|
||
| - lookahead_depth: limited lookahead to peek at near-future layers | ||
| - lookahead_weight_swaps / lookahead_weight_moves: balance gate-routing vs. atom motion during lookahead | ||
| - decay: decreases the incentive for repeatedly blocking the same qubits | ||
| - gate_weight / shuttling_weight / shuttling_time_weight: cost-model weights for gates vs. transport | ||
| - dynamic_mapping_weight: bias for enabling dynamic re-mapping (SWAP/MOVE) when beneficial | ||
| - max_bridge_distance: limit for BRIDGE operations; use to avoid long-range chains | ||
| - initial_coord_mapping: strategy for hardware coordinate initialization | ||
|
|
||
| For more details, please check the source code documentation of `MapperParameters`. | ||
|
|
||
| ## Tips | ||
|
|
||
| - Initial mapping: you can explicitly select the initial circuit-to-hardware mapping for `map` or `map_qasm_file` using | ||
| `initial_mapping=InitialCircuitMapping.identity` or `InitialCircuitMapping.graph`. | ||
|
|
||
| - QASM input: instead of building a circuit in Qiskit, you can call `mapper.map_qasm_file("path/to/circuit.qasm")` and | ||
| then `mapper.schedule(...)` as shown above. | ||
|
|
||
| - Architectures: the examples `rubidium_hybrid.json`, `rubidium_gate.json`, and `rubidium_shuttling.json` in | ||
| `architectures/` cover different capability profiles and are a good starting point | ||
|
|
||
| ## Hybrid Synthesis Mapper | ||
|
|
||
| The Hybrid Synthesis Mapper helps you compare and stitch together alternative circuit fragments while keeping track of the current mapping on the NA device. | ||
| Below is a compact example that mirrors the unit test flow and shows how to: | ||
|
|
||
| - evaluate multiple candidate fragments and pick the best, | ||
| - append fragments, | ||
| - and retrieve mapped QASM as well as the AOD-annotated variant. | ||
|
|
||
| First, we create the `HybridSynthesisMapper` and evaluate two candidate fragments (here, both are the same GHZ circuit as above for simplicity). | ||
|
|
||
| ```{code-cell} ipython3 | ||
| from mqt.qmap.hybrid_mapper import HybridSynthesisMapper | ||
|
|
||
| # Reuse the architecture `arch` and GHZ circuit `qc` defined above. | ||
| synth = HybridSynthesisMapper(arch) | ||
| synth.init_mapping(qc.num_qubits) | ||
|
|
||
| fidelities = synth.evaluate_synthesis_steps([circ, circ], also_map = False) | ||
| print("Fidelities of subcircuits:", fidelities ) | ||
| ``` | ||
|
|
||
| The fidelity return indicates how well the subcircuit can be appended to the circuit mapped to the hardware. | ||
|
|
||
| You can then build up a larger program by appending fragments. | ||
|
|
||
| ```{code-cell} ipython3 | ||
| synth.append_with_mapping(circ) | ||
| ``` | ||
|
|
||
| This appends the circuit and maps it directly. This can be repeated for multiple fragments to always choose the best one. | ||
|
|
||
| Similar to the normal Hybrid Mapper, you can retrieve the mapped circuit and the AOD-annotated variant: | ||
|
|
||
| ```{code-cell} ipython3 | ||
|
|
||
| # Retrieve mapped circuit (extended QASM2) | ||
| qasm_mapped = synth.get_mapped_qc_qasm() | ||
| print("\n... Mapped QASM snippet ...\n" + | ||
| "\n".join(qasm_mapped.splitlines()[:30]) + | ||
| "\n...") | ||
| ``` | ||
|
|
||
| One can also access the circuits which is constructed step-by-step in a unmapped state (e.g. to use a different mapper). | ||
|
|
||
| ```{code-cell} ipython3 | ||
| qasm_synth = synth.get_synthesized_qc_qasm() | ||
| print("\n... Synthesized QASM snippet ...\n" + | ||
| "\n".join(qasm_synth.splitlines()[:30]) + | ||
| "\n...") | ||
| ``` | ||
|
|
||
| Here this corresponds simply to the input GHZ circuit. | ||
|
|
||
| This workflow lets you mix candidate-generation (synthesis) with hardware-aware mapping and scheduling, while keeping a single source of truth for mapping state across fragments. |
Oops, something went wrong.
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.