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,671 @@
|
|
|
1
|
+
"""Live run state for the dashboard (``reviewer/``, served by ``qcc review``): ``build/<design>/state.json``.
|
|
2
|
+
|
|
3
|
+
A :class:`Run` records the design loop as it happens — which step is running, targets vs current values, KLayout
|
|
4
|
+
screenshots, plots (as data, rendered by the dashboard and by :mod:`quantcore_circuits.plots`), the circuit, the
|
|
5
|
+
Hamiltonian, the estimator consensus, simulation jobs, optimiser history and a log. Every mutation rewrites
|
|
6
|
+
``state.json`` atomically (inside :meth:`Run.deferred`: step starts / ends and the end of the block only); the server
|
|
7
|
+
pushes a Server-Sent Event and the browser refetches. The JSON follows the contract in ``reviewer/contract/state.ts``.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import contextlib
|
|
13
|
+
import functools
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import shutil
|
|
17
|
+
import tempfile
|
|
18
|
+
import threading
|
|
19
|
+
import time
|
|
20
|
+
from datetime import UTC, datetime
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
STATE_SCHEMA = "qcc-state/0.1"
|
|
24
|
+
STEPS = [
|
|
25
|
+
("synthesis", "LOM synthesis"),
|
|
26
|
+
("layout", "Layout"),
|
|
27
|
+
("render", "HFSS render"),
|
|
28
|
+
("simulate", "Simulate"),
|
|
29
|
+
("extract", "Extract"),
|
|
30
|
+
("hamiltonian", "Hamiltonian"),
|
|
31
|
+
("compare", "Compare to targets"),
|
|
32
|
+
("feedback", "Feedback"),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _now() -> str:
|
|
37
|
+
return datetime.now(UTC).isoformat(timespec="seconds")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def run_dir_for(design_name: str, root: str | Path = "build") -> Path:
|
|
41
|
+
return Path(root) / design_name
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
_LOCK = threading.RLock() # the notebook thread and the tracking threads (snapshots, FEM watcher) share Run objects
|
|
45
|
+
_RUNS: dict[str, Run] = {} # one Run object per run directory in a process (two writers on a state.json clobber it)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _locked(fn):
|
|
49
|
+
@functools.wraps(fn)
|
|
50
|
+
def wrapper(*a, **k):
|
|
51
|
+
with _LOCK:
|
|
52
|
+
return fn(*a, **k)
|
|
53
|
+
|
|
54
|
+
return wrapper
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Run:
|
|
58
|
+
def __new__(
|
|
59
|
+
cls, design_source=None, run_dir: str | Path | None = None, reset: bool = False, name: str | None = None
|
|
60
|
+
):
|
|
61
|
+
key = None
|
|
62
|
+
if run_dir is not None or name is not None:
|
|
63
|
+
key = str(Path(run_dir if run_dir is not None else run_dir_for(name)).resolve())
|
|
64
|
+
elif design_source is not None:
|
|
65
|
+
from quantcore_circuits.design import load_design # pylint: disable=import-outside-toplevel
|
|
66
|
+
|
|
67
|
+
key = str(run_dir_for(load_design(design_source).name).resolve())
|
|
68
|
+
with _LOCK:
|
|
69
|
+
if key is not None and key in _RUNS:
|
|
70
|
+
return _RUNS[key]
|
|
71
|
+
self = super().__new__(cls)
|
|
72
|
+
if key is not None:
|
|
73
|
+
_RUNS[key] = self
|
|
74
|
+
return self
|
|
75
|
+
|
|
76
|
+
@_locked
|
|
77
|
+
def __init__(
|
|
78
|
+
self, design_source=None, run_dir: str | Path | None = None, reset: bool = False, name: str | None = None
|
|
79
|
+
):
|
|
80
|
+
"""``design_source`` None: a model-only run named ``name`` (a stand-alone ``circuit.json``, no layout)."""
|
|
81
|
+
from quantcore_circuits.design import load_design # pylint: disable=import-outside-toplevel
|
|
82
|
+
|
|
83
|
+
self.design_source = design_source
|
|
84
|
+
design = load_design(design_source) if design_source is not None else None
|
|
85
|
+
self.dir = Path(run_dir) if run_dir else run_dir_for(design.name if design else name)
|
|
86
|
+
self.dir.mkdir(parents=True, exist_ok=True)
|
|
87
|
+
self.path = self.dir / "state.json"
|
|
88
|
+
if not hasattr(self, "design_names"):
|
|
89
|
+
self.design_names: set[str] = set()
|
|
90
|
+
if self.path.exists() and not reset:
|
|
91
|
+
self.state = {**self._empty(), **json.loads(self.path.read_text(encoding="utf-8"))}
|
|
92
|
+
else:
|
|
93
|
+
self.state = self._empty()
|
|
94
|
+
self.follow(design, design_source, name, save=False)
|
|
95
|
+
self.save()
|
|
96
|
+
|
|
97
|
+
@_locked
|
|
98
|
+
def follow(self, design, design_source=None, name: str | None = None, save: bool = True) -> None:
|
|
99
|
+
"""Point the run's ``design`` block at ``design`` (a revision of the same run). ``None``: a model-only run."""
|
|
100
|
+
from quantcore_circuits.design import design_hash # pylint: disable=import-outside-toplevel
|
|
101
|
+
from quantcore_circuits.pdk import get_pdk # pylint: disable=import-outside-toplevel
|
|
102
|
+
|
|
103
|
+
if design is None:
|
|
104
|
+
stack = get_pdk().stack
|
|
105
|
+
info = {
|
|
106
|
+
"name": name or "model",
|
|
107
|
+
"path": "",
|
|
108
|
+
"hash": "",
|
|
109
|
+
"pdk": get_pdk().name,
|
|
110
|
+
"chipBox": [0, 0, 1000, 1000],
|
|
111
|
+
"instances": 0,
|
|
112
|
+
"routes": 0,
|
|
113
|
+
}
|
|
114
|
+
else:
|
|
115
|
+
stack = get_pdk(design.pdk).stack
|
|
116
|
+
info = {
|
|
117
|
+
"name": design.name,
|
|
118
|
+
"path": str(design_source) if isinstance(design_source, (str, Path)) else design.name,
|
|
119
|
+
"hash": design_hash(design),
|
|
120
|
+
"pdk": design.pdk,
|
|
121
|
+
"chipBox": list(design.chip.box),
|
|
122
|
+
"instances": len(design.instances),
|
|
123
|
+
"routes": len(design.routes),
|
|
124
|
+
}
|
|
125
|
+
self.design_names.add(design.name)
|
|
126
|
+
info["stack"] = {
|
|
127
|
+
"substrate": stack.substrate_material,
|
|
128
|
+
"epsR": stack.substrate_permittivity,
|
|
129
|
+
"thickness_um": stack.substrate_height,
|
|
130
|
+
}
|
|
131
|
+
self.state["design"] = info
|
|
132
|
+
if save:
|
|
133
|
+
self.save()
|
|
134
|
+
|
|
135
|
+
@staticmethod
|
|
136
|
+
def _empty() -> dict:
|
|
137
|
+
return {
|
|
138
|
+
"schema": STATE_SCHEMA,
|
|
139
|
+
"updated": _now(),
|
|
140
|
+
"design": {},
|
|
141
|
+
"currentStep": None,
|
|
142
|
+
"steps": [{"id": i, "index": k + 1, "title": t, "status": "pending"} for k, (i, t) in enumerate(STEPS)],
|
|
143
|
+
"goal": {"reached": False, "passed": 0, "total": 0, "summary": "no targets evaluated yet"},
|
|
144
|
+
"targets": [],
|
|
145
|
+
"screenshots": [],
|
|
146
|
+
"plots": [],
|
|
147
|
+
"circuit": None,
|
|
148
|
+
"hamiltonian": None,
|
|
149
|
+
"consensus": [],
|
|
150
|
+
"jobs": [],
|
|
151
|
+
"cmatrix": None,
|
|
152
|
+
"history": [],
|
|
153
|
+
"log": [],
|
|
154
|
+
"sections": [],
|
|
155
|
+
"cards": [],
|
|
156
|
+
"summary": [],
|
|
157
|
+
"elements": [],
|
|
158
|
+
"femCompare": [],
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
# ---- persistence ------------------------------------------------------------------------------------------
|
|
162
|
+
@contextlib.contextmanager
|
|
163
|
+
def deferred(self):
|
|
164
|
+
"""Within this block ``state.json`` is written when a step starts, ends or fails and once at the end, not on
|
|
165
|
+
every log line, plot or field (an analysis of many qubit pairs adds dozens of them; each write encodes the
|
|
166
|
+
whole state)."""
|
|
167
|
+
with _LOCK:
|
|
168
|
+
self._defer = getattr(self, "_defer", 0) + 1
|
|
169
|
+
try:
|
|
170
|
+
yield self
|
|
171
|
+
finally:
|
|
172
|
+
with _LOCK:
|
|
173
|
+
self._defer -= 1
|
|
174
|
+
if not self._defer:
|
|
175
|
+
self.save()
|
|
176
|
+
|
|
177
|
+
@_locked
|
|
178
|
+
def save(self, force: bool = False) -> Path:
|
|
179
|
+
if getattr(self, "_defer", 0) and not force:
|
|
180
|
+
return self.path
|
|
181
|
+
self.state["updated"] = _now()
|
|
182
|
+
data = json.dumps(self.state, indent=1, ensure_ascii=False, default=_json_default)
|
|
183
|
+
self.dir.mkdir(parents=True, exist_ok=True) # the run dir may have been removed mid-run
|
|
184
|
+
fd, tmp = tempfile.mkstemp(suffix=".json", dir=self.dir)
|
|
185
|
+
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
|
186
|
+
f.write(data)
|
|
187
|
+
# Windows refuses to replace a file another process has open (the dashboard server reading it): retry briefly
|
|
188
|
+
for attempt in range(40):
|
|
189
|
+
try:
|
|
190
|
+
os.replace(tmp, self.path)
|
|
191
|
+
break
|
|
192
|
+
except PermissionError:
|
|
193
|
+
if attempt == 39:
|
|
194
|
+
os.remove(tmp)
|
|
195
|
+
raise
|
|
196
|
+
time.sleep(0.025)
|
|
197
|
+
return self.path
|
|
198
|
+
|
|
199
|
+
# ---- steps ------------------------------------------------------------------------------------------------
|
|
200
|
+
def _step(self, step_id: str) -> dict:
|
|
201
|
+
for s in self.state["steps"]:
|
|
202
|
+
if s["id"] == step_id:
|
|
203
|
+
return s
|
|
204
|
+
raise KeyError(step_id)
|
|
205
|
+
|
|
206
|
+
@_locked
|
|
207
|
+
def start(self, step_id: str, summary: str | None = None) -> None:
|
|
208
|
+
s = self._step(step_id)
|
|
209
|
+
s.update(status="running", started=_now())
|
|
210
|
+
s.pop("finished", None)
|
|
211
|
+
if summary:
|
|
212
|
+
s["summary"] = summary
|
|
213
|
+
self.state["currentStep"] = step_id
|
|
214
|
+
self.log(f"{s['title']}: started")
|
|
215
|
+
if getattr(self, "_defer", 0):
|
|
216
|
+
self.save(force=True)
|
|
217
|
+
|
|
218
|
+
@_locked
|
|
219
|
+
def done(self, step_id: str, summary: str = "", **metrics) -> None:
|
|
220
|
+
s = self._step(step_id)
|
|
221
|
+
s.update(status="done", finished=_now(), summary=summary or s.get("summary", ""))
|
|
222
|
+
if metrics:
|
|
223
|
+
s["metrics"] = {k: _plain(v) for k, v in metrics.items()}
|
|
224
|
+
self.log(f"{s['title']}: {summary}" if summary else f"{s['title']}: done")
|
|
225
|
+
if getattr(self, "_defer", 0):
|
|
226
|
+
self.save(force=True)
|
|
227
|
+
|
|
228
|
+
@_locked
|
|
229
|
+
def fail(self, step_id: str, message: str) -> None:
|
|
230
|
+
s = self._step(step_id)
|
|
231
|
+
s.update(status="failed", finished=_now(), summary=message)
|
|
232
|
+
self.state["currentStep"] = step_id
|
|
233
|
+
self.log(f"{s['title']}: {message}", "error")
|
|
234
|
+
if getattr(self, "_defer", 0):
|
|
235
|
+
self.save(force=True)
|
|
236
|
+
|
|
237
|
+
@_locked
|
|
238
|
+
def skip(self, step_id: str, reason: str) -> None:
|
|
239
|
+
s = self._step(step_id)
|
|
240
|
+
s.update(status="skipped", summary=reason)
|
|
241
|
+
self.log(f"{s['title']}: skipped ({reason})", "warn")
|
|
242
|
+
|
|
243
|
+
@_locked
|
|
244
|
+
def reset_from(self, step_id: str) -> None:
|
|
245
|
+
"""Mark ``step_id`` and every later step pending again (a new loop iteration)."""
|
|
246
|
+
hit = False
|
|
247
|
+
for s in self.state["steps"]:
|
|
248
|
+
hit = hit or s["id"] == step_id
|
|
249
|
+
if hit:
|
|
250
|
+
s.update(status="pending")
|
|
251
|
+
for k in ("started", "finished"):
|
|
252
|
+
s.pop(k, None)
|
|
253
|
+
self.save()
|
|
254
|
+
|
|
255
|
+
# ---- content ----------------------------------------------------------------------------------------------
|
|
256
|
+
@_locked
|
|
257
|
+
def log(self, msg: str, level: str = "info") -> None:
|
|
258
|
+
self.state["log"].append({"t": _now(), "level": level, "msg": msg})
|
|
259
|
+
self.state["log"] = self.state["log"][-500:]
|
|
260
|
+
self.save()
|
|
261
|
+
|
|
262
|
+
@_locked
|
|
263
|
+
def screenshot(
|
|
264
|
+
self,
|
|
265
|
+
png: str | Path,
|
|
266
|
+
title: str,
|
|
267
|
+
step: str | None = None,
|
|
268
|
+
caption: str = "",
|
|
269
|
+
source: str = "headless",
|
|
270
|
+
ident: str | None = None,
|
|
271
|
+
) -> dict:
|
|
272
|
+
"""Copy ``png`` into ``<run>/shots/`` and register it (same ``ident`` replaces the earlier one)."""
|
|
273
|
+
png = Path(png)
|
|
274
|
+
shots = self.dir / "shots"
|
|
275
|
+
shots.mkdir(parents=True, exist_ok=True)
|
|
276
|
+
ident = ident or png.stem
|
|
277
|
+
target = shots / f"{ident}.png"
|
|
278
|
+
if png.resolve() != target.resolve():
|
|
279
|
+
shutil.copyfile(png, target)
|
|
280
|
+
entry = {
|
|
281
|
+
"id": ident,
|
|
282
|
+
"title": title,
|
|
283
|
+
"url": f"/files/shots/{target.name}?v={int(target.stat().st_mtime)}",
|
|
284
|
+
"step": step,
|
|
285
|
+
"caption": caption,
|
|
286
|
+
"created": _now(),
|
|
287
|
+
"source": source,
|
|
288
|
+
}
|
|
289
|
+
self.state["screenshots"] = [s for s in self.state["screenshots"] if s["id"] != ident] + [entry]
|
|
290
|
+
self.save()
|
|
291
|
+
return entry
|
|
292
|
+
|
|
293
|
+
@_locked
|
|
294
|
+
def plot(self, spec: dict) -> None:
|
|
295
|
+
"""Add or replace a PlotSpec (``id`` is the key)."""
|
|
296
|
+
spec = _plain(spec)
|
|
297
|
+
self.state["plots"] = [p for p in self.state["plots"] if p["id"] != spec["id"]] + [spec]
|
|
298
|
+
self.save()
|
|
299
|
+
|
|
300
|
+
@_locked
|
|
301
|
+
def set(self, **fields) -> None:
|
|
302
|
+
"""Set top-level fields: targets, goal, circuit, hamiltonian, consensus, jobs, cmatrix, history."""
|
|
303
|
+
for k, v in fields.items():
|
|
304
|
+
self.state[k] = _plain(v)
|
|
305
|
+
self.save()
|
|
306
|
+
|
|
307
|
+
@_locked
|
|
308
|
+
def iteration(self, entry: dict) -> None:
|
|
309
|
+
self.state["history"] = [h for h in self.state["history"] if h["iteration"] != entry["iteration"]]
|
|
310
|
+
self.state["history"].append(_plain({"time": _now(), **entry}))
|
|
311
|
+
self.state["history"].sort(key=lambda h: h["iteration"])
|
|
312
|
+
self.save()
|
|
313
|
+
|
|
314
|
+
def refresh_jobs(self, jobs_root: str | Path | None = None, keep_root: str | Path | None = "auto") -> list[dict]:
|
|
315
|
+
"""Scan ``jobs_root`` (and the tutorials' kept FEM results) for the job directories of this run's design(s):
|
|
316
|
+
status, results, and the solve progress (:func:`job_progress`). Returns the jobs and stores them."""
|
|
317
|
+
# no lock while scanning (file reads, imports): a thread that holds _LOCK and waits for an import lock
|
|
318
|
+
# deadlocks with the thread that is importing and calls into a Run
|
|
319
|
+
names = set(self.design_names) | {self.state["design"].get("name")}
|
|
320
|
+
roots = [Path(jobs_root)] if jobs_root else [self.dir.parent / "jobs", Path.cwd() / "build" / "jobs"]
|
|
321
|
+
found: dict[str, dict] = {}
|
|
322
|
+
for root in dict.fromkeys(r.resolve() for r in roots): # the run root's jobs, and the cwd's (examples/build)
|
|
323
|
+
found.update({j["name"]: j for j in scan_jobs(names, root, keep_root)})
|
|
324
|
+
jobs = sorted(found.values(), key=lambda j: j["name"])
|
|
325
|
+
if json.dumps(jobs, sort_keys=True) != json.dumps(self.state.get("jobs"), sort_keys=True):
|
|
326
|
+
self.set(jobs=jobs)
|
|
327
|
+
return jobs
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
# ---- FEM jobs -----------------------------------------------------------------------------------------------------
|
|
331
|
+
_RUNNING = ("solving", "rendering", "running")
|
|
332
|
+
_NOISE = ("vgl_", "SYS_ERROR", "type=", "Argument is not")
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def _read_json(path: Path) -> dict:
|
|
336
|
+
try:
|
|
337
|
+
return json.loads(path.read_text(encoding="utf-8"))
|
|
338
|
+
except (OSError, ValueError):
|
|
339
|
+
return {}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def pid_alive(pid: int) -> bool:
|
|
343
|
+
"""Whether process ``pid`` exists (never signals it: a query only)."""
|
|
344
|
+
if pid <= 0:
|
|
345
|
+
return False
|
|
346
|
+
if os.name == "nt":
|
|
347
|
+
import ctypes # pylint: disable=import-outside-toplevel
|
|
348
|
+
|
|
349
|
+
k32 = ctypes.windll.kernel32 # type: ignore[attr-defined]
|
|
350
|
+
h = k32.OpenProcess(0x1000, False, pid) # PROCESS_QUERY_LIMITED_INFORMATION
|
|
351
|
+
if not h:
|
|
352
|
+
return False
|
|
353
|
+
code = ctypes.c_ulong()
|
|
354
|
+
ok = k32.GetExitCodeProcess(h, ctypes.byref(code))
|
|
355
|
+
k32.CloseHandle(h)
|
|
356
|
+
return bool(ok) and code.value == 259 # STILL_ACTIVE
|
|
357
|
+
try:
|
|
358
|
+
os.kill(pid, 0)
|
|
359
|
+
except ProcessLookupError:
|
|
360
|
+
return False
|
|
361
|
+
except PermissionError:
|
|
362
|
+
return True
|
|
363
|
+
return True
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def job_alive(d: Path, job: dict) -> bool:
|
|
367
|
+
"""A job whose ``job.json`` says "solving" / "rendering": is the AEDT process still there? (``<log>.pid``, written
|
|
368
|
+
by ``hfss.run_aedt``). Without a pid file a job that started under a minute ago counts as alive."""
|
|
369
|
+
for stem in ("solve.log.pid", "render.log.pid"):
|
|
370
|
+
f = d / stem
|
|
371
|
+
if f.exists():
|
|
372
|
+
try:
|
|
373
|
+
pid = int(f.read_text(encoding="utf-8").strip())
|
|
374
|
+
except (OSError, ValueError):
|
|
375
|
+
continue
|
|
376
|
+
if job.get("started") and f.stat().st_mtime < job["started"] - 5:
|
|
377
|
+
continue # the pid of an earlier run
|
|
378
|
+
if pid_alive(pid):
|
|
379
|
+
return True
|
|
380
|
+
# AEDT has exited but qcc is still collecting the results (pyEPR, notch fits) before job.json says done:
|
|
381
|
+
# the status file ends with "end" — finishing, not interrupted (for a few minutes at most)
|
|
382
|
+
status = d / ("qcc_solve_status.txt" if stem.startswith("solve") else "qcc_render_status.txt")
|
|
383
|
+
try:
|
|
384
|
+
lines = status.read_text(encoding="utf-8", errors="replace").split()
|
|
385
|
+
return bool(lines) and lines[-1] == "end" and time.time() - status.stat().st_mtime < 600
|
|
386
|
+
except OSError:
|
|
387
|
+
return False
|
|
388
|
+
return bool(job.get("started")) and time.time() - job["started"] < 60
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def _live_progress(d: Path) -> dict:
|
|
392
|
+
"""``sim_tools.aedt_progress.read_progress`` in the dashboard's ``JobProgress`` shape (``pass``, ``maxPasses``,
|
|
393
|
+
``delta`` / ``elements`` as one-entry lists, ``criterion``, ``target``, ``converged``, ``modesGHz``); empty when
|
|
394
|
+
AEDT has written no adaptive pass yet."""
|
|
395
|
+
from quantcore_circuits.sim_tools.aedt_progress import read_progress # pylint: disable=import-outside-toplevel
|
|
396
|
+
|
|
397
|
+
try:
|
|
398
|
+
p = read_progress(d)
|
|
399
|
+
except (OSError, ValueError):
|
|
400
|
+
return {}
|
|
401
|
+
if p.get("pass") is None:
|
|
402
|
+
return {}
|
|
403
|
+
out = {"pass": p["pass"], "criterion": p.get("criterion"), "target": p.get("target"), "delta": [p.get("delta")]}
|
|
404
|
+
if p.get("converged") is not None: # HFSS says so in EMConvData; Q3D's ΔC is only an estimate
|
|
405
|
+
out["converged"] = bool(p["converged"])
|
|
406
|
+
if p.get("max_passes"):
|
|
407
|
+
out["maxPasses"] = p["max_passes"]
|
|
408
|
+
if p.get("elements"):
|
|
409
|
+
out["elements"] = [p["elements"]]
|
|
410
|
+
if p.get("modes_GHz"):
|
|
411
|
+
out["modesGHz"] = [round(f, 4) for f in p["modes_GHz"]]
|
|
412
|
+
return out
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def job_progress(d: Path, job: dict) -> dict | None:
|
|
416
|
+
"""Solve progress of the job directory ``d`` from the files the solve leaves behind: ``job.json`` (status, start
|
|
417
|
+
time, settings), ``qcc_solve_status.txt`` / ``solve.log`` (last lines), ``*_convergence.txt`` (adaptive passes,
|
|
418
|
+
mesh, criterion), ``results/results.json``. None when there is nothing to show (an exported job)."""
|
|
419
|
+
status = job.get("status", "exported")
|
|
420
|
+
prog: dict = {}
|
|
421
|
+
if status in _RUNNING and not job_alive(d, job):
|
|
422
|
+
prog["stale"] = True # job.json still says "solving" but the process is gone (killed kernel, crash)
|
|
423
|
+
elif job.get("started") and status in _RUNNING:
|
|
424
|
+
prog["elapsedS"] = round(time.time() - job["started"], 1)
|
|
425
|
+
elif job.get("solve_seconds") is not None:
|
|
426
|
+
prog["elapsedS"] = job["solve_seconds"]
|
|
427
|
+
settings = job.get("settings") or {}
|
|
428
|
+
if settings.get("maximum_passes"):
|
|
429
|
+
prog["maxPasses"] = settings["maximum_passes"]
|
|
430
|
+
for stem in ("qcc_solve_status.txt", "qcc_render_status.txt"):
|
|
431
|
+
f = d / stem
|
|
432
|
+
if f.exists():
|
|
433
|
+
lines = [ln.strip() for ln in f.read_text(encoding="utf-8", errors="replace").splitlines() if ln.strip()]
|
|
434
|
+
if lines:
|
|
435
|
+
prog["stage"] = lines[-1][:160]
|
|
436
|
+
break
|
|
437
|
+
log = d / "solve.log"
|
|
438
|
+
if log.exists():
|
|
439
|
+
try:
|
|
440
|
+
with log.open("rb") as fh:
|
|
441
|
+
fh.seek(max(0, log.stat().st_size - 4096))
|
|
442
|
+
tail = fh.read().decode("utf-8", errors="replace").splitlines()
|
|
443
|
+
except OSError:
|
|
444
|
+
tail = []
|
|
445
|
+
tail = [ln.strip() for ln in tail if ln.strip() and not any(n in ln for n in _NOISE)]
|
|
446
|
+
if tail:
|
|
447
|
+
prog["logTail"] = tail[-1][:200]
|
|
448
|
+
conv_files = sorted(d.glob("*_project_convergence.txt")) # written by AEDT at the end of the solve
|
|
449
|
+
if not conv_files: # still running: gui-live's reader (EMConvData, per-pass Q3D / eigenmode .sd, mesh stats)
|
|
450
|
+
prog.update(_live_progress(d))
|
|
451
|
+
if conv_files:
|
|
452
|
+
from quantcore_circuits.analysis.results import parse_convergence # pylint: disable=import-outside-toplevel
|
|
453
|
+
|
|
454
|
+
try:
|
|
455
|
+
c = parse_convergence(conv_files[0])
|
|
456
|
+
except (OSError, ValueError):
|
|
457
|
+
c = None
|
|
458
|
+
if c and c["passes"]:
|
|
459
|
+
prog.update(
|
|
460
|
+
passes=c["passes"],
|
|
461
|
+
elements=c["elements"],
|
|
462
|
+
delta=c["delta"],
|
|
463
|
+
converged=c["converged"],
|
|
464
|
+
criterion=c["criterion"],
|
|
465
|
+
target=c["target"],
|
|
466
|
+
pass_=c["passes"][-1],
|
|
467
|
+
)
|
|
468
|
+
prog["pass"] = prog.pop("pass_")
|
|
469
|
+
return prog if set(prog) - {"maxPasses"} else None # an exported job has nothing to show
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def scan_jobs(names, jobs_root: str | Path = "build/jobs", keep_root: str | Path | None = "auto") -> list[dict]:
|
|
473
|
+
"""Jobs (``job.json``) of designs ``names`` under ``jobs_root``; with ``keep_root`` ("auto": the tutorials'
|
|
474
|
+
``examples/tutorials/fem``) kept results of a job count when the build copy has none (``source: "kept"``)."""
|
|
475
|
+
names = {n for n in names if n}
|
|
476
|
+
roots = [Path(jobs_root)]
|
|
477
|
+
if keep_root == "auto":
|
|
478
|
+
keep_root = Path(jobs_root).parent.parent / "examples" / "tutorials" / "fem"
|
|
479
|
+
if keep_root:
|
|
480
|
+
roots.append(Path(keep_root))
|
|
481
|
+
found: dict[str, dict] = {}
|
|
482
|
+
for root in roots:
|
|
483
|
+
if not root.exists():
|
|
484
|
+
continue
|
|
485
|
+
for job_json in sorted(root.glob("*/job.json")):
|
|
486
|
+
job = _read_json(job_json)
|
|
487
|
+
if job.get("design") not in names:
|
|
488
|
+
continue
|
|
489
|
+
d = job_json.parent
|
|
490
|
+
has_res = (d / "results" / "results.json").exists()
|
|
491
|
+
project = next(iter(sorted(d.glob("*_project.aedt"))), None)
|
|
492
|
+
fin = job.get("finished")
|
|
493
|
+
entry = {
|
|
494
|
+
"name": d.name,
|
|
495
|
+
"group": job.get("group"),
|
|
496
|
+
"analysis": job.get("analysis"),
|
|
497
|
+
"solver": job.get("solver"),
|
|
498
|
+
"status": "interrupted"
|
|
499
|
+
if job.get("status") in _RUNNING and not job_alive(d, job)
|
|
500
|
+
else job.get("status", "exported"),
|
|
501
|
+
"created": job.get("created"),
|
|
502
|
+
"finished": datetime.fromtimestamp(fin, UTC).isoformat(timespec="seconds") if fin else None,
|
|
503
|
+
"hasResults": has_res,
|
|
504
|
+
"project": str(project) if project else None,
|
|
505
|
+
"progress": job_progress(d, job),
|
|
506
|
+
}
|
|
507
|
+
old = found.get(d.name)
|
|
508
|
+
if old is None:
|
|
509
|
+
found[d.name] = entry
|
|
510
|
+
elif has_res and not old["hasResults"] and old["status"] not in _RUNNING:
|
|
511
|
+
# kept results of a job whose build copy was not solved in this checkout
|
|
512
|
+
found[d.name] = {
|
|
513
|
+
**old,
|
|
514
|
+
"status": "done",
|
|
515
|
+
"hasResults": True,
|
|
516
|
+
"source": "kept",
|
|
517
|
+
"finished": entry["finished"] or old["finished"],
|
|
518
|
+
}
|
|
519
|
+
return sorted(found.values(), key=lambda j: j["name"])
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
def _json_default(o):
|
|
523
|
+
if hasattr(o, "tolist"):
|
|
524
|
+
return o.tolist()
|
|
525
|
+
if hasattr(o, "item"):
|
|
526
|
+
return o.item()
|
|
527
|
+
if isinstance(o, Path):
|
|
528
|
+
return str(o)
|
|
529
|
+
return str(o)
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
def _plain(v):
|
|
533
|
+
"""numpy scalars/arrays, tuples and dataclasses → JSON-safe Python values."""
|
|
534
|
+
return json.loads(json.dumps(v, default=_json_default))
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
# ---- automatic tracking (see :mod:`quantcore_circuits.autotrack`) ----------------------------------------------------
|
|
538
|
+
_SESSION = None
|
|
539
|
+
_ENV_CHECKED = False
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
def default_root() -> Path:
|
|
543
|
+
"""``<repo>/build``: the folder with the pyproject.toml above the working directory (notebooks run from
|
|
544
|
+
``examples/``, ``examples/tutorials/`` or the root all share one set of runs), else ``./build``."""
|
|
545
|
+
here = Path.cwd().resolve()
|
|
546
|
+
for p in (here, *here.parents):
|
|
547
|
+
if (p / "pyproject.toml").exists() and (p / "src" / "quantcore_circuits").exists():
|
|
548
|
+
return p / "build"
|
|
549
|
+
return Path("build")
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
def start(
|
|
553
|
+
name: str | None = None,
|
|
554
|
+
*,
|
|
555
|
+
reset: bool = True,
|
|
556
|
+
snapshots: bool = True,
|
|
557
|
+
root: str | Path | None = None,
|
|
558
|
+
dashboard: bool = False,
|
|
559
|
+
port: int = 8765,
|
|
560
|
+
open_browser: bool = True,
|
|
561
|
+
watch: bool = True,
|
|
562
|
+
):
|
|
563
|
+
"""Record the library's calls (builds, DRC, LOM, FEM jobs, feedback) into ``build/<name>/state.json``.
|
|
564
|
+
|
|
565
|
+
``name``: one run for everything (e.g. a tutorial's revisions); None: one run per design name. ``reset``: start
|
|
566
|
+
the run(s) fresh. ``dashboard=True`` also serves the dashboard from this process (background thread) following
|
|
567
|
+
the run. Returns the session (``.flush()`` waits for the background snapshots)."""
|
|
568
|
+
global _SESSION, _ENV_CHECKED # noqa: PLW0603
|
|
569
|
+
from quantcore_circuits.autotrack import Session # pylint: disable=import-outside-toplevel
|
|
570
|
+
|
|
571
|
+
root = Path(root) if root is not None else default_root()
|
|
572
|
+
|
|
573
|
+
_ENV_CHECKED = True
|
|
574
|
+
if _SESSION is not None:
|
|
575
|
+
_SESSION.stop()
|
|
576
|
+
_SESSION = Session(name, root, reset=reset, snapshots=snapshots, watch=watch)
|
|
577
|
+
if dashboard:
|
|
578
|
+
from quantcore_circuits.review.server import serve_live # pylint: disable=import-outside-toplevel
|
|
579
|
+
|
|
580
|
+
_SESSION.server = serve_live(root=root, run=name, port=port, open_browser=open_browser, background=True)
|
|
581
|
+
return _SESSION
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
def stop() -> None:
|
|
585
|
+
global _SESSION # noqa: PLW0603
|
|
586
|
+
if _SESSION is not None:
|
|
587
|
+
_SESSION.flush()
|
|
588
|
+
_SESSION.stop()
|
|
589
|
+
server = getattr(_SESSION, "server", None)
|
|
590
|
+
if server is not None:
|
|
591
|
+
server.shutdown()
|
|
592
|
+
server.server_close()
|
|
593
|
+
_SESSION = None
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def session():
|
|
597
|
+
"""The active tracking session or None (``QCC_TRACK=1`` / ``QCC_TRACK=<run name>`` starts one on first use)."""
|
|
598
|
+
global _ENV_CHECKED # noqa: PLW0603
|
|
599
|
+
if _SESSION is None and not _ENV_CHECKED:
|
|
600
|
+
_ENV_CHECKED = True
|
|
601
|
+
env = os.environ.get("QCC_TRACK", "").strip()
|
|
602
|
+
if env and env.lower() not in ("0", "false", "no", "off"):
|
|
603
|
+
start(None if env.lower() in ("1", "true", "yes", "on") else env)
|
|
604
|
+
return _SESSION
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def emit(event: str, **kw) -> None:
|
|
608
|
+
"""Library hook: report ``event`` to the tracking session (no-op when tracking is off; never raises)."""
|
|
609
|
+
s = session()
|
|
610
|
+
if s is not None:
|
|
611
|
+
s.handle(event, kw)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
def run_for(design=None, model_name: str | None = None):
|
|
615
|
+
"""The tracking session's Run for ``design`` (None when tracking is off): what ``loop.analyse`` records into."""
|
|
616
|
+
s = session()
|
|
617
|
+
if s is None:
|
|
618
|
+
return None
|
|
619
|
+
try:
|
|
620
|
+
return s.run_for(design, model_name)
|
|
621
|
+
except Exception: # noqa: BLE001 pylint: disable=broad-except # tracking never breaks the caller
|
|
622
|
+
return None
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
@contextlib.contextmanager
|
|
626
|
+
def quiet():
|
|
627
|
+
"""Suspend the automatic fill/LOM/DRC hooks (a caller that records those results itself, e.g. ``loop.analyse``)."""
|
|
628
|
+
s = _SESSION
|
|
629
|
+
if s is None:
|
|
630
|
+
yield
|
|
631
|
+
return
|
|
632
|
+
s.quiet_depth += 1
|
|
633
|
+
try:
|
|
634
|
+
yield
|
|
635
|
+
finally:
|
|
636
|
+
s.quiet_depth -= 1
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
class _Stage:
|
|
640
|
+
"""Handle of :func:`stage`: ``fail(msg)`` ends the stage "failed" without raising; ``note`` is the done summary."""
|
|
641
|
+
|
|
642
|
+
def __init__(self, note: str = ""):
|
|
643
|
+
self.failed: str | None = None
|
|
644
|
+
self.note = note
|
|
645
|
+
|
|
646
|
+
def fail(self, msg: str = "failed") -> None:
|
|
647
|
+
self.failed = msg
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
@contextlib.contextmanager
|
|
651
|
+
def stage(step: str, label: str = ""):
|
|
652
|
+
"""Mark dashboard step ``step`` running, then done (or failed on an exception / ``handle.fail(msg)``) when the
|
|
653
|
+
block ends. Nested stages of one step (``hfss.render`` exporting its job) mark only the outermost. No-op when
|
|
654
|
+
tracking is off; never raises on its own."""
|
|
655
|
+
h = _Stage()
|
|
656
|
+
if session() is None:
|
|
657
|
+
yield h
|
|
658
|
+
return
|
|
659
|
+
emit("stage", step=step, phase="running", label=label)
|
|
660
|
+
try:
|
|
661
|
+
yield h
|
|
662
|
+
except BaseException as e:
|
|
663
|
+
emit("stage", step=step, phase="failed", label=label, detail=f"{type(e).__name__}: {e}")
|
|
664
|
+
raise
|
|
665
|
+
emit(
|
|
666
|
+
"stage",
|
|
667
|
+
step=step,
|
|
668
|
+
phase="failed" if h.failed else "done",
|
|
669
|
+
label=label,
|
|
670
|
+
detail=h.failed or h.note,
|
|
671
|
+
)
|