Closed
[refactor] 删除 DeepSeek-V4 未使用的初始化辅助项 #1288
hanboyouAdd on 20 days agoClosed at 19 days ago
[refactor] 删除 DeepSeek-V4 未使用的初始化辅助项 #1288
Closed
Total: 1 files changed+0-22
| @@ -17,7 +17,6 @@ from torchtitan.models.common.decoder_sharding import ( | |||
| 17 | pre_lm_head_norm_sharding_config, | 17 | pre_lm_head_norm_sharding_config, |
| 18 | token_embedding_sharding_config, | 18 | token_embedding_sharding_config, |
| 19 | ) | 19 | ) |
| 20 | -from torchtitan.models.common.param_init import depth_scaled_std | ||
| 21 | from torchtitan.models.deepseek_v4.flavors import ( | 20 | from torchtitan.models.deepseek_v4.flavors import ( |
| 22 | _build_mtp_layers as _upstream_build_mtp_layers, | 21 | _build_mtp_layers as _upstream_build_mtp_layers, |
| 23 | ) | 22 | ) |
| @@ -58,14 +57,8 @@ __all__ = [ | |||
| 58 | "model_registry", | 57 | "model_registry", |
| 59 | ] | 58 | ] |
| 60 | 59 | ||
| 61 | -_LINEAR_INIT = { | ||
| 62 | - "weight": partial(nn.init.trunc_normal_, std=0.02), | ||
| 63 | - "bias": nn.init.zeros_, | ||
| 64 | -} | ||
| 65 | _NORM_INIT = {"weight": nn.init.ones_} | 60 | _NORM_INIT = {"weight": nn.init.ones_} |
| 66 | _EMBEDDING_INIT = {"weight": partial(nn.init.normal_, std=1.0)} | 61 | _EMBEDDING_INIT = {"weight": partial(nn.init.normal_, std=1.0)} |
| 67 | -_APE_INIT = {"ape": partial(nn.init.trunc_normal_, std=0.02)} | ||
| 68 | -_SINK_INIT = {"attn_sink": partial(nn.init.trunc_normal_, std=0.02)} | ||
| 69 | _HC_PARAM_INIT = { | 62 | _HC_PARAM_INIT = { |
| 70 | "hc_fn": partial(nn.init.trunc_normal_, std=0.02), | 63 | "hc_fn": partial(nn.init.trunc_normal_, std=0.02), |
| 71 | "hc_base": partial(nn.init.trunc_normal_, std=0.02), | 64 | "hc_base": partial(nn.init.trunc_normal_, std=0.02), |
| @@ -81,21 +74,6 @@ def _output_linear_init(dim: int) -> dict[str, Callable]: | |||
| 81 | } | 74 | } |
| 82 | 75 | ||
| 83 | 76 | ||
| 84 | -def _depth_init(layer_id: int) -> dict[str, Callable]: | ||
| 85 | - return { | ||
| 86 | - "weight": partial(nn.init.trunc_normal_, std=depth_scaled_std(0.02, layer_id)), | ||
| 87 | - "bias": nn.init.zeros_, | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - | ||
| 91 | -def _depth_experts_init(layer_id: int) -> dict[str, Callable]: | ||
| 92 | - return { | ||
| 93 | - "w1_EFD": partial(nn.init.trunc_normal_, std=0.02), | ||
| 94 | - "w2_EDF": partial(nn.init.trunc_normal_, std=depth_scaled_std(0.02, layer_id)), | ||
| 95 | - "w3_EFD": partial(nn.init.trunc_normal_, std=depth_scaled_std(0.02, layer_id)), | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - | ||
| 99 | # SwiGLU gate/up clamp shared by all DSV4 flavors; 10.0 is the transformers | 77 | # SwiGLU gate/up clamp shared by all DSV4 flavors; 10.0 is the transformers |
| 100 | # config default (``swiglu_limit: float = 10.0``) and the inference repo's | 78 | # config default (``swiglu_limit: float = 10.0``) and the inference repo's |
| 101 | # ``config.json`` value. Zero disables the clamp. | 79 | # ``config.json`` value. Zero disables the clamp. |