Repository navigation
v0.12.1 — get_state/set_state correctness fix
Validated on Trn2 (trn2.3xlarge, Neuron SDK 2.33.0, native TorchNeuron) — see trnsci/trnsci#35.
Headline: correctness fix: in 0.7.0–0.12.0, Generator.get_state() / set_state() did not save the NKI stream counter, so a restored generator drew different values on the nki / auto paths. The state now carries the counter, and old-format states are still accepted (#75, #74).
Fixed
Generator.get_state()/set_state()did not restore the NKI stream (silent).
Affects released versions 0.7.0 through 0.12.0, on the NKI path only
(set_backend("nki"), or"auto"on Neuron hardware); the PyTorch path is
not affected. The state held only thetorch.Generatorstate, not the
Threefry counter the NKI draws take their offsets from, so restoring a
checkpoint and drawing again gave different values (Trn2: max |diff| 0.97
foruniform, 5.7 fornormal, both key modes). The state now carries the
counter too (torchstate followed by 8 counter bytes), andset_state
restores both and re-derives the counter-mode key. A baretorch.Generator
state is still accepted (#74).