Skip to main content

Module seeded_init

Module seeded_init 

Source
Expand description

Seeded, host-side weight-initialization helpers that make policy construction bit-exact under PsroConfig::seed / NfspConfig::seed (issue #135). Burn 0.21’s Initializer has no seed parameter, so we pre-compute the trunk + head weights from an StdRng instead. Seeded, host-side weight-initialization helpers for bit-exact policy construction.

§Why this module exists

Burn 0.21’s burn::nn::Initializer::init_with / init_tensor (see burn-core-0.21.0/src/module/initializer.rs) take no seed parameter — they route through a backend-internal Tensor::random that draws from an unseeded, thread-local generator. That makes Initializer::Orthogonal and Initializer::KaimingUniform the last non-reproducible site in the PSRO/NFSP determinism contract advertised by crate::multi_agent::psro::PsroConfig::seed / crate::multi_agent::nfsp::NfspConfig::seed (every rollout/ training RNG site was plumbed through StdRng::seed_from_u64 in PRs #113/#116/#122/#123/#125; this closes the policy-init gap — issue #135).

§What it does

Provides pure-Rust, StdRng-driven ports of the two init recipes the MLP policies use:

§Bit-parity caveat

These are not byte-identical to Burn’s unseeded output — we are replacing the distribution with a reproducible one, not mirroring Burn’s internal sampler. The only contract is: same seed (and same shape/gain) ⇒ same Vec<f32>, every run, every machine.

Functions§

seeded_kaiming_uniform
Generate a seeded Kaiming-uniform weight matrix of shape [d_in, d_out] flattened in row-major order.
seeded_orthogonal
Generate a seeded orthogonal weight matrix of shape [d_in, d_out] flattened in row-major order (row index over d_in, column index over d_out) — matching Burn’s Linear weight layout (weight: Param<Tensor<B, 2>> with dims [d_input, d_output]).