nvalchemi.distributed.resolve_cap#
- nvalchemi.distributed.resolve_cap(state, key, real, *, initial_factor, grow_factor=1.30, stride=16, extra=0, strict_gt=True)[source]#
Grow-only fixed-shape capacity for
key,>= real + extra.A cap is sized on first sight with
initial_factorheadroom, regrows withgrow_factoronly when the real count would overflow, and is always rounded up to a multiple ofstrideso small MD-step fluctuation lands in the same bucket — keeping the compiled graph from recompiling. The cap only ever grows, so a hot path reuses one compiled graph.- Parameters:
state (dict[str, int]) – Mutable dict holding the persistent caps across forwards (the caller owns its lifetime).
key (str) – Which capacity (e.g.
"atoms"/"edges"/"max_send").real (int) – The real count needed this step (before padding).
initial_factor (float) – Headroom multiplier applied the first time
keyis sized, set to cover the equilibrated peak from the first compile (e.g. edges climb ~25% through equilibration, atoms barely move).grow_factor (float) – Headroom multiplier applied on a later overflow.
stride (int) – Bucket size; the cap is rounded up to a multiple of this (16 for kernel-friendly shapes; coarser counts that swing more use a larger one).
extra (int) – Slots reserved beyond
real(e.g. UMA reserves 2 for the dead-edge anchor pair).strict_gt (bool) – Overflow test:
real + extra > capwhen True (the default; edges / send), or>= capwhen False (atoms, which need a strictly-larger cap because the dead row sits atcap - 1).
- Returns:
The (possibly grown) capacity for
key, recorded instate.- Return type:
int