quantcore-circuits 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantcore_circuits/__init__.py +57 -0
- quantcore_circuits/analysis/__init__.py +12 -0
- quantcore_circuits/analysis/_metal.py +70 -0
- quantcore_circuits/analysis/amplifiers.py +263 -0
- quantcore_circuits/analysis/circuits.py +117 -0
- quantcore_circuits/analysis/epr.py +231 -0
- quantcore_circuits/analysis/epr_lumped.py +372 -0
- quantcore_circuits/analysis/extract.py +119 -0
- quantcore_circuits/analysis/lom.py +80 -0
- quantcore_circuits/analysis/results.py +549 -0
- quantcore_circuits/analysis/store.py +81 -0
- quantcore_circuits/analysis/synthesis.py +118 -0
- quantcore_circuits/analysis/transmon.py +126 -0
- quantcore_circuits/assembly/__init__.py +17 -0
- quantcore_circuits/assembly/builder.py +127 -0
- quantcore_circuits/assembly/drc.py +683 -0
- quantcore_circuits/assembly/last_good.py +137 -0
- quantcore_circuits/assembly/netlist.py +174 -0
- quantcore_circuits/assembly/plan.py +605 -0
- quantcore_circuits/assembly/sidecar.py +270 -0
- quantcore_circuits/autotrack.py +605 -0
- quantcore_circuits/cards.py +878 -0
- quantcore_circuits/circuit/__init__.py +14 -0
- quantcore_circuits/circuit/adapters.py +305 -0
- quantcore_circuits/circuit/bridges.py +353 -0
- quantcore_circuits/circuit/consensus.py +158 -0
- quantcore_circuits/circuit/derive.py +28 -0
- quantcore_circuits/circuit/draw.py +198 -0
- quantcore_circuits/circuit/fill.py +828 -0
- quantcore_circuits/circuit/hamiltonian.py +193 -0
- quantcore_circuits/circuit/kinetic.py +102 -0
- quantcore_circuits/circuit/schema.py +139 -0
- quantcore_circuits/cli.py +1085 -0
- quantcore_circuits/codesign.py +1038 -0
- quantcore_circuits/data/selftest_q1_r1.json +44 -0
- quantcore_circuits/design/__init__.py +44 -0
- quantcore_circuits/design/io.py +98 -0
- quantcore_circuits/design/pyscript.py +395 -0
- quantcore_circuits/design/schema.py +398 -0
- quantcore_circuits/designer.py +625 -0
- quantcore_circuits/guiflow.py +991 -0
- quantcore_circuits/kqc_files.py +208 -0
- quantcore_circuits/layouts/__init__.py +118 -0
- quantcore_circuits/layouts/catalog.py +520 -0
- quantcore_circuits/layouts/chips/__init__.py +0 -0
- quantcore_circuits/layouts/chips/design_chip.py +325 -0
- quantcore_circuits/layouts/chips/frame.py +235 -0
- quantcore_circuits/layouts/junctions/__init__.py +0 -0
- quantcore_circuits/layouts/junctions/jj_fingers.py +99 -0
- quantcore_circuits/layouts/junctions/legacy_junctions.py +237 -0
- quantcore_circuits/layouts/junctions/sim_gap.py +48 -0
- quantcore_circuits/layouts/junctions/trilayer.py +541 -0
- quantcore_circuits/layouts/metal/__init__.py +105 -0
- quantcore_circuits/layouts/metal/component.py +332 -0
- quantcore_circuits/layouts/metal/geometry.py +462 -0
- quantcore_circuits/layouts/others/__init__.py +0 -0
- quantcore_circuits/layouts/others/amplifiers.py +1139 -0
- quantcore_circuits/layouts/others/bond_pad.py +119 -0
- quantcore_circuits/layouts/others/connector_pads.py +190 -0
- quantcore_circuits/layouts/others/couplers.py +21 -0
- quantcore_circuits/layouts/others/cpw_segment.py +131 -0
- quantcore_circuits/layouts/others/cpwe.py +661 -0
- quantcore_circuits/layouts/others/keepout.py +66 -0
- quantcore_circuits/layouts/others/legacy_resonators.py +645 -0
- quantcore_circuits/layouts/others/markers.py +201 -0
- quantcore_circuits/layouts/others/qpdk_cells.py +263 -0
- quantcore_circuits/layouts/others/shapes.py +114 -0
- quantcore_circuits/layouts/others/spirals.py +140 -0
- quantcore_circuits/layouts/others/sqdmetal_cells.py +90 -0
- quantcore_circuits/layouts/others/test_pads.py +461 -0
- quantcore_circuits/layouts/ports.py +119 -0
- quantcore_circuits/layouts/qubits/__init__.py +0 -0
- quantcore_circuits/layouts/qubits/legacy_transmon.py +124 -0
- quantcore_circuits/layouts/qubits/qpdk_cells.py +374 -0
- quantcore_circuits/layouts/qubits/sqdmetal_cells.py +376 -0
- quantcore_circuits/layouts/qubits/trilayer_concentric.py +65 -0
- quantcore_circuits/layouts/qubits/xmon.py +375 -0
- quantcore_circuits/layouts/registry.py +418 -0
- quantcore_circuits/layouts/wafers/__init__.py +0 -0
- quantcore_circuits/layouts/wafers/fab_export.py +454 -0
- quantcore_circuits/layouts/wafers/legacy_wafer.py +111 -0
- quantcore_circuits/layouts/wafers/wafer.py +469 -0
- quantcore_circuits/live/__init__.py +6 -0
- quantcore_circuits/live/klayout.py +225 -0
- quantcore_circuits/live/klive.py +61 -0
- quantcore_circuits/live/snapshot.py +185 -0
- quantcore_circuits/live/watch.py +93 -0
- quantcore_circuits/lom/__init__.py +15 -0
- quantcore_circuits/lom/builder.py +932 -0
- quantcore_circuits/lom/calibration.py +82 -0
- quantcore_circuits/lom/estimates.py +235 -0
- quantcore_circuits/lom/fragment.py +421 -0
- quantcore_circuits/lom/kqc_models.py +734 -0
- quantcore_circuits/lom/metal_models.py +917 -0
- quantcore_circuits/lom/quantcore_models.py +784 -0
- quantcore_circuits/lom/simulate.py +636 -0
- quantcore_circuits/lom/synthesize.py +189 -0
- quantcore_circuits/loop.py +610 -0
- quantcore_circuits/optimise.py +423 -0
- quantcore_circuits/pdk/__init__.py +451 -0
- quantcore_circuits/plots.py +876 -0
- quantcore_circuits/plugins.py +69 -0
- quantcore_circuits/review/__init__.py +57 -0
- quantcore_circuits/review/server.py +251 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- quantcore_circuits/review/static/assets/index-CDHdrFyA.css +1 -0
- quantcore_circuits/review/static/assets/index-CSx05Og4.js +409 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-HOLc17fK.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-obahsSVq.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-BasfLYem.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-CxZf_p3X.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-4D_pXhcN.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-CWCymEST.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-CjBOestx.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-DrXBdSj3.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-BQZuk6qB.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-DQukG94-.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-B0yAr1jD.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-BmqWE9Dz.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Bcila6Z-.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Dfes3d0z.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-BjwYoWNd.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-LO58E6JB.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-400-normal-B4URO6DV.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-400-normal-q2sYcFCs.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-500-normal-BIZE56-Y.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-500-normal-Xzm54t5V.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-600-normal-BZpKdvQh.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-600-normal-plRanbMR.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-700-normal-BUv2fZ6O.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-700-normal-C3JjAnD8.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-DGGRlc-M.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-KugGGMne.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-2j5mBUwD.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-C4iEst2y.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-B8X0CLgF.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-DRtmH8MT.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-BoQ6DsYi.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-qfdV9bQt.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-600-normal-CiBQ2DWP.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-600-normal-LgqL8muc.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-700-normal-BLAVimhd.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-700-normal-Yt3aPRUw.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-77YHD8bZ.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-C1nco2VV.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-BxGbmqWO.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-CV4jyFjo.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-CIVaiw4L.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-D2bJ5OIk.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-Ca8adRJv.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-TidjK2hL.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-Bbgyi5SW.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-DMkecbls.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-DOriooB6.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-mJboJaSs.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-BuLX-rYi.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-Cc8MFFhd.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-BZaoP0fm.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-DlLaEgI2.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
- quantcore_circuits/review/static/index.html +14 -0
- quantcore_circuits/review/static/logo-quantcore-black.png +0 -0
- quantcore_circuits/review/static/logo-quantcore-white.png +0 -0
- quantcore_circuits/review/static/sample/chip.png +0 -0
- quantcore_circuits/review/static/sample/chip_rev1.png +0 -0
- quantcore_circuits/review/static/sample/q1.png +0 -0
- quantcore_circuits/review/static/sample/q2.png +0 -0
- quantcore_circuits/review/static/sample-state.json +3747 -0
- quantcore_circuits/route/__init__.py +5 -0
- quantcore_circuits/route/router.py +694 -0
- quantcore_circuits/route/waveguide.py +187 -0
- quantcore_circuits/selftest.py +224 -0
- quantcore_circuits/sim_tools/__init__.py +6 -0
- quantcore_circuits/sim_tools/aedt_attach.py +66 -0
- quantcore_circuits/sim_tools/aedt_progress.py +224 -0
- quantcore_circuits/sim_tools/aedt_project.py +302 -0
- quantcore_circuits/sim_tools/aedt_scripts.py +397 -0
- quantcore_circuits/sim_tools/aedt_session.py +275 -0
- quantcore_circuits/sim_tools/ansys.py +90 -0
- quantcore_circuits/sim_tools/builder.py +1690 -0
- quantcore_circuits/sim_tools/export.py +470 -0
- quantcore_circuits/sim_tools/geometry_check.py +342 -0
- quantcore_circuits/sim_tools/hfss.py +583 -0
- quantcore_circuits/sim_tools/palace.py +197 -0
- quantcore_circuits/sim_tools/runner.py +179 -0
- quantcore_circuits/sim_tools/subset.py +364 -0
- quantcore_circuits/track.py +671 -0
- quantcore_circuits-0.0.1.dist-info/METADATA +204 -0
- quantcore_circuits-0.0.1.dist-info/RECORD +272 -0
- quantcore_circuits-0.0.1.dist-info/WHEEL +5 -0
- quantcore_circuits-0.0.1.dist-info/entry_points.txt +2 -0
- quantcore_circuits-0.0.1.dist-info/licenses/LICENSE +674 -0
- quantcore_circuits-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
"""Closed-loop design feedback: tune geometry knobs in ``design.json`` until extracted parameters hit targets.
|
|
2
|
+
|
|
3
|
+
Knobs are dotted paths into the design: ``"Q1.cross_length"`` (instance parameter), ``"R1.length"`` (route field),
|
|
4
|
+
``"R1.to.length"`` (nested route field, e.g. a hanger coupler length), ``"Q1.junction.Lj_nH"`` (an instance field).
|
|
5
|
+
Parameter paths may go deeper (:func:`get_knob`): ``"Q2.cpl_length.1"`` (an element of a list parameter),
|
|
6
|
+
``"Q2.arm_length.*"`` (every element of a list, scaled together; the knob value is their mean) and
|
|
7
|
+
``"Q11.connection_pads.readout.pad_width"`` (a nested option, e.g. a Metal connection pad; unset options take the
|
|
8
|
+
cell's default). Lengths with a unit (Metal ``"30um"``, ``"0.1mm"``) read as µm and are written back in their unit.
|
|
9
|
+
Targets are ``"<instance>.<quantity>"``, e.g. ``"Q1.f_q_GHz"``. The evaluator maps a design to extracted parameters
|
|
10
|
+
(``{"Q1": {"f_q_GHz": ...}}``); the default :func:`pipeline_evaluator` runs build → simulation job → solver → parse →
|
|
11
|
+
extract.
|
|
12
|
+
|
|
13
|
+
Few, expensive evaluations: 1 knob uses a bounded secant method, n knobs a finite-difference Gauss-Newton step.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import ast
|
|
19
|
+
import copy
|
|
20
|
+
import json
|
|
21
|
+
import re
|
|
22
|
+
from collections.abc import Callable
|
|
23
|
+
from dataclasses import dataclass, field
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
import numpy as np
|
|
27
|
+
|
|
28
|
+
from quantcore_circuits import track as _track
|
|
29
|
+
from quantcore_circuits.design import Design, design_hash, load_design
|
|
30
|
+
|
|
31
|
+
Evaluator = Callable[[Design], dict]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
INSTANCE_FIELDS = ("cell", "params", "place", "ports", "junction")
|
|
35
|
+
_UNIT_UM = {"um": 1.0, "µm": 1.0, "nm": 1e-3, "mm": 1e3}
|
|
36
|
+
_NUMBER = re.compile(r"^\s*([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?)\s*(um|µm|nm|mm)?\s*$")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def knob_number(value) -> float:
|
|
40
|
+
"""A knob value as a float: a number, a numeric string or a length with a unit (``"30um"``, ``"0.1mm"`` → µm);
|
|
41
|
+
a list: the mean of its elements (the value of a ``"<param>.*"`` knob)."""
|
|
42
|
+
if isinstance(value, bool):
|
|
43
|
+
raise ValueError(f"not a number: {value!r}")
|
|
44
|
+
if isinstance(value, (int, float)):
|
|
45
|
+
return float(value)
|
|
46
|
+
if isinstance(value, str):
|
|
47
|
+
m = _NUMBER.match(value)
|
|
48
|
+
if m:
|
|
49
|
+
return float(m.group(1)) * _UNIT_UM.get(m.group(2) or "um", 1.0)
|
|
50
|
+
if isinstance(value, (list, tuple)) and value:
|
|
51
|
+
return float(np.mean([knob_number(v) for v in value]))
|
|
52
|
+
raise ValueError(f"not a number: {value!r}")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def get_knob(design: Design, knob: str):
|
|
56
|
+
"""The value of ``knob`` (module docstring): the design's own value, else the cell default (Metal: the class's
|
|
57
|
+
default options, and for a nested option such as ``connection_pads.<pad>.<option>`` its ``_default_*`` template).
|
|
58
|
+
Numbers come back as they are stored; lengths with a unit and ``*`` (list) knobs as floats (µm)."""
|
|
59
|
+
data = design.to_json_dict()
|
|
60
|
+
head, *rest = knob.split(".")
|
|
61
|
+
if not rest:
|
|
62
|
+
raise KeyError(f"knob {knob!r}: no parameter after {head!r}")
|
|
63
|
+
if head in data["instances"]:
|
|
64
|
+
inst = data["instances"][head]
|
|
65
|
+
flux_or_asym = rest[0] == "junction" and rest[1:] in (["flux_phi0"], ["asym"])
|
|
66
|
+
if flux_or_asym and rest[1] not in (inst.get("junction") or {}):
|
|
67
|
+
value = 0.0 # unset flux / asymmetry: the default (a symmetric SQUID at its sweet spot)
|
|
68
|
+
elif len(rest) > 1 and rest[0] in INSTANCE_FIELDS: # an instance field, e.g. junction.Lj_nH
|
|
69
|
+
value = _walk(inst, rest, knob)
|
|
70
|
+
else:
|
|
71
|
+
value = _param_value(inst, rest, knob)
|
|
72
|
+
elif head in data["routes"]:
|
|
73
|
+
value = _walk(data["routes"][head], rest, knob)
|
|
74
|
+
else:
|
|
75
|
+
raise KeyError(f"knob {knob!r}: no instance or route {head!r}")
|
|
76
|
+
return knob_number(value) if rest[-1] == "*" else _leaf(value)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def set_knob(design: Design, knob: str, value) -> Design:
|
|
80
|
+
"""``design`` with ``knob`` set to ``value`` (a copy). A length stored with a unit keeps its unit; ``*`` scales
|
|
81
|
+
every element of the list so that their mean is ``value``; an unset parameter or option is created."""
|
|
82
|
+
data = copy.deepcopy(design.to_json_dict())
|
|
83
|
+
head, *rest = knob.split(".")
|
|
84
|
+
if not rest:
|
|
85
|
+
raise KeyError(f"knob {knob!r}: no parameter after {head!r}")
|
|
86
|
+
if head in data["instances"]:
|
|
87
|
+
inst = data["instances"][head]
|
|
88
|
+
if len(rest) > 1 and rest[0] in INSTANCE_FIELDS:
|
|
89
|
+
_put(inst, rest, value, knob)
|
|
90
|
+
else:
|
|
91
|
+
_param_put(inst, rest, value, knob)
|
|
92
|
+
elif head in data["routes"]:
|
|
93
|
+
_put(data["routes"][head], rest, value, knob)
|
|
94
|
+
else:
|
|
95
|
+
raise KeyError(f"knob {knob!r}: no instance or route {head!r}")
|
|
96
|
+
return Design.model_validate(data)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def knob_path(design: Design, knob: str) -> tuple:
|
|
100
|
+
"""Where ``knob`` lives in ``design.to_json_dict()`` (list indices as ints, without a trailing ``*``): the leaf
|
|
101
|
+
changes a proposal makes to the knob are under this path."""
|
|
102
|
+
data = design.to_json_dict()
|
|
103
|
+
head, *rest = knob.split(".")
|
|
104
|
+
parts = [int(p) if p.isdigit() else p for p in rest if p != "*"]
|
|
105
|
+
if head in data["instances"]:
|
|
106
|
+
if len(rest) > 1 and rest[0] in INSTANCE_FIELDS:
|
|
107
|
+
return ("instances", head, *parts)
|
|
108
|
+
inst = data["instances"][head]
|
|
109
|
+
flat = inst.get("params") or {}
|
|
110
|
+
if rest[0] not in flat and rest[0] in _options(flat):
|
|
111
|
+
return ("instances", head, "params", "options")
|
|
112
|
+
return ("instances", head, "params", *parts)
|
|
113
|
+
return ("routes", head, *parts)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _leaf(v):
|
|
117
|
+
"""A stored value as a knob value: numeric / unit strings as floats (µm), anything else as it is."""
|
|
118
|
+
if isinstance(v, str):
|
|
119
|
+
try:
|
|
120
|
+
return knob_number(v)
|
|
121
|
+
except ValueError:
|
|
122
|
+
return v
|
|
123
|
+
return v
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _as_dict(v):
|
|
127
|
+
"""A dict, or the JSON / Python-literal text of one (KLayout PCell forms store dict parameters as text); None for
|
|
128
|
+
anything else."""
|
|
129
|
+
if isinstance(v, dict):
|
|
130
|
+
return v
|
|
131
|
+
if isinstance(v, str) and v.strip().startswith("{"):
|
|
132
|
+
try:
|
|
133
|
+
out = json.loads(v)
|
|
134
|
+
except ValueError:
|
|
135
|
+
try:
|
|
136
|
+
out = ast.literal_eval(v.strip())
|
|
137
|
+
except (ValueError, SyntaxError):
|
|
138
|
+
return None
|
|
139
|
+
if isinstance(out, dict):
|
|
140
|
+
return out
|
|
141
|
+
return None
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _step(node, part: str, knob: str):
|
|
145
|
+
if isinstance(node, (list, tuple)):
|
|
146
|
+
return node[int(part)]
|
|
147
|
+
d = _as_dict(node)
|
|
148
|
+
if d is None or part not in d:
|
|
149
|
+
raise KeyError(f"knob {knob!r}: {part!r} is not set")
|
|
150
|
+
return d[part]
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _walk(node, parts, knob: str):
|
|
154
|
+
for i, part in enumerate(parts):
|
|
155
|
+
if part == "*":
|
|
156
|
+
if i != len(parts) - 1 or not isinstance(node, (list, tuple)):
|
|
157
|
+
raise KeyError(f"knob {knob!r}: '*' must be the last part, on a list")
|
|
158
|
+
return list(node)
|
|
159
|
+
node = _step(node, part, knob)
|
|
160
|
+
return node
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _options(flat: dict) -> dict:
|
|
164
|
+
"""A wrapper cell's ``options`` (dict or JSON text, e.g. what the plugin's parameter table writes)."""
|
|
165
|
+
return _as_dict(flat.get("options")) or {}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _cell_defaults(cell: str) -> dict:
|
|
169
|
+
"""Default parameters of a cell: Metal ``metal:<Class>`` its default options, else the PCell schema defaults."""
|
|
170
|
+
if cell.startswith("metal:"):
|
|
171
|
+
from quantcore_circuits.layouts.metal.geometry import template_options # pylint: disable=C0415
|
|
172
|
+
|
|
173
|
+
return template_options(cell.split(":", 1)[1])
|
|
174
|
+
from quantcore_circuits.layouts.registry import resolve_cell # pylint: disable=import-outside-toplevel
|
|
175
|
+
|
|
176
|
+
return {k: v.default for k, v in resolve_cell(cell).get_schema().items()}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _entry_defaults(cell: str, top: str) -> dict:
|
|
180
|
+
"""Defaults of one entry of a dict parameter (``connection_pads.<pad>``): Metal's ``_default_<top>`` template, or
|
|
181
|
+
the cell module's ``DEFAULT_CONNECTION_PAD`` (the SQDMetal re-implementations)."""
|
|
182
|
+
if cell.startswith("metal:"):
|
|
183
|
+
return dict(_cell_defaults(cell).get(f"_default_{top}") or {})
|
|
184
|
+
if top == "connection_pads":
|
|
185
|
+
import importlib # pylint: disable=import-outside-toplevel
|
|
186
|
+
|
|
187
|
+
from quantcore_circuits.layouts.registry import resolve_cell # pylint: disable=import-outside-toplevel
|
|
188
|
+
|
|
189
|
+
mod = importlib.import_module(resolve_cell(cell).__module__)
|
|
190
|
+
return dict(getattr(mod, "DEFAULT_CONNECTION_PAD", {}) or {})
|
|
191
|
+
return {}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def _param_value(inst: dict, rest, knob: str):
|
|
195
|
+
flat = dict(inst.get("params") or {})
|
|
196
|
+
opts = _options(flat)
|
|
197
|
+
top = rest[0]
|
|
198
|
+
if top in flat and top != "options":
|
|
199
|
+
node = flat[top]
|
|
200
|
+
elif top in opts:
|
|
201
|
+
node = opts[top]
|
|
202
|
+
else:
|
|
203
|
+
defaults = _cell_defaults(inst["cell"])
|
|
204
|
+
if top not in defaults:
|
|
205
|
+
raise KeyError(f"knob {knob!r}: {inst['cell']} has no parameter {top!r}")
|
|
206
|
+
node = defaults[top]
|
|
207
|
+
if len(rest) >= 3 and _as_dict(node) is not None: # <top>.<entry>.<option>: the option's default when unset
|
|
208
|
+
entry = _step(node, rest[1], knob)
|
|
209
|
+
d = {**_entry_defaults(inst["cell"], top), **(_as_dict(entry) or {})}
|
|
210
|
+
if rest[2] not in d:
|
|
211
|
+
raise KeyError(f"knob {knob!r}: {rest[2]!r} is not an option of {top}.{rest[1]}")
|
|
212
|
+
return _walk(d[rest[2]], rest[3:], knob)
|
|
213
|
+
return _walk(node, rest[1:], knob)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def _like(old, value):
|
|
217
|
+
"""``value`` in the form ``old`` was stored: a unit string keeps its unit, other numbers become floats;
|
|
218
|
+
non-numeric values are stored as they are."""
|
|
219
|
+
if isinstance(value, bool) or not isinstance(value, (int, float, np.floating, np.integer)):
|
|
220
|
+
return value
|
|
221
|
+
if isinstance(old, str):
|
|
222
|
+
m = _NUMBER.match(old)
|
|
223
|
+
if m and m.group(2):
|
|
224
|
+
return f"{float(value) / _UNIT_UM[m.group(2)]:.6g}{m.group(2)}"
|
|
225
|
+
return float(value) if isinstance(value, (np.floating, np.integer)) else value
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _put(node, parts, value, knob: str) -> None:
|
|
229
|
+
"""Set ``parts`` under ``node`` (dicts, lists, dict-valued JSON text), creating missing dict keys."""
|
|
230
|
+
*path, last = parts
|
|
231
|
+
if last == "*":
|
|
232
|
+
lst = _walk(node, path, knob) if path else node
|
|
233
|
+
if not isinstance(lst, list):
|
|
234
|
+
raise KeyError(f"knob {knob!r}: '*' needs a list")
|
|
235
|
+
mean = knob_number(lst)
|
|
236
|
+
for i, el in enumerate(lst):
|
|
237
|
+
lst[i] = _like(el, round(knob_number(el) * value / mean, 4) if mean else value)
|
|
238
|
+
return
|
|
239
|
+
for i, part in enumerate(path):
|
|
240
|
+
if isinstance(node, list):
|
|
241
|
+
node = node[int(part)]
|
|
242
|
+
continue
|
|
243
|
+
child = node.get(part)
|
|
244
|
+
if isinstance(child, str): # a dict kept as JSON text: change it there and write the text back
|
|
245
|
+
sub = _as_dict(child)
|
|
246
|
+
if sub is None:
|
|
247
|
+
raise KeyError(f"knob {knob!r}: {part!r} is {child!r}, not a dict")
|
|
248
|
+
_put(sub, [*path[i + 1 :], last], value, knob)
|
|
249
|
+
node[part] = json.dumps(sub)
|
|
250
|
+
return
|
|
251
|
+
if child is None: # e.g. a junction that is not set yet
|
|
252
|
+
child = node[part] = {}
|
|
253
|
+
node = child
|
|
254
|
+
if isinstance(node, list):
|
|
255
|
+
node[int(last)] = _like(node[int(last)], value)
|
|
256
|
+
else:
|
|
257
|
+
node[last] = _like(node.get(last), value)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _param_put(inst: dict, rest, value, knob: str) -> None:
|
|
261
|
+
flat = inst.setdefault("params", {})
|
|
262
|
+
top = rest[0]
|
|
263
|
+
if top not in flat and top in _options(flat): # stored in the wrapper's options: change it there
|
|
264
|
+
opts = _options(flat)
|
|
265
|
+
_put(opts, rest, value, knob)
|
|
266
|
+
flat["options"] = json.dumps(opts) if isinstance(flat.get("options"), str) else opts
|
|
267
|
+
return
|
|
268
|
+
if top not in flat and len(rest) > 1: # a list / dict parameter left at its default: start from the default
|
|
269
|
+
flat[top] = copy.deepcopy(_param_value(inst, [top], knob))
|
|
270
|
+
if len(rest) >= 3 and isinstance(flat.get(top), (dict, str)):
|
|
271
|
+
entry_parent = flat[top]
|
|
272
|
+
parsed = _as_dict(entry_parent)
|
|
273
|
+
if parsed is not None:
|
|
274
|
+
_put(parsed, rest[1:], value, knob)
|
|
275
|
+
flat[top] = json.dumps(parsed) if isinstance(entry_parent, str) else parsed
|
|
276
|
+
return
|
|
277
|
+
_put(flat, rest, value, knob)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def _resolve(data: dict, knob: str):
|
|
281
|
+
head, *rest = knob.split(".")
|
|
282
|
+
if head in data["instances"]:
|
|
283
|
+
node = data["instances"][head]
|
|
284
|
+
if len(rest) == 1:
|
|
285
|
+
return node["params"], rest[0]
|
|
286
|
+
base = node
|
|
287
|
+
elif head in data["routes"]:
|
|
288
|
+
base = data["routes"][head]
|
|
289
|
+
else:
|
|
290
|
+
raise KeyError(f"knob {knob!r}: no instance or route {head!r}")
|
|
291
|
+
for part in rest[:-1]:
|
|
292
|
+
base = base[part]
|
|
293
|
+
return base, rest[-1]
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
@dataclass
|
|
297
|
+
class Iteration:
|
|
298
|
+
knobs: dict
|
|
299
|
+
metrics: dict
|
|
300
|
+
error: dict
|
|
301
|
+
design_hash: str
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
@dataclass
|
|
305
|
+
class OptimiseResult:
|
|
306
|
+
design: Design
|
|
307
|
+
converged: bool
|
|
308
|
+
history: list[Iteration] = field(default_factory=list)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def _target_values(metrics: dict, targets: dict) -> np.ndarray:
|
|
312
|
+
out = []
|
|
313
|
+
for key in targets:
|
|
314
|
+
inst, qty = key.split(".", 1)
|
|
315
|
+
v = metrics.get(inst, {}).get(qty)
|
|
316
|
+
if v is None:
|
|
317
|
+
v = metrics.get(inst, {}).get(qty.replace("_GHz", "_eig_GHz"))
|
|
318
|
+
if v is None:
|
|
319
|
+
raise KeyError(f"evaluator did not return {key}")
|
|
320
|
+
out.append(float(v))
|
|
321
|
+
return np.asarray(out)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def optimise(
|
|
325
|
+
source,
|
|
326
|
+
knobs: dict[str, tuple[float, float]],
|
|
327
|
+
targets: dict[str, float],
|
|
328
|
+
evaluate: Evaluator,
|
|
329
|
+
tolerance: dict[str, float] | None = None,
|
|
330
|
+
max_iter: int = 6,
|
|
331
|
+
step: float = 0.02,
|
|
332
|
+
log=print,
|
|
333
|
+
) -> OptimiseResult:
|
|
334
|
+
"""Tune ``knobs`` (with bounds) so that ``targets`` are met within ``tolerance`` (absolute, per target)."""
|
|
335
|
+
design = load_design(source)
|
|
336
|
+
names = list(knobs)
|
|
337
|
+
lo = np.array([knobs[k][0] for k in names], dtype=float)
|
|
338
|
+
hi = np.array([knobs[k][1] for k in names], dtype=float)
|
|
339
|
+
want = np.array([targets[k] for k in targets], dtype=float)
|
|
340
|
+
tol = np.array([(tolerance or {}).get(k, 1e-3 * max(abs(targets[k]), 1)) for k in targets])
|
|
341
|
+
x = np.array([float(get_knob(design, k)) for k in names])
|
|
342
|
+
history: list[Iteration] = []
|
|
343
|
+
|
|
344
|
+
def run(xv) -> np.ndarray:
|
|
345
|
+
d = design
|
|
346
|
+
for k, v in zip(names, xv):
|
|
347
|
+
d = set_knob(d, k, float(v))
|
|
348
|
+
metrics = evaluate(d)
|
|
349
|
+
y = _target_values(metrics, targets)
|
|
350
|
+
err = dict(zip(targets, (y - want).tolist()))
|
|
351
|
+
history.append(Iteration(dict(zip(names, xv.tolist())), metrics, err, design_hash(d)))
|
|
352
|
+
log(f"[optimise] {dict(zip(names, np.round(xv, 4)))} -> {dict(zip(targets, np.round(y, 4)))}")
|
|
353
|
+
_track.emit(
|
|
354
|
+
"optimise",
|
|
355
|
+
index=len(history) - 1,
|
|
356
|
+
knobs=dict(zip(names, xv.tolist())),
|
|
357
|
+
metrics=metrics,
|
|
358
|
+
error=err,
|
|
359
|
+
tol=dict(zip(targets, tol.tolist())),
|
|
360
|
+
design=d,
|
|
361
|
+
)
|
|
362
|
+
return y
|
|
363
|
+
|
|
364
|
+
try:
|
|
365
|
+
y = run(x)
|
|
366
|
+
prev = None
|
|
367
|
+
for _ in range(max_iter - 1):
|
|
368
|
+
r = y - want
|
|
369
|
+
if np.all(np.abs(r) <= tol):
|
|
370
|
+
break
|
|
371
|
+
if len(names) == 1 and len(want) == 1:
|
|
372
|
+
if prev is None: # first step: finite-difference slope
|
|
373
|
+
dx = step * max(abs(x[0]), 1.0)
|
|
374
|
+
x1 = np.clip(x + dx, lo, hi)
|
|
375
|
+
y1 = run(x1)
|
|
376
|
+
slope = (y1[0] - y[0]) / (x1[0] - x[0])
|
|
377
|
+
prev, x, y = (x1, y1), x1, y1
|
|
378
|
+
else:
|
|
379
|
+
(xp, yp) = prev
|
|
380
|
+
slope = (y[0] - yp[0]) / (x[0] - xp[0]) if x[0] != xp[0] else 0.0
|
|
381
|
+
if slope == 0:
|
|
382
|
+
break
|
|
383
|
+
x_new = np.clip(x - (y - want) / slope, lo, hi)
|
|
384
|
+
prev = (x, y)
|
|
385
|
+
x, y = x_new, run(x_new)
|
|
386
|
+
else:
|
|
387
|
+
jac = np.zeros((len(want), len(names)))
|
|
388
|
+
for i in range(len(names)):
|
|
389
|
+
dx = np.zeros_like(x)
|
|
390
|
+
dx[i] = step * max(abs(x[i]), 1.0)
|
|
391
|
+
jac[:, i] = (run(np.clip(x + dx, lo, hi)) - y) / dx[i]
|
|
392
|
+
delta = np.linalg.lstsq(jac, -(y - want), rcond=None)[0]
|
|
393
|
+
x = np.clip(x + delta, lo, hi)
|
|
394
|
+
y = run(x)
|
|
395
|
+
except BaseException as e:
|
|
396
|
+
_track.emit("optimise_end", converged=False, error=f"{type(e).__name__}: {e}", evaluations=len(history),
|
|
397
|
+
design=design)
|
|
398
|
+
raise
|
|
399
|
+
best = min(history, key=lambda it: float(np.sum((np.array(list(it.error.values())) / tol) ** 2)))
|
|
400
|
+
final = design
|
|
401
|
+
for k, v in best.knobs.items():
|
|
402
|
+
final = set_knob(final, k, v)
|
|
403
|
+
converged = all(abs(best.error[k]) <= t for k, t in zip(targets, tol))
|
|
404
|
+
_track.emit("optimise_end", converged=converged, evaluations=len(history), design=final)
|
|
405
|
+
return OptimiseResult(final, converged, history)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def pipeline_evaluator(group: str, analysis: str, job_root: str | Path = "build/jobs", **settings) -> Evaluator:
|
|
409
|
+
"""build → sim job → run (local solver) → parse → extract, for use with :func:`optimise`."""
|
|
410
|
+
from quantcore_circuits.analysis.extract import extract # pylint: disable=import-outside-toplevel
|
|
411
|
+
from quantcore_circuits.analysis.results import collect_results # pylint: disable=import-outside-toplevel
|
|
412
|
+
from quantcore_circuits.sim_tools import build_simulation, export_job # pylint: disable=import-outside-toplevel
|
|
413
|
+
from quantcore_circuits.sim_tools.runner import run_job # pylint: disable=import-outside-toplevel
|
|
414
|
+
|
|
415
|
+
def evaluate(design: Design) -> dict:
|
|
416
|
+
job_dir = Path(job_root) / f"{design.name}_{group}_{analysis}_{design_hash(design)}"
|
|
417
|
+
if not (job_dir / "results" / "results.json").exists():
|
|
418
|
+
setup = build_simulation(design, group, analysis)
|
|
419
|
+
export_job(setup, job_dir, overwrite=True, **settings)
|
|
420
|
+
run_job(job_dir)
|
|
421
|
+
return extract(design, collect_results(job_dir))
|
|
422
|
+
|
|
423
|
+
return evaluate
|