You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ensemble members with noise injection should be able to generate predictable and reproducible noise. #191
I have been looking into the implementation of Aurora 1.5 Ensemble and I have some feedback.
In some applications we want to focus on individual ensemble members. To make this possible, it would be helpful to support deterministic, per-ensemble-member noise generation so that a given ensemble member produces the same noise sequence across model runs.
A possible implementation would be to assign each ensemble member its own RNG seed. These seeds could either be provided explicitly or generated automatically when the ensemble members are created.
We should not generate the same noise on every forward pass. The goal should be to reproduce the same noise sequence when processing the same sequence of batches in the same order. RNG state management could be exposed to the user so that they have control over the random number sequence predictability.
This could be done by adding a rng_reset() method to the Swin3DTransformerBackbone class, which restore the initial RNG state associated with the ensemble member. The Aurora ensemble model would also be extended with the ability to invoke rng_reset for every ensemble member. Users would invoke this method whenever deterministic semantics is required (for example, at the start of an inference run of the model).
To preserve current behaviour, this would be entirely optional. The per-ensemble-member seed would default to None (current semantics), with deterministic behaviour enabled only when an explicit seed is provided. With the current semantics, rng_reset() could either raise an exception or be a silent no-op.
Summary: support optional per-ensemble-member RNG seeds for the sake of making noise generation reproducible across runs for a given ensemble member.
Reactions are currently unavailable
Activity
s-sasaki-earthsea-wizard commented on Jul 19, 2026
I had the same need for reproducible ensemble members, so I prototyped this proposal on a branch — and it works as hoped: with an optional per-member noise_seed, a given ensemble member reproduces the exact same noise sequence across runs and across fresh model instances, and calling rng_reset() restores the sequence from the start. noise_seed=None keeps the current behaviour unchanged. All 43 tests under tests/v1p5/ pass.
An optional noise_seed: int | None = None on Swin3DTransformerBackbone, plumbed through Aurora (and therefore AuroraV1p5Ensemble). When set, noise is drawn from a dedicated per-instance torch.Generator instead of the global RNG. None preserves the current noise-generation semantics.
rng_reset() restores the initial RNG state, so processing the same sequence of batches in the same order reproduces the same noise sequence. Exposed on the model via Aurora.rng_reset().
The generator is created lazily on the first noise sample because it must live on the same device as the noise tensor (a CPU generator cannot be used for CUDA tensors).
A few design decisions on the points the issue left open — feedback welcome:
With noise_seed=None, rng_reset() is a warning-emitting no-op rather than an exception, so it is safe to call unconditionally while still surfacing misuse.
When a seed is configured, rng_reset() also flushes the noise cache used for noise accumulation: leftover cached noise would otherwise contaminate the reproduced sequence.
The existing reset_noise() (cache only) and the new rng_reset() (RNG state + cache) stay separate methods, with the distinction documented.
Moving the model to another device recreates the generator from the initial seed (with a warning), which restarts the noise sequence from the beginning; this is documented in the docstring.
One note for testing: with randomly initialised weights the adaptive-LN modulation is zero-initialised (init_respostnorm), so the noise context does not affect the output at initialization. The tests therefore record the sampled noise directly instead of comparing model outputs.
Happy to open a PR if this direction looks right to the maintainers.
Instead of adding an argument noise_seed to the constructor, how would it sound to add a keyword generator: torch.Generator | tuple[torch.Generator | None, ...] | None to Aurora.forward, which is then passed to Swin3DTransformerBackbone.forward and used in the torch.randn calls?
If the user generates multiple ensemble members simultaneously by using a batch size, one could pass a tuple of generators to control the randomness for each ensemble member simultaneously.
Wessel (@wesselb)Agnieszka Słowik (@Slowika) Thank you for the feedback! I have opened #202 implementing the generator keyword on Aurora.forward as suggested, with a tuple of per-member generators supported for batched ensemble members. The previous prototype branch stays untouched for reference. Details and a few design decisions are described in the PR.
Activity
s-sasaki-earthsea-wizard commentedon Jul 19, 2026
I had the same need for reproducible ensemble members, so I prototyped this proposal on a branch — and it works as hoped: with an optional per-member
noise_seed, a given ensemble member reproduces the exact same noise sequence across runs and across fresh model instances, and callingrng_reset()restores the sequence from the start.noise_seed=Nonekeeps the current behaviour unchanged. All 43 tests undertests/v1p5/pass.The branch:
feature/per-member-noise-seed(pinned at1ff8fe5). Details below.Implementation
noise_seed: int | None = NoneonSwin3DTransformerBackbone, plumbed throughAurora(and thereforeAuroraV1p5Ensemble). When set, noise is drawn from a dedicated per-instancetorch.Generatorinstead of the global RNG.Nonepreserves the current noise-generation semantics.rng_reset()restores the initial RNG state, so processing the same sequence of batches in the same order reproduces the same noise sequence. Exposed on the model viaAurora.rng_reset().A few design decisions on the points the issue left open — feedback welcome:
noise_seed=None,rng_reset()is a warning-emitting no-op rather than an exception, so it is safe to call unconditionally while still surfacing misuse.rng_reset()also flushes the noise cache used for noise accumulation: leftover cached noise would otherwise contaminate the reproduced sequence.reset_noise()(cache only) and the newrng_reset()(RNG state + cache) stay separate methods, with the distinction documented.Verification
tests/v1p5/test_noise_seed.pycovers:rng_reset()reproduces the exact noise sequence, also with noise accumulation enabled;rng_reset()the stream keeps advancing, and different seeds produce different noise;noise_seed=Nonepreserves the current global-RNG semantics, and the no-oprng_reset()leaves both the global RNG state and the noise cache untouched.To reproduce:
Expected result: all 43 tests pass.
One note for testing: with randomly initialised weights the adaptive-LN modulation is zero-initialised (
init_respostnorm), so the noise context does not affect the output at initialization. The tests therefore record the sampled noise directly instead of comparing model outputs.Happy to open a PR if this direction looks right to the maintainers.
wesselb commentedon Aug 19, 2026
Hey Agnieszka Słowik (@Slowika) and Syota-Sasaki (@s-sasaki-earthsea-wizard)! Thanks for opening and issue and apologies for the slow reply from our side.
Instead of adding an argument
noise_seedto the constructor, how would it sound to add a keywordgenerator: torch.Generator | tuple[torch.Generator | None, ...] | NonetoAurora.forward, which is then passed toSwin3DTransformerBackbone.forwardand used in thetorch.randncalls?If the user generates multiple ensemble members simultaneously by using a batch size, one could pass a tuple of generators to control the randomness for each ensemble member simultaneously.
wesselb commentedon Aug 19, 2026
CC Jonathan Weyn (@jweyn)
Slowika commentedon Aug 20, 2026
Hi Wessel (@wesselb) ! Thank you for the reply.
I like this approach! It gives the user a higher level of control over using fixed random seeds.
Syota-Sasaki (@s-sasaki-earthsea-wizard) Are you happy to make this change on your branch and open a PR? I don't think this is a big change.
s-sasaki-earthsea-wizard commentedon Aug 24, 2026
Wessel (@wesselb) Agnieszka Słowik (@Slowika) Thank you for the feedback! I have opened #202 implementing the
generatorkeyword onAurora.forwardas suggested, with a tuple of per-member generators supported for batched ensemble members. The previous prototype branch stays untouched for reference. Details and a few design decisions are described in the PR.Add `generator` argument to `forward` for reproducible noise in stoch…