Feat: add named parameters - #194
Open
JYMiracle305 wants to merge 2 commits into
Open
Conversation
Contributor
Author
JYMiracle305
force-pushed
the
feat/named-parameters
branch
from
August 6, 2026 08:12
15630b4 to
8a20374
Compare
JYMiracle305
changed the base branch from
master
to
feat/checkpoint-optimizer-state-control
August 6, 2026 08:14
JYMiracle305
changed the base branch from
feat/checkpoint-optimizer-state-control
to
master
August 6, 2026 08:16
JYMiracle305
changed the base branch from
master
to
feat/checkpoint-optimizer-state-control
August 6, 2026 08:17
JYMiracle305
force-pushed
the
feat/named-parameters
branch
from
August 6, 2026 08:44
8a20374 to
6efc27e
Compare
JYMiracle305
force-pushed
the
feat/named-parameters
branch
from
August 6, 2026 09:47
6efc27e to
5a75ab8
Compare
Base automatically changed from
feat/checkpoint-optimizer-state-control
to
master
August 7, 2026 02:18
kilinchange
force-pushed
the
feat/named-parameters
branch
from
August 7, 2026 02:18
5a75ab8 to
9dd31c7
Compare
chen2021673
requested changes
Aug 7, 2026
|
|
||
| void set_parameter_names(const std::vector<std::string> &names); | ||
|
|
||
| const std::vector<std::string> ¶meter_names() const; |
| std::unordered_set<const Tensor *> visited; | ||
|
|
||
| std::function<void(const Module &, const std::string &)> collect | ||
| = [&](const Module &module, const std::string &module_prefix) { |
Contributor
There was a problem hiding this comment.
parameters_ 和 modules_ 都是 unordered_map,不保序,同一个共享参数保存成哪个的 key 是不稳定的,现有 NamedModules() 是按名称排序 child 后遍历,这里能不能直接用NamedModules() 方法获取 modules_ 再保序遍历 parameters_ (parameters_ 数量太大的话排序不知道有没有性能问题)
| model_chunks, ddp_world_size, ddp_rank); | ||
| } else { | ||
| optimizer = optimizer_creator(params_to_optimize); | ||
| std::unordered_map<const Tensor *, std::string> parameter_name_by_tensor; |
Contributor
There was a problem hiding this comment.
这个逻辑只在 else 分支调用,分布式场景是暂时没有适配吗
| model_chunks, ddp_world_size, ddp_rank); | ||
| } else { | ||
| optimizer = optimizer_creator(params_to_optimize); | ||
| std::unordered_map<const Tensor *, std::string> parameter_name_by_tensor; |
Contributor
There was a problem hiding this comment.
这个逻辑能不能挪到 optimizer 构造时,不要在训练入口这里拼
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


1. 主要修改