-
Notifications
You must be signed in to change notification settings - Fork 2.2k
add moh #4881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
add moh #4881
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -398,6 +398,7 @@ def _gen_aoa_config(cls, config: DeepseekV4Config): | |
| n_shared_experts = getattr(config, "n_shared_experts", 1) | ||
| moe_n_hash_layers = getattr(config, "moe_n_hash_layers", 3) | ||
| dense_mode = getattr(config, "csa_dense_mode", False) | ||
| use_moh = getattr(config, "use_moh", False) | ||
| csa_compress_ratios = config.csa_compress_ratios | ||
| num_head_empty_layers = ( | ||
| config.num_empty_layers_add_in_head | ||
|
|
@@ -518,6 +519,12 @@ def _gen_aoa_config(cls, config: DeepseekV4Config): | |
| f"{idx_src}.weights_proj.weight^T -> {idx_tgt}.linear_weights_proj.weight", | ||
| f"{idx_src}.wq_b.weight^T -> {idx_tgt}.linear_wq_b.weight", | ||
| ] | ||
| # V4_INDEXER_MOH: indexer_moh_bias (persistable buffer) is not in the pretrained checkpoint; | ||
| # randomly initialize them via add primitive. | ||
| if use_moh: | ||
| stmts += [ | ||
| f"_ -> {idx_tgt}.indexer_moh_bias", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已在当前头部验证:decoder 与 MTP 两处
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 更正:当前头部只补了 Fleet -> HF 导出,HF -> Fleet 仍是
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已核对当前头部:decoder 与 MTP 的正向 AOA 会根据 checkpoint key 在已保存 bias 存在时使用命名映射,缺失时才零初始化;保存器始终生成索引,加载端也会读取该 key 集。原 P1 已修复。 |
||
| ] | ||
|
|
||
| # --- MoE Gate --- | ||
| stmts += [f"{src}.ffn.gate.weight -> {tgt}.mlp.gate.weight, dtype='float32'"] | ||
|
|
@@ -651,6 +658,12 @@ def _gen_aoa_config(cls, config: DeepseekV4Config): | |
| f"{idx_src}.weights_proj.weight^T -> {idx_tgt}.linear_weights_proj.weight", | ||
| f"{idx_src}.wq_b.weight^T -> {idx_tgt}.linear_wq_b.weight", | ||
| ] | ||
| # V4_INDEXER_MOH: indexer_moh_bias (persistable buffer) is not in the pretrained checkpoint; | ||
| # randomly initialize them via add primitive. | ||
| if use_moh: | ||
| stmts += [ | ||
| f"_ -> {idx_tgt}.indexer_moh_bias", | ||
| ] | ||
|
|
||
| # --- MoE Gate (MTP layers are always non-hash, so always have bias) --- | ||
| stmts += [ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_stop_gradient_skips_update_but_still_zeroes_counter只将linear_wq_b.weight.stop_gradient设为True,但这里实际读取的是linear_weights_proj.weight。测试里的_FakeCSAIndexer没有linear_weights_proj,所以ref_param会是None,随后仍执行indexer_moh_bias.add_,该测试在依赖齐全时必然失败,也没有验证注释所述的冻结保护。请统一代表参数与 fake/test,并确保冻结分支测试通过。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已核对当前实现与测试均使用
linear_weights_proj.weight作为冻结判定参数,并新增了冻结非代表参数不应触发冻结分支的覆盖。原 P1 已修复。