dbac 0.1.0__tar.gz

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.
Files changed (70) hide show
  1. dbac-0.1.0/.github/workflows/docs.yml +38 -0
  2. dbac-0.1.0/.github/workflows/publish.yml +43 -0
  3. dbac-0.1.0/.gitignore +9 -0
  4. dbac-0.1.0/CITATION.cff +20 -0
  5. dbac-0.1.0/PKG-INFO +138 -0
  6. dbac-0.1.0/README.md +111 -0
  7. dbac-0.1.0/docs/Makefile +5 -0
  8. dbac-0.1.0/docs/api/dbqite.md +63 -0
  9. dbac-0.1.0/docs/api/dme.md +50 -0
  10. dbac-0.1.0/docs/api/gci.md +32 -0
  11. dbac-0.1.0/docs/api/hbac.md +32 -0
  12. dbac-0.1.0/docs/api/index.md +38 -0
  13. dbac-0.1.0/docs/api/plotting.md +149 -0
  14. dbac-0.1.0/docs/api/utils.md +46 -0
  15. dbac-0.1.0/docs/conf.py +47 -0
  16. dbac-0.1.0/docs/figures.md +86 -0
  17. dbac-0.1.0/docs/guide/conventions.md +114 -0
  18. dbac-0.1.0/docs/guide/dbac-step.md +159 -0
  19. dbac-0.1.0/docs/guide/dme.md +144 -0
  20. dbac-0.1.0/docs/guide/hbac.md +113 -0
  21. dbac-0.1.0/docs/guide/plotting.md +135 -0
  22. dbac-0.1.0/docs/guide/recursion.md +150 -0
  23. dbac-0.1.0/docs/index.ipynb +584 -0
  24. dbac-0.1.0/docs/installation.md +62 -0
  25. dbac-0.1.0/docs/quickstart.md +68 -0
  26. dbac-0.1.0/figures/F4_Circuit_A_n_2.pdf +0 -0
  27. dbac-0.1.0/figures/F4_Circuit_B_n_3.pdf +0 -0
  28. dbac-0.1.0/figures/F4_Circuit_C_n_4.pdf +0 -0
  29. dbac-0.1.0/figures/S2_DME_norm.pdf +0 -0
  30. dbac-0.1.0/figures/S4_QITE_ideal_DME_merged.pdf +0 -0
  31. dbac-0.1.0/figures/S5_bloch_bad.pdf +0 -0
  32. dbac-0.1.0/figures/S5_bloch_good.pdf +0 -0
  33. dbac-0.1.0/figures/S5_bloch_mid.pdf +0 -0
  34. dbac-0.1.0/figures/S6_M1k1_s_sweep.pdf +0 -0
  35. dbac-0.1.0/figures/S6_M2k1_s_sweep.pdf +0 -0
  36. dbac-0.1.0/notebooks/config.py +17 -0
  37. dbac-0.1.0/notebooks/dme_ptm_plot.ipynb +275 -0
  38. dbac-0.1.0/notebooks/draw_circuit.ipynb +810 -0
  39. dbac-0.1.0/notebooks/hbac.ipynb +174 -0
  40. dbac-0.1.0/notebooks/optimal_s_Mk.npy +0 -0
  41. dbac-0.1.0/notebooks/sup_figure_S4.ipynb +167 -0
  42. dbac-0.1.0/pyproject.toml +43 -0
  43. dbac-0.1.0/requirements.txt +2 -0
  44. dbac-0.1.0/scripts/figure_4.py +114 -0
  45. dbac-0.1.0/scripts/sup_figure_S2.py +94 -0
  46. dbac-0.1.0/scripts/sup_figure_S4.py +126 -0
  47. dbac-0.1.0/scripts/sup_figure_S5.py +93 -0
  48. dbac-0.1.0/scripts/sup_figure_S6.py +79 -0
  49. dbac-0.1.0/src/dbac/__init__.py +12 -0
  50. dbac-0.1.0/src/dbac/dbqite.py +192 -0
  51. dbac-0.1.0/src/dbac/dme.py +160 -0
  52. dbac-0.1.0/src/dbac/gci.py +226 -0
  53. dbac-0.1.0/src/dbac/hbac.py +100 -0
  54. dbac-0.1.0/src/dbac/plotting/__init__.py +23 -0
  55. dbac-0.1.0/src/dbac/plotting/bloch.py +255 -0
  56. dbac-0.1.0/src/dbac/plotting/circuits.py +117 -0
  57. dbac-0.1.0/src/dbac/plotting/cooling.py +468 -0
  58. dbac-0.1.0/src/dbac/plotting/dme.py +62 -0
  59. dbac-0.1.0/src/dbac/plotting/gci.py +48 -0
  60. dbac-0.1.0/src/dbac/plotting/ptm.py +174 -0
  61. dbac-0.1.0/src/dbac/plotting/style.py +45 -0
  62. dbac-0.1.0/src/dbac/utils.py +137 -0
  63. dbac-0.1.0/tests/conftest.py +27 -0
  64. dbac-0.1.0/tests/test_core.py +68 -0
  65. dbac-0.1.0/tests/test_dbqite.py +87 -0
  66. dbac-0.1.0/tests/test_dme.py +80 -0
  67. dbac-0.1.0/tests/test_gci.py +81 -0
  68. dbac-0.1.0/tests/test_hbac.py +49 -0
  69. dbac-0.1.0/tests/test_plotting.py +80 -0
  70. dbac-0.1.0/tests/test_utils.py +75 -0
@@ -0,0 +1,38 @@
1
+ name: docs
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ workflow_dispatch:
6
+
7
+ permissions:
8
+ contents: read
9
+ pages: write
10
+ id-token: write
11
+
12
+ concurrency:
13
+ group: pages
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ build:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.12"
24
+ - run: pip install -e ".[docs]"
25
+ - run: make -C docs html
26
+ - uses: actions/upload-pages-artifact@v3
27
+ with:
28
+ path: docs/_build/html
29
+
30
+ deploy:
31
+ needs: build
32
+ runs-on: ubuntu-latest
33
+ environment:
34
+ name: github-pages
35
+ url: ${{ steps.deployment.outputs.page_url }}
36
+ steps:
37
+ - id: deployment
38
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,43 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.12"
17
+
18
+ - name: Build sdist and wheel
19
+ run: |
20
+ python -m pip install --upgrade build twine
21
+ python -m build
22
+ python -m twine check dist/*
23
+
24
+ - uses: actions/upload-artifact@v4
25
+ with:
26
+ name: dist
27
+ path: dist/
28
+
29
+ publish:
30
+ needs: build
31
+ runs-on: ubuntu-latest
32
+ environment:
33
+ name: pypi
34
+ url: https://pypi.org/project/dbac/
35
+ permissions:
36
+ id-token: write # for PyPI trusted publishing
37
+ steps:
38
+ - uses: actions/download-artifact@v4
39
+ with:
40
+ name: dist
41
+ path: dist/
42
+
43
+ - uses: pypa/gh-action-pypi-publish@release/v1
dbac-0.1.0/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .ipynb_checkpoints/
4
+ .venv/
5
+ .history/
6
+ dist/
7
+ build/
8
+ *.egg-info/
9
+ _build/
@@ -0,0 +1,20 @@
1
+ cff-version: 1.2.0
2
+ message: If you use this software, please cite the accompanying paper.
3
+ title: dbac
4
+ type: software
5
+ repository-code: https://github.com/khanhuyengiang/dbac
6
+ preferred-citation:
7
+ type: article
8
+ title: Double-Bracket Algorithmic Cooling
9
+ authors:
10
+ - {family-names: Alghadeer, given-names: Mohammed}
11
+ - {family-names: Giang, given-names: Khanh Uyen}
12
+ - {family-names: Cao, given-names: Shuxiang}
13
+ - {family-names: Fasciati, given-names: Simone D.}
14
+ - {family-names: Piscitelli, given-names: Michele}
15
+ - {family-names: Ng, given-names: Nelly}
16
+ - {family-names: Leek, given-names: Peter J.}
17
+ - {family-names: Gluza, given-names: Marek}
18
+ - {family-names: Bakr, given-names: Mustafa}
19
+ journal: arXiv preprint arXiv:2510.00302
20
+ year: 2025
dbac-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,138 @@
1
+ Metadata-Version: 2.5
2
+ Name: dbac
3
+ Version: 0.1.0
4
+ Summary: Double-Bracket Algorithmic Cooling: simulation, DME, HBAC baseline and plotting code.
5
+ Project-URL: Homepage, https://github.com/khanhuyengiang/dbac
6
+ Project-URL: Paper, https://arxiv.org/abs/2510.00302
7
+ Author-email: Khanh Uyen Giang <khanh.giang@tu-darmstadt.de>
8
+ Keywords: QITE,algorithmic cooling,density matrix exponentiation,double-bracket flow,quantum
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Physics
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: matplotlib>=3.9
14
+ Requires-Dist: numpy>=1.26
15
+ Requires-Dist: qibo>=0.3
16
+ Requires-Dist: qutip>=5.0
17
+ Requires-Dist: scipy>=1.11
18
+ Provides-Extra: docs
19
+ Requires-Dist: furo; extra == 'docs'
20
+ Requires-Dist: myst-nb>=1.0; extra == 'docs'
21
+ Requires-Dist: sphinx>=7.3; extra == 'docs'
22
+ Provides-Extra: notebooks
23
+ Requires-Dist: jupyter>=1.1; extra == 'notebooks'
24
+ Provides-Extra: test
25
+ Requires-Dist: pytest>=8; extra == 'test'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Double-Bracket Algorithmic Cooling (dbac) package
29
+
30
+ Code accompanying the paper **[Double-Bracket Algorithmic Cooling](https://arxiv.org/abs/2510.00302)**
31
+ (M. Alghadeer, K. U. Giang, S. Cao, S. D. Fasciati, M. Piscitelli, N. Ng, P. J. Leek,
32
+ M. Gluza, M. Bakr).
33
+
34
+ ## Background
35
+
36
+ Algorithmic cooling lowers the entropy of a qubit using only local operations and a
37
+ "colder" ancilla, and is the basis of established techniques like heat-bath algorithmic
38
+ cooling (HBAC). This paper introduces **double-bracket algorithmic cooling (DBAC)**, which
39
+ instead removes *coherence* from an already-pure qubit state, extending algorithmic
40
+ cooling from a thermodynamic (entropy) notion of cooling to a genuinely quantum one.
41
+
42
+ DBAC simulates quantum imaginary-time evolution (QITE) by recursively synthesizing
43
+ unitaries that implement Riemannian steepest-descent ("double-bracket") flows towards the
44
+ ground state, one small step at a time. Each step needs an extra copy of the current state
45
+ to act as a **quantum instruction**: that copy is consumed via **density matrix
46
+ exponentiation (DME)**, a protocol that uses repeated partial SWAPs to approximate the
47
+ unitary $e^{-it\rho}$ generated by a state $\rho$, without ever synthesizing $\rho$ as a
48
+ gate. Because the resulting circuit does not depend on the input state and needs no
49
+ measurements or feedback, cooling performance is governed entirely by *how many* quantum
50
+ instructions (copies of the state) are available -- a trade-off the paper relates to the
51
+ Nernst principle ("cooling to absolute zero costs infinite resources").
52
+
53
+ ## Repository layout
54
+
55
+ ```
56
+ src/dbac/ Physics and numerics: DME, DB-QITE/GCI recursion, HBAC, state utilities.
57
+ src/dbac/plotting/ All plotting code, factored out of the physics and shared across scripts/notebooks.
58
+ scripts/ The three DBAC scripts (computation + plotting), runnable standalone.
59
+ notebooks/ Narrated walkthroughs that call scripts/ and dbac.plotting and explain the physics.
60
+ figures/ All generated figures (PDF).
61
+ docs/ Sphinx documentation (`pip install -e ".[docs]" && make -C docs html`).
62
+ ```
63
+
64
+ ### `src/dbac/` -- physics and numerics (no plotting)
65
+
66
+ | File | Contents |
67
+ |---|---|
68
+ | `dme.py` | Density matrix exponentiation: exact (`dme_expm`), SWAP+numpy (`dme_channel`), analytical equivalent (`dme_channel_equivalent`), and qibo-circuit (`dme_qibo`) implementations. |
69
+ | `dbqite.py` | A single-qubit DB-QITE step built on top of Trotterized DME (`QITE_GCI_dme`) or on the exact unitary (`ideal_DME`). |
70
+ | `gci.py` | `GCI`: runs and tracks a DB-QITE/"group commutator iteration" recursion (energy, fidelity, states) for a fixed number of steps or by greedily picking the best step size at each round. |
71
+ | `hbac.py` | Heat-bath algorithmic cooling (reset + compress), the classical baseline DBAC is compared against. |
72
+ | `utils.py` | Shared helpers: fidelity with the ground state, depolarizing noise, thermal states, the $R_X(\theta)$ initial-state sweep used throughout. |
73
+
74
+ ### `src/dbac/plotting/` -- all plotting
75
+
76
+ | File | Contents |
77
+ |---|---|
78
+ | `style.py` | Shared journal figure sizes and matplotlib `rcParams`. |
79
+ | `bloch.py` | Bloch-sphere rendering of single-qubit states and DB-QITE recursion trajectories. |
80
+ | `ptm.py` | Pauli-transfer-matrix heatmaps and a hue/size process-matrix plot. |
81
+ | `gci.py` | Energy/fidelity vs. evolution-duration plots for `GCI.execute_gci` output. |
82
+ | `cooling.py` | The cooling-performance figures: fidelity-fidelity plots, energy-vs-$\theta$ plots, grid layouts, and the ideal-DME summary figure. |
83
+ | `dme.py` | DME-channel-implementation benchmark plots. |
84
+
85
+ ### `scripts/` -- one script per result, runnable from the command line
86
+
87
+ The three DBAC scripts do the computation (calling into `dbac`), calls `dbac.plotting` to
88
+ plot it, and saves the resulting figures to `figures/`:
89
+
90
+ ```bash
91
+ pip install -e .
92
+ python scripts/sup_figure_S2.py # DME channel implementation benchmark
93
+ python scripts/sup_figure_S4.py # DBAC with ideal (M -> infinity) DME, sweep over k
94
+ python scripts/figure_4.py # Main result: cooling vs. number of quantum instructions (Fig. 4)
95
+ python scripts/sup_figure_S5.py # Bloch-sphere illustration of the DBAC recursion
96
+ ```
97
+
98
+ ### `notebooks/` -- narrated walkthroughs
99
+
100
+ | Notebook | Figure(s) | What it shows |
101
+ |---|---|---|
102
+ | [`dme_ptm_plot.ipynb`](notebooks/dme_ptm_plot.ipynb) | `ptm_*.pdf` | Pauli-transfer-matrix view of the ideal $ZZ$ interaction, the DME unitary, and the two hardware circuits (A, B). |
103
+ | [`hbac.ipynb`](notebooks/hbac.ipynb) | `hbac_3_qubits.pdf` | Heat-bath algorithmic cooling baseline on a 3-qubit chain, pure vs. depolarized input. |
104
+ | [`sup_figure_S4.ipynb`](notebooks/sup_figure_S4.ipynb) | `S4_QITE_ideal_DME_merged.pdf` (Fig. 7) | DBAC in the ideal-DME limit, sweeping the recursion depth $k$. |
105
+ | [`docs/index.ipynb`](docs/index.ipynb) | `F4_*.pdf` (Fig. 4) | **Main result** (also the front page of the docs): Trotterized-DME DBAC cooling performance vs. number of quantum instructions, compared to hardware experiment data. |
106
+
107
+ `notebooks/not_in_use/` holds earlier exploratory notebooks kept for reference;
108
+ they are not part of the maintained code path.
109
+
110
+ ## Setup
111
+
112
+ ```bash
113
+ python3 -m venv .venv
114
+ source .venv/bin/activate
115
+ pip install -e ".[notebooks]"
116
+ jupyter notebook notebooks/
117
+ ```
118
+
119
+ Figures that use LaTeX-rendered labels require a local LaTeX installation (`matplotlib`'s
120
+ `text.usetex`); without one, either install `texlive` or disable it via
121
+ `dbac.plotting.use_paper_style(use_tex=False)`.
122
+
123
+ ## Citation
124
+
125
+ If you use this code, please cite:
126
+
127
+ ```bibtex
128
+ @article{alghadeer2025dbac,
129
+ title = {Double-Bracket Algorithmic Cooling},
130
+ author = {Alghadeer, Mohammed and Giang, Khanh Uyen and Cao, Shuxiang and
131
+ Fasciati, Simone D. and Piscitelli, Michele and Ng, Nelly and
132
+ Leek, Peter J. and Gluza, Marek and Bakr, Mustafa},
133
+ journal = {arXiv preprint arXiv:2510.00302},
134
+ year = {2025}
135
+ }
136
+ ```
137
+
138
+ Notebooks only save their plots when `SAVE_PLOTS = True` in [`notebooks/config.py`](notebooks/config.py) (off by default); PDFs then go to `figures/`.
dbac-0.1.0/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # Double-Bracket Algorithmic Cooling (dbac) package
2
+
3
+ Code accompanying the paper **[Double-Bracket Algorithmic Cooling](https://arxiv.org/abs/2510.00302)**
4
+ (M. Alghadeer, K. U. Giang, S. Cao, S. D. Fasciati, M. Piscitelli, N. Ng, P. J. Leek,
5
+ M. Gluza, M. Bakr).
6
+
7
+ ## Background
8
+
9
+ Algorithmic cooling lowers the entropy of a qubit using only local operations and a
10
+ "colder" ancilla, and is the basis of established techniques like heat-bath algorithmic
11
+ cooling (HBAC). This paper introduces **double-bracket algorithmic cooling (DBAC)**, which
12
+ instead removes *coherence* from an already-pure qubit state, extending algorithmic
13
+ cooling from a thermodynamic (entropy) notion of cooling to a genuinely quantum one.
14
+
15
+ DBAC simulates quantum imaginary-time evolution (QITE) by recursively synthesizing
16
+ unitaries that implement Riemannian steepest-descent ("double-bracket") flows towards the
17
+ ground state, one small step at a time. Each step needs an extra copy of the current state
18
+ to act as a **quantum instruction**: that copy is consumed via **density matrix
19
+ exponentiation (DME)**, a protocol that uses repeated partial SWAPs to approximate the
20
+ unitary $e^{-it\rho}$ generated by a state $\rho$, without ever synthesizing $\rho$ as a
21
+ gate. Because the resulting circuit does not depend on the input state and needs no
22
+ measurements or feedback, cooling performance is governed entirely by *how many* quantum
23
+ instructions (copies of the state) are available -- a trade-off the paper relates to the
24
+ Nernst principle ("cooling to absolute zero costs infinite resources").
25
+
26
+ ## Repository layout
27
+
28
+ ```
29
+ src/dbac/ Physics and numerics: DME, DB-QITE/GCI recursion, HBAC, state utilities.
30
+ src/dbac/plotting/ All plotting code, factored out of the physics and shared across scripts/notebooks.
31
+ scripts/ The three DBAC scripts (computation + plotting), runnable standalone.
32
+ notebooks/ Narrated walkthroughs that call scripts/ and dbac.plotting and explain the physics.
33
+ figures/ All generated figures (PDF).
34
+ docs/ Sphinx documentation (`pip install -e ".[docs]" && make -C docs html`).
35
+ ```
36
+
37
+ ### `src/dbac/` -- physics and numerics (no plotting)
38
+
39
+ | File | Contents |
40
+ |---|---|
41
+ | `dme.py` | Density matrix exponentiation: exact (`dme_expm`), SWAP+numpy (`dme_channel`), analytical equivalent (`dme_channel_equivalent`), and qibo-circuit (`dme_qibo`) implementations. |
42
+ | `dbqite.py` | A single-qubit DB-QITE step built on top of Trotterized DME (`QITE_GCI_dme`) or on the exact unitary (`ideal_DME`). |
43
+ | `gci.py` | `GCI`: runs and tracks a DB-QITE/"group commutator iteration" recursion (energy, fidelity, states) for a fixed number of steps or by greedily picking the best step size at each round. |
44
+ | `hbac.py` | Heat-bath algorithmic cooling (reset + compress), the classical baseline DBAC is compared against. |
45
+ | `utils.py` | Shared helpers: fidelity with the ground state, depolarizing noise, thermal states, the $R_X(\theta)$ initial-state sweep used throughout. |
46
+
47
+ ### `src/dbac/plotting/` -- all plotting
48
+
49
+ | File | Contents |
50
+ |---|---|
51
+ | `style.py` | Shared journal figure sizes and matplotlib `rcParams`. |
52
+ | `bloch.py` | Bloch-sphere rendering of single-qubit states and DB-QITE recursion trajectories. |
53
+ | `ptm.py` | Pauli-transfer-matrix heatmaps and a hue/size process-matrix plot. |
54
+ | `gci.py` | Energy/fidelity vs. evolution-duration plots for `GCI.execute_gci` output. |
55
+ | `cooling.py` | The cooling-performance figures: fidelity-fidelity plots, energy-vs-$\theta$ plots, grid layouts, and the ideal-DME summary figure. |
56
+ | `dme.py` | DME-channel-implementation benchmark plots. |
57
+
58
+ ### `scripts/` -- one script per result, runnable from the command line
59
+
60
+ The three DBAC scripts do the computation (calling into `dbac`), calls `dbac.plotting` to
61
+ plot it, and saves the resulting figures to `figures/`:
62
+
63
+ ```bash
64
+ pip install -e .
65
+ python scripts/sup_figure_S2.py # DME channel implementation benchmark
66
+ python scripts/sup_figure_S4.py # DBAC with ideal (M -> infinity) DME, sweep over k
67
+ python scripts/figure_4.py # Main result: cooling vs. number of quantum instructions (Fig. 4)
68
+ python scripts/sup_figure_S5.py # Bloch-sphere illustration of the DBAC recursion
69
+ ```
70
+
71
+ ### `notebooks/` -- narrated walkthroughs
72
+
73
+ | Notebook | Figure(s) | What it shows |
74
+ |---|---|---|
75
+ | [`dme_ptm_plot.ipynb`](notebooks/dme_ptm_plot.ipynb) | `ptm_*.pdf` | Pauli-transfer-matrix view of the ideal $ZZ$ interaction, the DME unitary, and the two hardware circuits (A, B). |
76
+ | [`hbac.ipynb`](notebooks/hbac.ipynb) | `hbac_3_qubits.pdf` | Heat-bath algorithmic cooling baseline on a 3-qubit chain, pure vs. depolarized input. |
77
+ | [`sup_figure_S4.ipynb`](notebooks/sup_figure_S4.ipynb) | `S4_QITE_ideal_DME_merged.pdf` (Fig. 7) | DBAC in the ideal-DME limit, sweeping the recursion depth $k$. |
78
+ | [`docs/index.ipynb`](docs/index.ipynb) | `F4_*.pdf` (Fig. 4) | **Main result** (also the front page of the docs): Trotterized-DME DBAC cooling performance vs. number of quantum instructions, compared to hardware experiment data. |
79
+
80
+ `notebooks/not_in_use/` holds earlier exploratory notebooks kept for reference;
81
+ they are not part of the maintained code path.
82
+
83
+ ## Setup
84
+
85
+ ```bash
86
+ python3 -m venv .venv
87
+ source .venv/bin/activate
88
+ pip install -e ".[notebooks]"
89
+ jupyter notebook notebooks/
90
+ ```
91
+
92
+ Figures that use LaTeX-rendered labels require a local LaTeX installation (`matplotlib`'s
93
+ `text.usetex`); without one, either install `texlive` or disable it via
94
+ `dbac.plotting.use_paper_style(use_tex=False)`.
95
+
96
+ ## Citation
97
+
98
+ If you use this code, please cite:
99
+
100
+ ```bibtex
101
+ @article{alghadeer2025dbac,
102
+ title = {Double-Bracket Algorithmic Cooling},
103
+ author = {Alghadeer, Mohammed and Giang, Khanh Uyen and Cao, Shuxiang and
104
+ Fasciati, Simone D. and Piscitelli, Michele and Ng, Nelly and
105
+ Leek, Peter J. and Gluza, Marek and Bakr, Mustafa},
106
+ journal = {arXiv preprint arXiv:2510.00302},
107
+ year = {2025}
108
+ }
109
+ ```
110
+
111
+ Notebooks only save their plots when `SAVE_PLOTS = True` in [`notebooks/config.py`](notebooks/config.py) (off by default); PDFs then go to `figures/`.
@@ -0,0 +1,5 @@
1
+ html:
2
+ sphinx-build -b html . _build/html
3
+
4
+ clean:
5
+ rm -rf _build
@@ -0,0 +1,63 @@
1
+ # dbac.dbqite
2
+
3
+ One step of DBAC, called a *DB-QITE step* (double-bracket quantum imaginary-time evolution) in
4
+ the code. A step takes the current state of the data qubit and a duration $s$ and returns a
5
+ colder state:
6
+
7
+ $$
8
+ \rho \mapsto e^{is\rho'}\,\rho\,e^{-is\rho'}, \qquad \rho' = e^{is\hat H}\rho\, e^{-is\hat H},
9
+ \qquad \hat H = -Z .
10
+ $$
11
+
12
+ All step functions share the signature `step(psi, s) -> density matrix`, so any of them can be
13
+ handed to `dbac.gci.GCI` to run several steps. They differ only in how $e^{is\rho'}$ is applied.
14
+
15
+ See [One DBAC step](../guide/dbac-step.md) for a walkthrough with plots.
16
+
17
+ ```{eval-rst}
18
+ .. currentmodule:: dbac.dbqite
19
+
20
+ .. autosummary::
21
+
22
+ QITE_dme_select_M
23
+ ideal_DME
24
+ initial_psi
25
+ QITE_GCI_dme
26
+ DME
27
+ H
28
+ target_energy
29
+ ```
30
+
31
+ ## Step functions
32
+
33
+ ```{eval-rst}
34
+ .. autofunction:: QITE_dme_select_M
35
+
36
+ .. autofunction:: ideal_DME
37
+
38
+ .. autofunction:: initial_psi
39
+
40
+ .. autofunction:: QITE_GCI_dme
41
+ ```
42
+
43
+ ## DME inside the step
44
+
45
+ ```{eval-rst}
46
+ .. autofunction:: DME
47
+ ```
48
+
49
+ ## The Hamiltonian
50
+
51
+ ```{eval-rst}
52
+ .. autodata:: H
53
+ :no-value:
54
+
55
+ .. autodata:: eigs
56
+ :no-value:
57
+
58
+ .. autodata:: target_energy
59
+ :no-value:
60
+
61
+ .. autodata:: H_sh
62
+ :no-value:
63
+ ```
@@ -0,0 +1,50 @@
1
+ # dbac.dme
2
+
3
+ Density matrix exponentiation (DME): applying $e^{it\rho}$ to a data state $\sigma$ using
4
+ copies of $\rho$ instead of knowledge of $\rho$. This is the subroutine inside every DBAC step.
5
+
6
+ The module offers the same channel four ways, so the implementations can be checked against
7
+ each other. All take `(data, instruction, t, M)`: the data and instruction density matrices, the
8
+ total duration, and the number of Trotter steps (instruction copies used).
9
+
10
+ See [Density matrix exponentiation](../guide/dme.md) for how DME works and which
11
+ implementation to pick.
12
+
13
+ :::{note}
14
+ DBAC steps do not call this module: they use `dbac.dbqite.DME`, which takes the arguments in
15
+ the order `(instruction, data, t, M)`.
16
+ :::
17
+
18
+ ```{eval-rst}
19
+ .. currentmodule:: dbac.dme
20
+
21
+ .. autosummary::
22
+
23
+ dme_channel
24
+ dme_channel_equivalent
25
+ dme_qibo
26
+ dme_expm
27
+ ptrace
28
+ ```
29
+
30
+ ## Approximate DME (Trotterized)
31
+
32
+ ```{eval-rst}
33
+ .. autofunction:: dme_channel
34
+
35
+ .. autofunction:: dme_channel_equivalent
36
+
37
+ .. autofunction:: dme_qibo
38
+ ```
39
+
40
+ ## Exact reference
41
+
42
+ ```{eval-rst}
43
+ .. autofunction:: dme_expm
44
+ ```
45
+
46
+ ## Helpers
47
+
48
+ ```{eval-rst}
49
+ .. autofunction:: ptrace
50
+ ```
@@ -0,0 +1,32 @@
1
+ # dbac.gci
2
+
3
+ Runs the DBAC recursion. `GCI` (group commutator iteration) applies a step function from
4
+ `dbac.dbqite` again and again, each time to the previous output, and records the energy,
5
+ fidelity and state after every step.
6
+
7
+ See [Running the recursion](../guide/recursion.md) for both modes of `GCI` and a guide to its
8
+ output.
9
+
10
+ ```{eval-rst}
11
+ .. currentmodule:: dbac.gci
12
+
13
+ .. autosummary::
14
+
15
+ GCI
16
+ GCI.execute_gci
17
+ max_excitation
18
+ ```
19
+
20
+ ## Running the recursion
21
+
22
+ ```{eval-rst}
23
+ .. autoclass:: GCI
24
+ :members: execute_gci, compute_moments, fidelity_with_0
25
+ :member-order: bysource
26
+ ```
27
+
28
+ ## Summarizing a cooling curve
29
+
30
+ ```{eval-rst}
31
+ .. autofunction:: max_excitation
32
+ ```
@@ -0,0 +1,32 @@
1
+ # dbac.hbac
2
+
3
+ Heat-bath algorithmic cooling (HBAC), the standard entropy-based protocol, implemented
4
+ minimally so DBAC can be compared with it. Each round resets the last qubit to a thermal state
5
+ and sorts the populations of the joint state; `hbac` runs several rounds and returns the first
6
+ qubit.
7
+
8
+ See [HBAC baseline](../guide/hbac.md) for how HBAC differs from DBAC and a side-by-side comparison.
9
+
10
+ ```{eval-rst}
11
+ .. currentmodule:: dbac.hbac
12
+
13
+ .. autosummary::
14
+
15
+ hbac
16
+ refresh_reset_qubit
17
+ compress_density_matrix
18
+ ```
19
+
20
+ ## Running HBAC
21
+
22
+ ```{eval-rst}
23
+ .. autofunction:: hbac
24
+ ```
25
+
26
+ ## The two parts of a round
27
+
28
+ ```{eval-rst}
29
+ .. autofunction:: refresh_reset_qubit
30
+
31
+ .. autofunction:: compress_density_matrix
32
+ ```
@@ -0,0 +1,38 @@
1
+ # API reference
2
+
3
+ The package has two halves: the physics in `dbac`, and the plotting in `dbac.plotting`. The
4
+ physics modules never import matplotlib.
5
+
6
+ If you are new to the package, the [guide](../guide/conventions.md) explains each module with
7
+ runnable examples. These pages list every public function and its arguments.
8
+
9
+ | module | what it is for | guide |
10
+ |---|---|---|
11
+ | [`dbac.utils`](utils.md) | building initial states, fidelity, noise | [States and conventions](../guide/conventions.md) |
12
+ | [`dbac.dme`](dme.md) | density matrix exponentiation, four implementations | [Density matrix exponentiation](../guide/dme.md) |
13
+ | [`dbac.dbqite`](dbqite.md) | one DBAC step, the Hamiltonian | [One DBAC step](../guide/dbac-step.md) |
14
+ | [`dbac.gci`](gci.md) | running several steps, reading the results | [Running the recursion](../guide/recursion.md) |
15
+ | [`dbac.hbac`](hbac.md) | heat-bath algorithmic cooling, for comparison | [HBAC baseline](../guide/hbac.md) |
16
+ | [`dbac.plotting`](plotting.md) | every figure: cooling curves, circuits, Bloch sphere, PTMs | [Plotting](../guide/plotting.md) |
17
+
18
+ ## How the pieces fit together
19
+
20
+ A typical calculation touches the modules in this order:
21
+
22
+ 1. `dbac.utils.rx_sweep` builds the initial states;
23
+ 2. `dbac.dbqite.QITE_dme_select_M` makes a DBAC step function, which uses
24
+ [DME](dme.md) internally;
25
+ 3. `dbac.gci.GCI` runs that step $k$ times and records energy and fidelity;
26
+ 4. `dbac.plotting` draws the result.
27
+
28
+ ```python
29
+ import numpy as np
30
+ from dbac.utils import rx_sweep
31
+ from dbac.dbqite import QITE_dme_select_M
32
+ from dbac.gci import GCI
33
+
34
+ psi = rx_sweep([0.5])[0] # 1. initial state
35
+ step = QITE_dme_select_M(1) # 2. step with M = 1
36
+ results = GCI(step, psi, None, [np.pi / 4] * 2).execute_gci() # 3. k = 2 steps
37
+ print(results[-1]) # fidelity after 0, 1, 2 steps
38
+ ```