Randomness¶
Deterministic seed derivation. A SeedTree splits one master seed into
independent, reproducible SeedStreams so every process, replication, and
shard draws from a stream that depends only on its path in the tree — never on
scheduling or completion order. Both are re-exported from the top-level
llmsim package.
SeedTree ¶
SeedTree(master_seed)
Mints independent, reproducible streams from one master seed.
The entry point of the Phase 2 randomness design: construct one tree from
the study's explicit master_seed, then draw one stream per
(config_index, replication_index). :meth:rng is the exact seam the
Phase 1 Sim(rng=...) constructor consumes::
tree = SeedTree(master_seed=20260712)
sim = Sim(rng=tree.rng(config_index=0, replication_index=3))
Root the tree at master_seed (validated to be an int).
child_seed ¶
child_seed(config_index, replication_index)
Derive the 128-bit child seed for one triple under this master.
stream ¶
stream(config_index, replication_index)
Return the picklable :class:SeedStream spec for one triple.
rng ¶
rng(config_index, replication_index)
Return a fresh random.Random for one triple (the Sim seam).
SeedStream
dataclass
¶
SeedStream(seed, config_index, replication_index)
A picklable spec for one derived stream.
Carries the (config_index, replication_index) identity plus the
derived child seed -- exactly what an execution backend transports to a
worker (a seed spec, never a live random.Random). Call :meth:rng
worker-side to construct the actual stream. A frozen dataclass, so
transported clones compare equal and hash consistently.