class GradGraphPercentageBounded, opt-in runtime cache for the native gradient percentage. ``reference`` must be the native encoder-transformer gradient-percentage callable. Capture is validated only for PyTorch 2.5.1, CUDA 12.1 and A800 (sm80); other environments use that reference and record a fallback reason. No CUDA error is caught and retried as native execution. Model identity, parameter names/order/identity, participating gradients, layout/dtype/device, current stream and autocast context define each schema. Gradient storage can change without recapture. A fifth schema falls back; ``clear(model)`` allows a later epoch to build a fresh bounded cache after freezing/unfreezing parameters. Call lifecycle methods between steps; one instance is intended for one trainer thread.
| 名称 | 类型 | 默认值 |
|---|---|---|
reference | — | — |
enabled | — | True |
capture_allowed | — | False |
max_schemas | — | 4 |
warmup | — | 3 |
clear(self, model=None)Release cached graph/buffer state at a step boundary; keep counters.
| 名称 | 类型 | 默认值 |
|---|---|---|
model | — | None |
reset(self)Start a fresh runtime after restore; no capture until re-enabled.
set_enabled(self, enabled)Disabling releases caches. Re-enabling requires explicit warmup.
| 名称 | 类型 | 默认值 |
|---|---|---|
enabled | — | — |
set_capture_allowed(self, allowed)Allow new warmup captures; False still replays existing schemas.
| 名称 | 类型 | 默认值 |
|---|---|---|
allowed | — | — |
__call__(self, model)| 名称 | 类型 | 默认值 |
|---|---|---|
model | — | — |
debug_scalar_groups(self, model)Expose graph outputs for strict checks, without making CPU copies.
| 名称 | 类型 | 默认值 |
|---|---|---|
model | — | — |
audit(self)