Skip to content

docs: list the API users call, and document the configuration fields - #53

Merged
Sophia Wen (hfwen0502) merged 2 commits into
mainfrom
docs-api-surface
Oct 9, 2026
Merged

Sophia Wen (hfwen0502) merged 2 commits into
mainfrom
docs-api-surface

Conversation

@hfwen0502

Copy link
Copy Markdown
Member

The API reference listed whatever autodoc found. This narrows it to what a user calls and documents the configuration fields, which had no documentation at all.

sbd: grouped into diagonalization (tpb_diag, gdb_diag), configuration (TPB_SBD, GDB_SBD), inputs (LoadFCIDump, LoadAlphaDets, sort_bitarray, from_strings, sort_bitarray_array), backends and devices, and MPI. Internal and transitional helpers are left out.

Configuration fields: three tables, for the fields TPB_SBD and GDB_SBD share, TPB's own, and GDB's own, each with what the field does and the traps that are easy to miss. Two entries reflect checks made while addressing the #46 review:

  • bit_length: at most 63, since 64 is undefined behavior in SBD's multi-rank redistribution. For GDB's heatbath expansion (carryover_type 2 or 3) it must also be even once a determinant spans more than one word, or the expansion crashes or returns a wrong energy. The examples/gdb drivers require an even value of at most 62.
  • t_comm_size: the rank count must be a multiple of t_comm_size * b_comm_size, and on the Thrust backend equal to it, because GDB on Thrust has no helper dimension.

sbd.sbd_solver and sbd.device_config: a short framing paragraph each. The solver page says how it plugs into qiskit-addon-sqd, and that it uses TPB only. The device page lists only DeviceConfig's public constructors.

This needed #46, since from_strings and sort_bitarray_array arrive with it. sphinx-build -W -T --keep-going, the command tox -e docs runs, succeeds with no warnings, and the rendered page resolves every documented function.

🤖 Generated with Claude Code

Sophia Wen (hfwen0502) and others added 2 commits October 9, 2026 15:39
The API pages used automodule :members:, which documents every public-named object:
40 entries, including internals (DeviceConfig.apply, create_sbd_solver), a
deprecated alias (gpu_nvidia_omp), single-item forms of bulk functions (makestring,
from_string), and debugging aids. Each page now names its objects explicitly, under
task headings: 26 entries. Nothing is removed from __all__ or the code, so every
name still works; this only chooses what the reference shows.

TPB_SBD and GDB_SBD are factory functions, so none of their fields appeared anywhere
in the docs. They are now tabulated: fields shared by both, then each struct's own,
taken from the bindings.cpp docstrings and filled in where those were terse. There is
no defaults column, because upstream's struct defaults and the ones solve_sci applies
differ.

DeviceConfig needs :no-inherited-members: alongside its explicit member list:
conf.py's autodoc_default_options set inherited-members, which otherwise brought
apply and gpu_nvidia_omp back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@garrison Jim Garrison (garrison) added the documentation Improvements or additions to documentation label Oct 9, 2026
@hfwen0502
Sophia Wen (hfwen0502) merged commit 815f56e into main Oct 9, 2026
16 checks passed
@hfwen0502
Sophia Wen (hfwen0502) deleted the docs-api-surface branch October 9, 2026 20:05
Jim Garrison (garrison) added a commit that referenced this pull request Oct 9, 2026
#53 curated the autodoc list and added field tables, which changes where
this branch's documentation belongs.

The packing convention moves from `from_string` to `from_strings`. #53
documents the bulk form and deliberately leaves the singular one out, so
the convention was written on a function the rendered docs never show --
and `from_strings`, the form users are steered to, had no packing
documentation of its own. `from_string` and `makestring` now point at it
instead of restating it. The examples are shown as the `uint64` ndarray
`from_strings` actually returns rather than as nested lists.

`dump_matrix_form_wf` now appears in #53's `TPB_SBD` field table as well
as the README's, so the README row defers to the format section instead of
describing the field a second time.

Also corrects a claim this branch made about `sbd_solver.py`: since #49 the
wavefunction write is skipped when SBD selects the carryover itself
(`carryover_type` 1 against an addon that accepts it), because the next
subspace then comes back in `carryover_adet`/`carryover_bdet` and the
amplitudes never reach Python. Saying it "uses" the dump without that
qualification implied the write always happens.

`tox -e docs` passes with no warnings, and the packing convention renders
on the `from_strings` entry.

Assisted-by: Claude Opus 5
Jim Garrison (garrison) added a commit that referenced this pull request Oct 9, 2026
…der (#55)

* Document how to retrieve TPB amplitudes, and the bitstring packing order

Two things a user has to discover by reading upstream C++ or experimenting.

TPB has two wavefunction output paths that write different formats, and
nothing said so. `savename` -- the one named in `tpb_diag`'s signature --
goes to `SaveWavefunction`, which writes one file per b_comm position
holding only that rank's block, behind a three-`size_t` header and the
block's determinant words. `sbd_data.dump_matrix_form_wf` goes to
`SaveMatrixFormWF`, which gathers the full adet x bdet subspace onto one
rank and writes a bare row-major float64 array with no header at all, or,
for a `.dat`/`.txt` path, a text table labelling each amplitude with its
own alpha and beta bitstring.

The second is what almost every caller wants, and is what this package's
own SQD integration already uses (`sbd_solver.py` sets it and reads the
result with a bare `np.fromfile`). It appeared only as a one-line pybind
docstring and a CLI flag in `run_sbd_diag.py`, absent from the README's
TPB section and from the `tpb_diag` docstring, both of which mention
`savename` alone -- so following the signature led to parsing the wrong
layout. Document both, side by side, and note that the text form is
written with default stream formatting and so carries ~6 significant
digits rather than full float64.

`from_string` and `makestring` packed words with no stated convention.
Bitstrings are packed from the right: the trailing `bit_length` characters
become word 0, so the leading characters of a multi-word string land in
the last word, not the first. Easy to get backwards, and a wrong guess
yields a valid-looking but wrong subspace rather than an error.

GDB needed no changes here: #46 documented its amplitude retrieval and
file layout in examples/gdb/README.md.

Assisted-by: Claude Opus 5

* Fit the amplitude and packing docs to the API surface #53 defined

#53 curated the autodoc list and added field tables, which changes where
this branch's documentation belongs.

The packing convention moves from `from_string` to `from_strings`. #53
documents the bulk form and deliberately leaves the singular one out, so
the convention was written on a function the rendered docs never show --
and `from_strings`, the form users are steered to, had no packing
documentation of its own. `from_string` and `makestring` now point at it
instead of restating it. The examples are shown as the `uint64` ndarray
`from_strings` actually returns rather than as nested lists.

`dump_matrix_form_wf` now appears in #53's `TPB_SBD` field table as well
as the README's, so the README row defers to the format section instead of
describing the field a second time.

Also corrects a claim this branch made about `sbd_solver.py`: since #49 the
wavefunction write is skipped when SBD selects the carryover itself
(`carryover_type` 1 against an addon that accepts it), because the next
subspace then comes back in `carryover_adet`/`carryover_bdet` and the
amplitudes never reach Python. Saying it "uses" the dump without that
qualification implied the write always happens.

`tox -e docs` passes with no warnings, and the packing convention renders
on the `from_strings` entry.

Assisted-by: Claude Opus 5
Jim Garrison (garrison) added a commit that referenced this pull request Oct 10, 2026
…der (#55) (#57)

* Document how to retrieve TPB amplitudes, and the bitstring packing order

Two things a user has to discover by reading upstream C++ or experimenting.

TPB has two wavefunction output paths that write different formats, and
nothing said so. `savename` -- the one named in `tpb_diag`'s signature --
goes to `SaveWavefunction`, which writes one file per b_comm position
holding only that rank's block, behind a three-`size_t` header and the
block's determinant words. `sbd_data.dump_matrix_form_wf` goes to
`SaveMatrixFormWF`, which gathers the full adet x bdet subspace onto one
rank and writes a bare row-major float64 array with no header at all, or,
for a `.dat`/`.txt` path, a text table labelling each amplitude with its
own alpha and beta bitstring.

The second is what almost every caller wants, and is what this package's
own SQD integration already uses (`sbd_solver.py` sets it and reads the
result with a bare `np.fromfile`). It appeared only as a one-line pybind
docstring and a CLI flag in `run_sbd_diag.py`, absent from the README's
TPB section and from the `tpb_diag` docstring, both of which mention
`savename` alone -- so following the signature led to parsing the wrong
layout. Document both, side by side, and note that the text form is
written with default stream formatting and so carries ~6 significant
digits rather than full float64.

`from_string` and `makestring` packed words with no stated convention.
Bitstrings are packed from the right: the trailing `bit_length` characters
become word 0, so the leading characters of a multi-word string land in
the last word, not the first. Easy to get backwards, and a wrong guess
yields a valid-looking but wrong subspace rather than an error.

GDB needed no changes here: #46 documented its amplitude retrieval and
file layout in examples/gdb/README.md.

Assisted-by: Claude Opus 5

* Fit the amplitude and packing docs to the API surface #53 defined

#53 curated the autodoc list and added field tables, which changes where
this branch's documentation belongs.

The packing convention moves from `from_string` to `from_strings`. #53
documents the bulk form and deliberately leaves the singular one out, so
the convention was written on a function the rendered docs never show --
and `from_strings`, the form users are steered to, had no packing
documentation of its own. `from_string` and `makestring` now point at it
instead of restating it. The examples are shown as the `uint64` ndarray
`from_strings` actually returns rather than as nested lists.

`dump_matrix_form_wf` now appears in #53's `TPB_SBD` field table as well
as the README's, so the README row defers to the format section instead of
describing the field a second time.

Also corrects a claim this branch made about `sbd_solver.py`: since #49 the
wavefunction write is skipped when SBD selects the carryover itself
(`carryover_type` 1 against an addon that accepts it), because the next
subspace then comes back in `carryover_adet`/`carryover_bdet` and the
amplitudes never reach Python. Saying it "uses" the dump without that
qualification implied the write always happens.

`tox -e docs` passes with no warnings, and the packing convention renders
on the `from_strings` entry.

Assisted-by: Claude Opus 5
(cherry picked from commit 90afb07)

Co-authored-by: Jim Garrison <garrison@ibm.com>
@garrison

Copy link
Copy Markdown
Member
  • bit_length: at most 63, since 64 is undefined behavior in SBD's multi-rank redistribution. For GDB's heatbath expansion (carryover_type 2 or 3) it must also be even once a determinant spans more than one word, or the expansion crashes or returns a wrong energy. The examples/gdb drivers require an even value of at most 62.

Ref r-ccs-cms/sbd#104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants