vibeqc.PerfTracker

class vibeqc.PerfTracker(phases=<factory>, scf_iters=<factory>, memory_snapshots=<factory>, threads=1, t_start=<factory>, native_phases=<factory>, native_dropped_calls=0, _native_token=None)[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 x 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>, native_phases=<factory>, native_dropped_calls=0, _native_token=None)
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.

snapshot_native(*[, _finish])

Drain completed native calls; safe to render an intermediate report.

Attributes

phases: dict[str, _PhaseStat]
scf_iters: list[dict[str, Any]]
memory_snapshots: list[dict[str, Any]]
threads: int = 1
t_start: float
native_phases: list[dict[str, Any]]
native_dropped_calls: int = 0
snapshot_native(*, _finish=False)[source]

Drain completed native calls; safe to render an intermediate report.

The native buffer holds 256 calls between snapshots. Loss is counted. Abrupt process termination cannot run context cleanup, so checkpoint the report after completed calls when profiling a bounded calculation.

Parameters:

_finish (bool)

Return type:

None

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