chemparseplot.parse.surrogate.gpr_optim#

Parsers for the artifacts of gpr_optim campaign records.

A record is <record>/<set>/<cell>/ holding result.json, band/{band.h5,gprn.log,obs-archive/kernel.txt,mlflow.run.json} and, for dimer cells, saddle/mlflow.run.json. The MLflow file store sits at <record>/mlruns. h5py is imported on use.

.. versionadded:: 1.10.0

Module Contents#

Functions#

sha256_file

Hex SHA-256 of a file, streamed.

_value

parse_gprn_log

Group the [tag] key=value ... lines of a gprn/gprd log by tag.

read_mlflow_metrics

Read an MLflow file-store run: name -> {time_ms, value, step}.

_locate_run

_tail

_ledger

_add_dimer_calls

Add the dimer stage to a band ledger so that it sums to the search calls.

parse_gpr_optim_result

Build a :class:CellRecord from a cell’s result.json.

parse_gpr_optim_campaign

Collect every <set>/<cell>/result.json of a record.

_kernel

_search_from_log

project_on_path

Project rows of points onto the polyline path.

_projection

Path coordinate of the foot point of each row of points.

_read_saddle

Flat Cartesian positions (A) of an eOn .con file; None when unreadable.

read_atom_types

Atomic numbers of the first frame of a geometry file.

_find_atom_types

Fill band.numbers from the cell’s own geometry files, in order.

_band_history

BandHistory from a band and its training set (band_h5 records).

_band_from_readcon

Band from gpridge’s readcon output: band.con (or its corpus) and the training set in obs-archive/training.

_band_from_h5

Band from an HDF5 file: older gpridge band.h5 or --full-h5.

_dimer_from_mlflow

parse_gpr_optim_cell

Parse one benchmark cell into a :class:SurrogateSearch.

parse_scaling_csv

Strong-scaling table from per-repetition wall times.

pop_csv_cells

Distinct cell values of a fixed-work CSV, in file order.

_pop_rows

Rows of cell (every row without a cell column), as dicts.

parse_pop_csv

Per-layout means of efficiency columns from a fixed-work CSV.

parse_pop_factors

Fixed-work factors and wall per layout as a :class:PopTable.

parse_components_csv

Median seconds per component from a tidy CSV as a :class:ComponentTable.

parse_breakdown_csv

Median seconds of each component stage per cell and layout.

Data#

API#

chemparseplot.parse.surrogate.gpr_optim._TAG#

‘compile(…)’

chemparseplot.parse.surrogate.gpr_optim._LEDGER#

‘compile(…)’

chemparseplot.parse.surrogate.gpr_optim.MATCH_TOLERANCE#

0.02

chemparseplot.parse.surrogate.gpr_optim.PAIR_WINDOW_MS#

5000

chemparseplot.parse.surrogate.gpr_optim.SPECTRUM_BATCH_CALLS#

20

chemparseplot.parse.surrogate.gpr_optim._MIN_TOKENS#

2

chemparseplot.parse.surrogate.gpr_optim.sha256_file(path: str | pathlib.Path) → str[source]#

Hex SHA-256 of a file, streamed.

chemparseplot.parse.surrogate.gpr_optim._value(text: str)[source]#
chemparseplot.parse.surrogate.gpr_optim.parse_gprn_log(path: str | pathlib.Path) → dict[str, list[dict]][source]#

Group the [tag] key=value ... lines of a gprn/gprd log by tag.

Bare words after the keys (rejected) are kept under flags. Lines of other shapes are skipped.

chemparseplot.parse.surrogate.gpr_optim.read_mlflow_metrics(run_dir: str | pathlib.Path) → dict[str, dict[str, numpy.ndarray]][source]#

Read an MLflow file-store run: name -> {time_ms, value, step}.

chemparseplot.parse.surrogate.gpr_optim._locate_run(cell: pathlib.Path, sub: str, mlruns: pathlib.Path | None) → pathlib.Path | None[source]#
chemparseplot.parse.surrogate.gpr_optim._tail(path: pathlib.Path, nbytes: int = 1 << 17) → str[source]#
chemparseplot.parse.surrogate.gpr_optim._ledger(*logs: pathlib.Path) → dict[str, int][source]#
chemparseplot.parse.surrogate.gpr_optim._add_dimer_calls(rec: chemparseplot.parse.surrogate.model.CellRecord, cell: pathlib.Path) → None[source]#

Add the dimer stage to a band ledger so that it sums to the search calls.

chemparseplot.parse.surrogate.gpr_optim.parse_gpr_optim_result(result_json: str | pathlib.Path) → chemparseplot.parse.surrogate.model.CellRecord[source]#

Build a :class:CellRecord from a cell’s result.json.

chemparseplot.parse.surrogate.gpr_optim.parse_gpr_optim_campaign(record_dir: str | pathlib.Path, name: str | None = None) → chemparseplot.parse.surrogate.model.CampaignTable[source]#

Collect every <set>/<cell>/result.json of a record.

chemparseplot.parse.surrogate.gpr_optim._kernel(path: pathlib.Path) → dict[source]#
chemparseplot.parse.surrogate.gpr_optim._search_from_log(log: dict[str, list[dict]], tol, converged) → chemparseplot.parse.surrogate.model.SearchHistory | None[source]#
chemparseplot.parse.surrogate.gpr_optim.project_on_path(points: numpy.ndarray, path: numpy.ndarray, coord: numpy.ndarray) → tuple[numpy.ndarray, numpy.ndarray][source]#

Project rows of points onto the polyline path.

Returns the path coordinate of the foot point and the Cartesian distance (norm over all coordinates, in the unit of path) to it.

chemparseplot.parse.surrogate.gpr_optim._projection(points: numpy.ndarray, path: numpy.ndarray, coord: numpy.ndarray) → numpy.ndarray[source]#

Path coordinate of the foot point of each row of points.

chemparseplot.parse.surrogate.gpr_optim._read_saddle(path: pathlib.Path) → numpy.ndarray | None[source]#

Flat Cartesian positions (A) of an eOn .con file; None when unreadable.

chemparseplot.parse.surrogate.gpr_optim.read_atom_types(path: str | pathlib.Path, n_atoms: int | None = None) → numpy.ndarray[source]#

Atomic numbers of the first frame of a geometry file.

.con / .convel symbols come from :mod:chemparseplot.parse.eon.con_io and are mapped with ase.data.atomic_numbers. Other suffixes stay on ase.io.read.

Raises ValueError naming the file when it cannot be read or when its atom count differs from n_atoms.

chemparseplot.parse.surrogate.gpr_optim._find_atom_types(cell: pathlib.Path, band: chemparseplot.parse.surrogate.model.BandHistory) → None[source]#

Fill band.numbers from the cell’s own geometry files, in order.

chemparseplot.parse.surrogate.gpr_optim._band_history(band, obs, events) → chemparseplot.parse.surrogate.model.BandHistory[source]#

BandHistory from a band and its training set (band_h5 records).

A band read from band.con holds every atom while the training rows hold the moving atoms only (frozen atoms are not GP coordinates); the band is then cut to its moving atoms so both share one coordinate space.

chemparseplot.parse.surrogate.gpr_optim._band_from_readcon(band_dir: pathlib.Path, events) → chemparseplot.parse.surrogate.model.BandHistory[source]#

Band from gpridge’s readcon output: band.con (or its corpus) and the training set in obs-archive/training.

chemparseplot.parse.surrogate.gpr_optim._band_from_h5(h5_path: pathlib.Path, events) → chemparseplot.parse.surrogate.model.BandHistory[source]#

Band from an HDF5 file: older gpridge band.h5 or --full-h5.

chemparseplot.parse.surrogate.gpr_optim._dimer_from_mlflow(run: pathlib.Path, tol, converged) → chemparseplot.parse.surrogate.model.SingleEndedHistory | None[source]#
chemparseplot.parse.surrogate.gpr_optim.parse_gpr_optim_cell(cell_dir: str | pathlib.Path, *, mlruns: str | pathlib.Path | None = None) → chemparseplot.parse.surrogate.model.SurrogateSearch[source]#

Parse one benchmark cell into a :class:SurrogateSearch.

Parameters

cell_dir <record>/<set>/<cell>. mlruns MLflow store root; defaults to <record>/mlruns.

chemparseplot.parse.surrogate.gpr_optim.parse_scaling_csv(wall_csv: str | pathlib.Path, counts_csv: str | pathlib.Path | None = None, *, stage: str = 'pipeline', cells: list[str] | None = None)[source]#

Strong-scaling table from per-repetition wall times.

wall_csv has columns cell, ranks, threads, repetition, stage, seconds, calls; counts_csv (optional) cell, ranks, threads, repetition, passed. One series per cell, one point per ranks x threads layout (x = cores), time = median over repetitions with min and max kept, calls = median, and a point is capped when any of its repetitions has passed false.

chemparseplot.parse.surrogate.gpr_optim.pop_csv_cells(path: str | pathlib.Path) → list[str] | None[source]#

Distinct cell values of a fixed-work CSV, in file order.

None when the file has no cell column: its rows then belong to whichever cell the caller draws.

chemparseplot.parse.surrogate.gpr_optim._pop_rows(path, cell)[source]#

Rows of cell (every row without a cell column), as dicts.

A named cell the file does not hold is an error that lists the cells it does hold, so a label that differs from the wall table cannot vanish.

chemparseplot.parse.surrogate.gpr_optim.parse_pop_csv(path: str | pathlib.Path, metrics: list[str], *, cell: str | None = None) → tuple[list[str], dict[str, numpy.ndarray]][source]#

Per-layout means of efficiency columns from a fixed-work CSV.

The file needs ranks and threads columns; each name in metrics is a column of fractions. With cell given and a cell column present, only that cell’s rows count, and a cell the file lacks is an error naming the cells it has. Rows of one layout are averaged; layouts sort by cores, then threads.

chemparseplot.parse.surrogate.gpr_optim.parse_pop_factors(path: str | pathlib.Path, metrics: dict[str, str] | list[str], *, time: str = 'elapsed_s', quantity: str = 'process wall', cell: str | None = None)[source]#

Fixed-work factors and wall per layout as a :class:PopTable.

metrics maps a column of fractions to the label it is drawn with (a list uses the column names as labels); time names the column of the wall in seconds, from which speedup and fixed-work efficiency follow, and quantity says what that column measures for the axis label. Rows of one layout are averaged. The cell rule is that of :func:parse_pop_csv.

chemparseplot.parse.surrogate.gpr_optim.parse_components_csv(path: str | pathlib.Path, *, total: str = 'total', cells: list[str] | None = None)[source]#

Median seconds per component from a tidy CSV as a :class:ComponentTable.

Columns cell, ranks, threads, repetition, component, seconds; the component named total is the whole wall of that run and every other component a non-nesting part of it. Repetitions of one cell and layout are reduced to their median. A requested cell the file lacks, and a run without a total row, are errors.

chemparseplot.parse.surrogate.gpr_optim.parse_breakdown_csv(wall_csv: str | pathlib.Path, components: list[str], *, total: str | None = 'pipeline', cells: list[str] | None = None) → dict[str, tuple[list[str], dict[str, numpy.ndarray], numpy.ndarray | None]][source]#

Median seconds of each component stage per cell and layout.

Returns {cell: (layouts, {component: seconds}, total_seconds)} with layouts sorted by cores then threads. total names the stage holding the whole (None for no total). The components should not nest.