Gate the offload-state memory deltas on allocator-backed stats (#8409)
## Description
The dynamic offload-state tests assert strict allocated-memory deltas
around `offload_states()` / `reload_states()`:
- `alloc_after_offload < alloc_before_offload`
- `alloc_after_reload > alloc_after_offload`
That contract assumes `memory_allocated()` is allocator bookkeeping,
which holds on cuda (`torch.cuda.memory_allocated()`). On cpu,
`CPU_Accelerator.memory_allocated()` reports process RSS (psutil), and
RSS does not shrink when tensors are freed — so all 92 parameterized
cases fail even when the offload itself is correct (the device-placement
and data-integrity checks in the same tests pass).
Gate only the memory-delta asserts on whether the accelerator's torch
device module exposes `memory_allocated` (cuda does; `torch.cpu` does
not), mirroring the capability probe used for `fork_rng` in
`train_cifar` (#8407):
- cuda and other allocator-backed backends: behavior unchanged
- cpu: the unobservable deltas are skipped; all device-placement
validations still run
Exposed by the `LOCAL_SIZE=4` multi-rank CPU run in #8381 (92 of the 131
v1-half failures there).
## Validation (executed on real hardware)
- 20-core x86_64 CPU, torch 2.13.0+cpu, gloo backend, 2 ranks
(`LOCAL_SIZE=2`)
- Before:
`TestDynamicOffloadStatesZero12[False-1-False-False-optim_states]` fails
on the persistent-state delta assert
- After: 5 representative cases pass (persistent and grad paths, ZeRO
stage 1/2/3, `static_offload_optimizer=True` branch) — 5 passed in 55.6s
- pre-commit (yapf / flake8 / check-torchdist / codespell) passes on the
changed file
Sibling PRs from the same series: #8397, #8398, #8399, #8407.
Signed-off-by: Guokai Ma <guokai.ma@intel.com>