Skip to main content

Module init

Module init 

Source
Expand description

Weight initialization utilities (C-INIT-001).

Provides rand_normal_seeded for proper random normal initialization, matching HuggingFace LLaMA’s normal(0, initializer_range).

Replaces the legacy sinusoidal sin(i * const) * scale placeholder that caused a 16x convergence gap vs PyTorch (entrenar#309).

References:

  • Touvron et al. (2023) LLaMA: arxiv 2302.13971
  • He et al. (2015) Kaiming init: arxiv 1502.01852
  • HuggingFace LlamaPreTrainedModel._init_weights

Constants§

INITIALIZER_RANGE
Default initializer range matching HuggingFace LLaMA config.

Functions§

get_init_seed
Get the current initialization seed.
lock_init_seed
Lock the init-seed critical section and set the seed atomically.
rand_normal_seeded
Generate n random normal values with mean=0 and std=INITIALIZER_RANGE.
set_init_seed
Set the global initialization seed (called from training config).