Skip to content

Commit 3e3a0cd

Browse files
committed
Merge branch 'main' into bd-restructure-execution-mode-pages
2 parents fe45e5e + aa46e9f commit 3e3a0cd

27 files changed

+1042
-278
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "qiskit-addon-sqd",
3+
"version": "0.8.1"
4+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"title": "Sample-based quantum diagonalization (SQD)",
3+
"children": [
4+
{
5+
"title": "API index",
6+
"url": "/api/qiskit-addon-sqd/0.8"
7+
},
8+
{
9+
"title": "qiskit_addon_sqd.configuration_recovery",
10+
"url": "/api/qiskit-addon-sqd/0.8/configuration-recovery"
11+
},
12+
{
13+
"title": "qiskit_addon_sqd.counts",
14+
"url": "/api/qiskit-addon-sqd/0.8/counts"
15+
},
16+
{
17+
"title": "qiskit_addon_sqd.fermion",
18+
"url": "/api/qiskit-addon-sqd/0.8/fermion"
19+
},
20+
{
21+
"title": "qiskit_addon_sqd.qubit",
22+
"url": "/api/qiskit-addon-sqd/0.8/qubit"
23+
},
24+
{
25+
"title": "qiskit_addon_sqd.subsampling",
26+
"url": "/api/qiskit-addon-sqd/0.8/subsampling"
27+
},
28+
{
29+
"title": "Release notes",
30+
"url": "/api/qiskit-addon-sqd/release-notes"
31+
}
32+
],
33+
"collapsed": true
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: configuration_recovery (v0.8)
3+
description: API reference for qiskit_addon_sqd.configuration_recovery in qiskit-addon-sqd v0.8
4+
in_page_toc_min_heading_level: 2
5+
python_api_type: module
6+
python_api_name: qiskit_addon_sqd.configuration_recovery
7+
---
8+
9+
<span id="module-qiskit_addon_sqd.configuration_recovery" />
10+
11+
<span id="configuration-recovery-qiskit-addon-sqd-configuration-recovery" />
12+
13+
# Configuration recovery
14+
15+
`qiskit_addon_sqd.configuration_recovery`
16+
17+
Functions for performing self-consistent configuration recovery.
18+
19+
### post\_select\_by\_hamming\_weight
20+
21+
<Function id="qiskit_addon_sqd.configuration_recovery.post_select_by_hamming_weight" github="https://github.com/Qiskit/qiskit-addon-sqd/tree/stable/0.8/qiskit_addon_sqd/configuration_recovery.py#L24-L48" signature="post_select_by_hamming_weight(bitstring_matrix, *, hamming_right, hamming_left)">
22+
Post-select bitstrings based on the hamming weight of each half.
23+
24+
**Parameters**
25+
26+
* **bitstring\_matrix** ([*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)")) – A 2D array of `bool` representations of bit values such that each row represents a single bitstring
27+
* **hamming\_right** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The target hamming weight of the right half of bitstrings
28+
* **hamming\_left** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The target hamming weight of the left half of bitstrings
29+
30+
**Returns**
31+
32+
A mask signifying which samples (rows) were selected from the input matrix.
33+
34+
**Return type**
35+
36+
[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)")
37+
</Function>
38+
39+
### recover\_configurations
40+
41+
<Function id="qiskit_addon_sqd.configuration_recovery.recover_configurations" github="https://github.com/Qiskit/qiskit-addon-sqd/tree/stable/0.8/qiskit_addon_sqd/configuration_recovery.py#L51-L117" signature="recover_configurations(bitstring_matrix, probabilities, avg_occupancies, num_elec_a, num_elec_b, rand_seed=None)">
42+
Refine bitstrings based on average orbital occupancy and a target hamming weight.
43+
44+
This function refines each bit in isolation in an attempt to transform the Hilbert space represented by the input `bitstring_matrix` into a space closer to that which supports the ground state.
45+
46+
<Admonition title="Note" type="note">
47+
This function makes the assumption that bit `i` represents the spin-down orbital corresponding to the spin-up orbital in bit `i + N` where `N` is the number of spatial orbitals and `i < N`.
48+
</Admonition>
49+
50+
<Admonition title="Note" type="note">
51+
The output configurations may not necessarily have correct hamming weight, as each bit is flipped in isolation from the other bits in the bitstring.
52+
</Admonition>
53+
54+
**Parameters**
55+
56+
* **bitstring\_matrix** ([*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)")) – A 2D array of `bool` representations of bit values such that each row represents a single bitstring
57+
* **probabilities** ([*Sequence*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.13)")*\[*[*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")*]*) – A 1D array specifying a probability distribution over the bitstrings
58+
* **avg\_occupancies** ([*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)")) – A 1D array containing the mean occupancy of each orbital. It is assumed that `avg_occupancies[i]` corresponds to the orbital represented by column `i` in `bitstring_matrix`.
59+
* **num\_elec\_a** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The number of spin-up electrons in the system.
60+
* **num\_elec\_b** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The number of spin-down electrons in the system.
61+
* **rand\_seed** ([*Generator*](https://numpy.org/doc/stable/reference/random/generator.html#numpy.random.Generator "(in NumPy v2.1)") *|*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) – A seed for controlling randomness
62+
63+
**Returns**
64+
65+
A refined bitstring matrix and an updated probability array.
66+
67+
**Return type**
68+
69+
[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")\[[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)"), [*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)")]
70+
71+
**References**
72+
73+
**\[1]: J. Robledo-Moreno, et al., [Chemistry Beyond Exact Solutions on a Quantum-Centric Supercomputer](https://arxiv.org/abs/2405.05068),**
74+
75+
arXiv:2405.05068 \[quant-ph].
76+
</Function>
77+
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: counts (v0.8)
3+
description: API reference for qiskit_addon_sqd.counts in qiskit-addon-sqd v0.8
4+
in_page_toc_min_heading_level: 2
5+
python_api_type: module
6+
python_api_name: qiskit_addon_sqd.counts
7+
---
8+
9+
<span id="module-qiskit_addon_sqd.counts" />
10+
11+
<span id="counts-qiskit-addon-sqd-counts" />
12+
13+
# Counts
14+
15+
`qiskit_addon_sqd.counts`
16+
17+
Functions for transforming counts dictionaries.
18+
19+
### counts\_to\_arrays
20+
21+
<Function id="qiskit_addon_sqd.counts.counts_to_arrays" github="https://github.com/Qiskit/qiskit-addon-sqd/tree/stable/0.8/qiskit_addon_sqd/counts.py#L21-L40" signature="counts_to_arrays(counts)">
22+
Convert a counts dictionary into a bitstring matrix and a probability array.
23+
24+
**Parameters**
25+
26+
**counts** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")*\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")*,* [*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)") *|*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) – The counts dictionary to convert
27+
28+
**Returns**
29+
30+
* A 2D array representing the sampled bitstrings. Each row represents a bitstring, and each element is a `bool` representation of the bit’s value
31+
* A 1D array containing the probability with which each bitstring was sampled
32+
33+
**Return type**
34+
35+
[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")\[[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)"), [*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)")]
36+
</Function>
37+
38+
### generate\_counts\_uniform
39+
40+
<Function id="qiskit_addon_sqd.counts.generate_counts_uniform" github="https://github.com/Qiskit/qiskit-addon-sqd/tree/stable/0.8/qiskit_addon_sqd/counts.py#L43-L77" signature="generate_counts_uniform(num_samples, num_bits, rand_seed=None)">
41+
Generate a bitstring counts dictionary of samples drawn from the uniform distribution.
42+
43+
**Parameters**
44+
45+
* **num\_samples** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The number of samples to draw
46+
* **num\_bits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The number of bits in the bitstrings
47+
* **rand\_seed** ([*Generator*](https://numpy.org/doc/stable/reference/random/generator.html#numpy.random.Generator "(in NumPy v2.1)") *|*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) – A seed for controlling randomness
48+
49+
**Returns**
50+
51+
A dictionary mapping bitstrings of length `num_bits` to the number of times they were sampled.
52+
53+
**Raises**
54+
55+
[**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)")`num_samples` and `num_bits` must be positive integers.
56+
57+
**Return type**
58+
59+
[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")\[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)"), [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")]
60+
</Function>
61+
62+
### generate\_counts\_bipartite\_hamming
63+
64+
<Function id="qiskit_addon_sqd.counts.generate_counts_bipartite_hamming" github="https://github.com/Qiskit/qiskit-addon-sqd/tree/stable/0.8/qiskit_addon_sqd/counts.py#L80-L135" signature="generate_counts_bipartite_hamming(num_samples, num_bits, *, hamming_right, hamming_left, rand_seed=None)">
65+
Generate a bitstring counts dictionary with specified bipartite hamming weight.
66+
67+
**Parameters**
68+
69+
* **num\_samples** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The number of samples to draw
70+
* **num\_bits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The number of bits in the bitstrings
71+
* **hamming\_right** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The hamming weight on the right half of each bitstring
72+
* **hamming\_left** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The hamming weight on the left half of each bitstring
73+
* **rand\_seed** ([*Generator*](https://numpy.org/doc/stable/reference/random/generator.html#numpy.random.Generator "(in NumPy v2.1)") *|*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) – A seed for controlling randomness
74+
75+
**Returns**
76+
77+
A dictionary mapping bitstrings to the number of times they were sampled. Each half of each bitstring in the output dictionary will have a hamming weight as specified by the inputs.
78+
79+
**Raises**
80+
81+
* [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)")`num_bits` and `num_samples` must be positive integers.
82+
* [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)") – Hamming weights must be specified as non-negative integers.
83+
* [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)")`num_bits` must be even.
84+
85+
**Return type**
86+
87+
[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")\[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)"), [int](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")]
88+
</Function>
89+
90+
### normalize\_counts\_dict
91+
92+
<Function id="qiskit_addon_sqd.counts.normalize_counts_dict" github="https://github.com/Qiskit/qiskit-addon-sqd/tree/stable/0.8/qiskit_addon_sqd/counts.py#L138-L145" signature="normalize_counts_dict(counts)">
93+
Convert a counts dictionary into a probability dictionary.
94+
95+
**Parameters**
96+
97+
**counts** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")*\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")*,* [*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)") *|*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*)
98+
99+
**Return type**
100+
101+
[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")\[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)"), [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")]
102+
</Function>
103+

0 commit comments

Comments
 (0)