Closed
[refactor] 退役 DeepSeek-V4 重复配置 registry #1286
hanboyouAdd on 20 days agoClosed at 19 days ago
[refactor] 退役 DeepSeek-V4 重复配置 registry #1286
Closed
hanboyouAdd on 20 days agoClosed at 19 days ago
Total: 5 files changed+24-818
@@ -284,13 +284,13 @@ System: Ascend 950,图模式
284 284 
285| 模型 | NPU 数 | 量化 | GBS | 序列长度 | FSDP | TP | PP | CP | EP | 单卡吞吐 (tokens/s) | step time | BF16 MFU |285| 模型 | NPU 数 | 量化 | GBS | 序列长度 | FSDP | TP | PP | CP | EP | 单卡吞吐 (tokens/s) | step time | BF16 MFU |
286| :--- | ---: | :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |286| :--- | ---: | :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
287-| [DeepSeek-V4-Flash](torchtitan_npu/models/deepseek_v4/config_registry.py) | 64 | MXFP8 | 512 | 4k | 64 | 1 | 1 | 1 | 64 | 2126 | 15.42 s | / |287+| [DeepSeek-V4-Flash](torchtitan_npu_recipes/models/deepseek_v4.py) | 64 | MXFP8 | 512 | 4k | 64 | 1 | 1 | 1 | 64 | 2126 | 15.42 s | / |
288-| [DeepSeek-V4-Flash](torchtitan_npu/models/deepseek_v4/config_registry.py) | 64 | MXFP8 | 64 | 64k | 8 | 1 | 1 | 8 | 64 | 1501.6 | 43.64 s | / |288+| [DeepSeek-V4-Flash](torchtitan_npu_recipes/models/deepseek_v4.py) | 64 | MXFP8 | 64 | 64k | 8 | 1 | 1 | 8 | 64 | 1501.6 | 43.64 s | / |
289-| [DeepSeek-V4-Flash](torchtitan_npu/models/deepseek_v4/config_registry.py) | 128 | MXFP8 | 8 | 1M | 1 | 1 | 1 | 128 | 128 | 1325 | 49.46 s | / |289+| [DeepSeek-V4-Flash](torchtitan_npu_recipes/models/deepseek_v4.py) | 128 | MXFP8 | 8 | 1M | 1 | 1 | 1 | 128 | 128 | 1325 | 49.46 s | / |
290-| [DeepSeek-V4-Flash](torchtitan_npu/models/deepseek_v4/config_registry.py) | 64 | BF16 | 512 | 4k | 64 | 1 | 1 | 1 | 64 | 1603 | 20.44 s | 28.81% |290+| [DeepSeek-V4-Flash](torchtitan_npu_recipes/models/deepseek_v4.py) | 64 | BF16 | 512 | 4k | 64 | 1 | 1 | 1 | 64 | 1603 | 20.44 s | 28.81% |
291-| [DeepSeek-V4-Flash](torchtitan_npu/models/deepseek_v4/config_registry.py) | 64 | BF16 | 64 | 64k | 8 | 1 | 1 | 8 | 64 | 1421 | 46.12 s | 32.87% |291+| [DeepSeek-V4-Flash](torchtitan_npu_recipes/models/deepseek_v4.py) | 64 | BF16 | 64 | 64k | 8 | 1 | 1 | 8 | 64 | 1421 | 46.12 s | 32.87% |
292-| [DeepSeek-V4-Flash](torchtitan_npu/models/deepseek_v4/config_registry.py) | 64 | QAT | 512 | 4k | 64 | 1 | 1 | 1 | 64 | 1576 | 20.79 s | / |292+| [DeepSeek-V4-Flash](torchtitan_npu_recipes/models/deepseek_v4.py) | 64 | QAT | 512 | 4k | 64 | 1 | 1 | 1 | 64 | 1576 | 20.79 s | / |
293-| [DeepSeek-V4-Flash](torchtitan_npu/models/deepseek_v4/config_registry.py) | 64 | QAT | 64 | 64k | 8 | 1 | 1 | 8 | 64 | 1532 | 42.78 s | / |293+| [DeepSeek-V4-Flash](torchtitan_npu_recipes/models/deepseek_v4.py) | 64 | QAT | 64 | 64k | 8 | 1 | 1 | 8 | 64 | 1532 | 42.78 s | / |
294 294 
295# 免责声明295# 免责声明
296 296 
@@ -26,7 +26,7 @@ A5 使用 `CONFIG=deepseek_v4_flash_lora bash examples/deepseek_v4/deepseek_v4_f
26```python26```python
27from torchtitan.config.transform import apply_transforms27from torchtitan.config.transform import apply_transforms
28 28 
29-from torchtitan_npu.models.deepseek_v4.config_registry import deepseek_v4_flash29+from torchtitan_npu_recipes.models.deepseek_v4 import deepseek_v4_flash
30from torchtitan_npu.models.deepseek_v4.lora import deepseek_v4_lora_transform30from torchtitan_npu.models.deepseek_v4.lora import deepseek_v4_lora_transform
31from torchtitan_npu.models.deepseek_v4.peft import DeepSeekV4PEFTCheckpointManager31from torchtitan_npu.models.deepseek_v4.peft import DeepSeekV4PEFTCheckpointManager
32 32 
@@ -112,7 +112,7 @@ DeepSeek-V4 复用 `roll_mtp_sequence` 和社区多预测列表接口,只实
112| `deepseek_v4/__init__.py` | 根据模型规格构造非压缩、mHC-aware 的 MTP blocks |112| `deepseek_v4/__init__.py` | 根据模型规格构造非压缩、mHC-aware 的 MTP blocks |
113| `deepseek_v4/model.py` | 保留主干多流 state,并组织主预测和 MTP 预测 |113| `deepseek_v4/model.py` | 保留主干多流 state,并组织主预测和 MTP 预测 |
114| `deepseek_v4/mtp.py` | 实现 DeepSeek-V4 mHC MTP block、CP batch 和 chunk loss |114| `deepseek_v4/mtp.py` | 实现 DeepSeek-V4 mHC MTP block、CP batch 和 chunk loss |
115-| `deepseek_v4/config_registry.py` | 默认 recipe 构造 MTP 模型并配置 MTP chunk loss |115+| `torchtitan_npu_recipes/models/deepseek_v4.py` | 默认 recipe 构造 MTP 模型并配置 MTP chunk loss |
116| `deepseek_v4/parallelize.py` | 让 MTP blocks 复用现有 DSV4 并行流程 |116| `deepseek_v4/parallelize.py` | 让 MTP blocks 复用现有 DSV4 并行流程 |
117| `deepseek_v4/sharding.py` | 增加 MTP fusion、mHC head 和有效掩码布局 |117| `deepseek_v4/sharding.py` | 增加 MTP fusion、mHC head 和有效掩码布局 |
118| `deepseek_v4/state_dict_adapter.py` | 转换本地 `mtp_layers` 与 HF `mtp.<depth>` 参数 |118| `deepseek_v4/state_dict_adapter.py` | 转换本地 `mtp_layers` 与 HF `mtp.<depth>` 参数 |
@@ -1,21 +1,32 @@
1# Copyright (c) 2026 Huawei Technologies Co., Ltd. All rights reserved.1# Copyright (c) 2026 Huawei Technologies Co., Ltd. All rights reserved.
2# SPDX-License-Identifier: BSD-3-Clause2# SPDX-License-Identifier: BSD-3-Clause
3 3 
4-"""Small optimizer integration recipes with explicit checkpoint ownership."""4+"""Small optimizer recipes with explicit checkpoint and compile ownership."""
5 5 
6from torchtitan.components.checkpointer import CheckpointManager6from torchtitan.components.checkpointer import CheckpointManager
7 7 
8from torchtitan_npu.config import CompileConfig, ModelCompileConfig8from torchtitan_npu.config import CompileConfig, ModelCompileConfig
9-from torchtitan_npu.models.deepseek_v4.config_registry import deepseek_v4_debugmodel9+from torchtitan_npu_recipes.models.deepseek_v4 import deepseek_v4_debugmodel
10+ 
11+ 
12+def _optimizer_debug_config():
13+ config = deepseek_v4_debugmodel()
14+ # Keep these cases' compilation boundary independent of recipe defaults.
15+ config.model.local_compile_regions = [
16+ "loss",
17+ "fused_binary_activation",
18+ "fp32_to_bf16_split",
19+ ]
20+ return config
10 21 
11 22 
12def deepseek_v4_checkpoint():23def deepseek_v4_checkpoint():
13- config = deepseek_v4_debugmodel()24+ config = _optimizer_debug_config()
14 config.checkpointer = CheckpointManager.Config()25 config.checkpointer = CheckpointManager.Config()
15 return config26 return config
16 27 
17 28 
18def deepseek_v4_aot_eager():29def deepseek_v4_aot_eager():
19- config = deepseek_v4_debugmodel()30+ config = _optimizer_debug_config()
20 config.compile = CompileConfig(components=[], model=ModelCompileConfig(backend="aot_eager"))31 config.compile = CompileConfig(components=[], model=ModelCompileConfig(backend="aot_eager"))
21 return config32 return config