From a7a70abbc19188f78b670b9f286583b18bbe7cef Mon Sep 17 00:00:00 2001 From: Kaelyn Ferris <43348706+kaelynj@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:13:26 -0500 Subject: [PATCH 1/5] Incorporate SQD feedback --- docs/guides/qiskit-addons-sqd-get-started.ipynb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/guides/qiskit-addons-sqd-get-started.ipynb b/docs/guides/qiskit-addons-sqd-get-started.ipynb index e257e28a9fa..72585438ebb 100644 --- a/docs/guides/qiskit-addons-sqd-get-started.ipynb +++ b/docs/guides/qiskit-addons-sqd-get-started.ipynb @@ -1826,12 +1826,14 @@ "\n", "1. Use the `recover_configurations()` method to obtain a refined bitstring matrix and probability array based on the average orbital occupancy.\n", "1. Use the `postselect_and_subsample()` to collect batches of subsamples to diagonalize over.\n", - "1. Then use the batches of subsamples as arguments to the `solve_fermion()` method to obtain an approximation of the ground state." + "1. Then use the batches of subsamples as arguments to the `solve_fermion()` method to obtain an approximation of the ground state.\n", + "\n", + "One important note here is how to address the very first iteration of the configuration recovery loop. Here the average orbital occupancy is not yet available and so only the `postselect_and_subsample()` method is called. This removes any non-physical samples (samples with incorrect Hamming weight) before running the eigenstate solver, `solve_fermion()`. Afterwards, the average orbital occupation is calculated across all batches and used as input to the `recover_configurations()` method which flips individual bits probabilistically based on this average. (See Section **II-A** of the supplementary information in the [SQD paper](https://arxiv.org/abs/2405.05068) for more information.)" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "a6d492b5-d86b-43cd-9171-4add0903fe84", "metadata": {}, "outputs": [ @@ -1928,7 +1930,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "dcd4ed70-89a0-44f4-b4b0-6270bbeb0c13", "metadata": {}, "outputs": [ @@ -1949,6 +1951,8 @@ "# Data for energies plot\n", "n2_exact = -109.10288938\n", "x1 = range(ITERATIONS)\n", + "# Here we plot the smallest energy obtained across all batches for each iteration\n", + "# of the configuration recovery loop.\n", "e_diff = [abs(np.min(energies) - n2_exact) for energies in energy_hist]\n", "yt1 = [1.0, 1e-1, 1e-2, 1e-3, 1e-4]\n", "\n", From 648278ca9844ee8a1465a401acaabf4c259f403c Mon Sep 17 00:00:00 2001 From: Kaelyn Ferris <43348706+kaelynj@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:41:07 -0500 Subject: [PATCH 2/5] Include more information about configuration recovery --- docs/guides/qiskit-addons-sqd-get-started.ipynb | 2 +- docs/guides/qiskit-addons-sqd.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/qiskit-addons-sqd-get-started.ipynb b/docs/guides/qiskit-addons-sqd-get-started.ipynb index 72585438ebb..03886826594 100644 --- a/docs/guides/qiskit-addons-sqd-get-started.ipynb +++ b/docs/guides/qiskit-addons-sqd-get-started.ipynb @@ -1828,7 +1828,7 @@ "1. Use the `postselect_and_subsample()` to collect batches of subsamples to diagonalize over.\n", "1. Then use the batches of subsamples as arguments to the `solve_fermion()` method to obtain an approximation of the ground state.\n", "\n", - "One important note here is how to address the very first iteration of the configuration recovery loop. Here the average orbital occupancy is not yet available and so only the `postselect_and_subsample()` method is called. This removes any non-physical samples (samples with incorrect Hamming weight) before running the eigenstate solver, `solve_fermion()`. Afterwards, the average orbital occupation is calculated across all batches and used as input to the `recover_configurations()` method which flips individual bits probabilistically based on this average. (See Section **II-A** of the supplementary information in the [SQD paper](https://arxiv.org/abs/2405.05068) for more information.)" + "One important note here is how to address the very first iteration of the configuration recovery loop. Here the average orbital occupancy is not yet available and so only the `postselect_and_subsample()` method is called. This removes any non-physical samples (samples with incorrect Hamming weight) before running the eigenstate solver, `solve_fermion()`. Afterwards, the average orbital occupation is calculated across all batches and used as input to the `recover_configurations()` method which flips individual bits probabilistically based on this average. The probability of flipping an individual bit is based on the distance between the value of the bit and the average orbital occupancy obtained. (See Section **II-A** of the supplementary information in the [SQD paper](https://arxiv.org/abs/2405.05068) for more information.)" ] }, { diff --git a/docs/guides/qiskit-addons-sqd.mdx b/docs/guides/qiskit-addons-sqd.mdx index 92c72be5dea..1642e967346 100644 --- a/docs/guides/qiskit-addons-sqd.mdx +++ b/docs/guides/qiskit-addons-sqd.mdx @@ -60,7 +60,7 @@ $$ \hat{H}_{S^{(k)}} = \hat{P}_{\mathcal{S}^{(k)}}\hat{H}\hat{P}_{\mathcal{S}^{( where $\hat{H}_{\mathcal{S}^{(k)}}$ is the Hamiltonian of a given subspace. -The bulk of the SQD workflow lies here wherein each of these subspace Hamiltonians is diagonalized. The ground states obtained from each of these subspaces, $|\psi^{(k)}\rangle$, are used to obtain an estimate of a reference vector of occupancies $\mathbf{n}^{(K)}$ averaged over each of the $K$ subspaces and sent back to the configuration recovery step. A new set of subspaces are then obtained and diagonalized, and this procedure iterates in a loop until a user specified criterion is met. +The bulk of the SQD workflow lies here wherein each of these subspace Hamiltonians is diagonalized. The ground states obtained from each of these subspaces, $|\psi^{(k)}\rangle$, are used to obtain an estimate of a reference vector of occupancies $\mathbf{n}^{(K)}$ averaged over each of the $K$ subspaces. A new set of configurations $\mathcal{X}_R$ is then generated by probabilistically flipping individual bits based on this average occupation and the known total number of particles (hamming weight) in the system. This configuration recovery process is then repeated by preparing a new set of subspaces to diagonalize, obtaining new eigenstates and averaged orbital occupancy, then generating a new set of configurations. This loop is iterated until a user specified criterion is met, and the overall process is analogous to filtering a noisy signal to improve its fidelity. ## Next steps From 3b9d0268081397d157b49d1c41a6ec13e60bd00c Mon Sep 17 00:00:00 2001 From: Kaelyn Ferris <43348706+kaelynj@users.noreply.github.com> Date: Mon, 13 Jan 2025 09:38:14 -0500 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: abbycross --- docs/guides/qiskit-addons-sqd-get-started.ipynb | 2 +- docs/guides/qiskit-addons-sqd.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/qiskit-addons-sqd-get-started.ipynb b/docs/guides/qiskit-addons-sqd-get-started.ipynb index 03886826594..b9011d040a8 100644 --- a/docs/guides/qiskit-addons-sqd-get-started.ipynb +++ b/docs/guides/qiskit-addons-sqd-get-started.ipynb @@ -1828,7 +1828,7 @@ "1. Use the `postselect_and_subsample()` to collect batches of subsamples to diagonalize over.\n", "1. Then use the batches of subsamples as arguments to the `solve_fermion()` method to obtain an approximation of the ground state.\n", "\n", - "One important note here is how to address the very first iteration of the configuration recovery loop. Here the average orbital occupancy is not yet available and so only the `postselect_and_subsample()` method is called. This removes any non-physical samples (samples with incorrect Hamming weight) before running the eigenstate solver, `solve_fermion()`. Afterwards, the average orbital occupation is calculated across all batches and used as input to the `recover_configurations()` method which flips individual bits probabilistically based on this average. The probability of flipping an individual bit is based on the distance between the value of the bit and the average orbital occupancy obtained. (See Section **II-A** of the supplementary information in the [SQD paper](https://arxiv.org/abs/2405.05068) for more information.)" + "It is important to note how to address the first iteration of the configuration recovery loop. Since the average orbital occupancy is not yet available, only the `postselect_and_subsample()` method is called. This removes any non-physical samples (samples with incorrect Hamming weight) before running the eigenstate solver, `solve_fermion()`. Afterward, the average orbital occupation is calculated across all batches and used as input to the `recover_configurations()` method, which flips individual bits probabilistically based on this average. The probability of flipping an individual bit is based on the distance between the value of the bit and the average orbital occupancy obtained. (See Section **II-A** of the supplementary information in the [SQD paper](https://arxiv.org/abs/2405.05068) for more information.)" ] }, { diff --git a/docs/guides/qiskit-addons-sqd.mdx b/docs/guides/qiskit-addons-sqd.mdx index 1642e967346..a46ca3f1694 100644 --- a/docs/guides/qiskit-addons-sqd.mdx +++ b/docs/guides/qiskit-addons-sqd.mdx @@ -60,7 +60,7 @@ $$ \hat{H}_{S^{(k)}} = \hat{P}_{\mathcal{S}^{(k)}}\hat{H}\hat{P}_{\mathcal{S}^{( where $\hat{H}_{\mathcal{S}^{(k)}}$ is the Hamiltonian of a given subspace. -The bulk of the SQD workflow lies here wherein each of these subspace Hamiltonians is diagonalized. The ground states obtained from each of these subspaces, $|\psi^{(k)}\rangle$, are used to obtain an estimate of a reference vector of occupancies $\mathbf{n}^{(K)}$ averaged over each of the $K$ subspaces. A new set of configurations $\mathcal{X}_R$ is then generated by probabilistically flipping individual bits based on this average occupation and the known total number of particles (hamming weight) in the system. This configuration recovery process is then repeated by preparing a new set of subspaces to diagonalize, obtaining new eigenstates and averaged orbital occupancy, then generating a new set of configurations. This loop is iterated until a user specified criterion is met, and the overall process is analogous to filtering a noisy signal to improve its fidelity. +The bulk of the SQD workflow lies here wherein each of these subspace Hamiltonians is diagonalized. The ground states obtained from each of these subspaces, $|\psi^{(k)}\rangle$, are used to obtain an estimate of a reference vector of occupancies $\mathbf{n}^{(K)}$ averaged over each of the $K$ subspaces. A new set of configurations $\mathcal{X}_R$ is then generated by probabilistically flipping individual bits based on this average occupation and the known total number of particles (Hamming weight) in the system. This configuration recovery process is then repeated by preparing a new set of subspaces to diagonalize, obtaining new eigenstates and averaged orbital occupancy, and generating a new set of configurations. This loop is iterated until a user-specified criterion is met, and the overall process is analogous to filtering a noisy signal to improve its fidelity. ## Next steps From f74b1a5d784e0c34cab24ed54c75ef9981d2098e Mon Sep 17 00:00:00 2001 From: Kaelyn Ferris <43348706+kaelynj@users.noreply.github.com> Date: Thu, 16 Jan 2025 17:11:02 -0500 Subject: [PATCH 4/5] Address review comments --- docs/guides/qiskit-addons-sqd-get-started.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guides/qiskit-addons-sqd-get-started.ipynb b/docs/guides/qiskit-addons-sqd-get-started.ipynb index 24c2305bef6..9b3e3f14209 100644 --- a/docs/guides/qiskit-addons-sqd-get-started.ipynb +++ b/docs/guides/qiskit-addons-sqd-get-started.ipynb @@ -1824,11 +1824,11 @@ "source": [ "Now, run the configuration recovery loop. Each loop consists of three steps:\n", "\n", - "1. Use the `recover_configurations()` method to obtain a refined bitstring matrix and probability array based on the average orbital occupancy.\n", + "1. Use the `recover_configurations()` function to obtain a refined bitstring matrix and probability array based on the average orbital occupancy.\n", "1. Use the `postselect_and_subsample()` to collect batches of subsamples to diagonalize over.\n", - "1. Then use the batches of subsamples as arguments to the `solve_fermion()` method to obtain an approximation of the ground state.\n", + "1. Then use the batches of subsamples as arguments to the `solve_fermion()` function to obtain an approximation of the ground state.\n", "\n", - "It is important to note how to address the first iteration of the configuration recovery loop. Since the average orbital occupancy is not yet available, only the `postselect_and_subsample()` method is called. This removes any non-physical samples (samples with incorrect Hamming weight) before running the eigenstate solver, `solve_fermion()`. Afterward, the average orbital occupation is calculated across all batches and used as input to the `recover_configurations()` method, which flips individual bits probabilistically based on this average. The probability of flipping an individual bit is based on the distance between the value of the bit and the average orbital occupancy obtained. (See Section **II-A** of the supplementary information in the [SQD paper](https://arxiv.org/abs/2405.05068) for more information.)" + "It is important to note how to address the first iteration of the configuration recovery loop. Since the average orbital occupancy is not yet available, only the `postselect_and_subsample()` function is called. This removes any non-physical samples (samples with incorrect Hamming weight) before running the eigenstate solver, `solve_fermion()`. Afterward, the average orbital occupation is calculated across all batches and used as input to the `recover_configurations()` method, which flips individual bits probabilistically based on this average. See Section **II-A** of the supplementary information in the [SQD paper](https://arxiv.org/abs/2405.05068) for more information." ] }, { From 66664b240c9fc39591932812544cd686c24a9f04 Mon Sep 17 00:00:00 2001 From: Kaelyn Ferris <43348706+kaelynj@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:01:20 -0500 Subject: [PATCH 5/5] Slight word change --- docs/guides/qiskit-addons-sqd.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/qiskit-addons-sqd.mdx b/docs/guides/qiskit-addons-sqd.mdx index b622e26d974..9d6fdf5314f 100644 --- a/docs/guides/qiskit-addons-sqd.mdx +++ b/docs/guides/qiskit-addons-sqd.mdx @@ -60,7 +60,7 @@ $$ \hat{H}_{S^{(k)}} = \hat{P}_{\mathcal{S}^{(k)}}\hat{H}\hat{P}_{\mathcal{S}^{( where $\hat{H}_{\mathcal{S}^{(k)}}$ is the Hamiltonian of a given subspace. -The bulk of the SQD workflow lies here wherein each of these subspace Hamiltonians is diagonalized. The ground states obtained from each of these subspaces, $|\psi^{(k)}\rangle$, are used to obtain an estimate of a reference vector of occupancies $\mathbf{n}^{(K)}$ averaged over each of the $K$ subspaces. A new set of configurations $\mathcal{X}_R$ is then generated by probabilistically flipping individual bits based on this average occupation and the known total number of particles (Hamming weight) in the system. This configuration recovery process is then repeated by preparing a new set of subspaces to diagonalize, obtaining new eigenstates and averaged orbital occupancy, and generating a new set of configurations. This loop is iterated until a user-specified criterion is met, and the overall process is analogous to filtering a noisy signal to improve its fidelity. +The bulk of the SQD workflow lies here wherein each of these subspace Hamiltonians is diagonalized. The ground states obtained from each of these subspaces, $|\psi^{(k)}\rangle$, are used to produce an estimate of a reference vector of occupancies $\mathbf{n}^{(K)}$ averaged over each of the $K$ subspaces. A new set of configurations $\mathcal{X}_R$ is then generated by probabilistically flipping individual bits based on this average occupation and the known total number of particles (Hamming weight) in the system. This configuration recovery process is then repeated by preparing a new set of subspaces to diagonalize, obtaining new eigenstates and averaged orbital occupancy, and generating a new set of configurations. This loop is iterated until a user-specified criterion is met, and the overall process is analogous to filtering a noisy signal to improve its fidelity. ## Next steps