vibeqc.PerfTracker

class vibeqc.PerfTracker(phases=<factory>, scf_iters=<factory>, memory_snapshots=<factory>, threads=1, t_start=<factory>)[source]

Bases: object

Accumulator for per-phase wall/CPU timings, per-iteration SCF rows, and memory snapshots over the course of a calculation.

Constructed inside perf_log() and passed implicitly to every PerfScope opened in the same async-context (uses contextvars.ContextVar, so perf trackers do NOT leak across threads or asyncio tasks). Call sites that want to read the live tracker — to add a custom snapshot, for instance — use active_tracker().

Public attributes:

  • phases — map phase_name _PhaseStat; wall_s on each entry is the cumulative wall time across all calls.

  • scf_iters — list of per-iteration dicts (energy / dE / grad / DIIS / wall_s); populated by SCF entry points wired into the progress logger.

  • memory_snapshots — list of {label, rss_mb, t_s} taken at SCF transitions.

  • threads — snapshot of the OpenMP thread count at tracker construction (used to compute parallelism = cpu_s / (wall_s × threads) per phase).

  • t_start — perf_counter timestamp; phase rows report wall-time deltas relative to this anchor.

Parameters:
__init__(phases=<factory>, scf_iters=<factory>, memory_snapshots=<factory>, threads=1, t_start=<factory>)
Parameters:
Return type:

None

Methods

__init__([phases, scf_iters, ...])

add_scf_iter(**fields)

Record one SCF iteration.

add_scope(name, wall_s, cpu_s)

snapshot_memory(label)

Take a labeled RSS snapshot.

Attributes

phases: dict[str, _PhaseStat]
scf_iters: list[dict[str, Any]]
memory_snapshots: list[dict[str, Any]]
threads: int = 1
t_start: float
add_scope(name, wall_s, cpu_s)[source]
Parameters:
Return type:

None

add_scf_iter(**fields)[source]

Record one SCF iteration. Recognized keys: iter, energy, dE, grad, diis. Extra keys are kept verbatim in the row.

Parameters:

fields (Any)

Return type:

None

snapshot_memory(label)[source]

Take a labeled RSS snapshot. label is what shows up in the report (typically "start_of_scf", "after_iter_5", "end_of_scf").

Parameters:

label (str)

Return type:

None

property total_wall_s: float