-
Notifications
You must be signed in to change notification settings - Fork 876
[Docathon][Add CN Doc No.35-37] #6442
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ddfdfce
[Docathon][Add CN Doc No.35-37]
Kaedeharai d7c157e
Merge branch 'develop' of https://github.com/PaddlePaddle/docs into d…
Kaedeharai 80b5453
modified: docs/api/paddle/incubate/distributed/utils/io/dist_save/…
Kaedeharai 2cf42fd
Merge branch 'develop' of https://github.com/PaddlePaddle/docs into d…
Kaedeharai 029ac4b
Update docs/api/paddle/incubate/distributed/utils/io/dist_save/save_c…
sunzhongkai588 252634b
Update docs/api/paddle/incubate/distributed/utils/io/dist_save/save_f…
sunzhongkai588 282edc1
Update docs/api/paddle/incubate/distributed/utils/io/dist_save/save_c…
sunzhongkai588 38c6863
Update docs/api/paddle/incubate/distributed/utils/io/dist_save/save_f…
sunzhongkai588 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
docs/api/paddle/incubate/distributed/utils/io/dist_save/save_cn.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| .. _cn_api_paddle_incubate_distributed_utils_io_idst_save_save: | ||
|
|
||
| save | ||
| ------------------------------- | ||
|
|
||
| .. py:function:: paddle.incubate.distributed.utils.io.dist_save.save(state_dict, path, **configs) | ||
|
|
||
| 在分布式和单卡环境中将状态字典保存到指定路径。 | ||
|
|
||
| .. note:: | ||
| 现在支持保存 Layer/Optimizer 的 ``state_dict``, Tensor 和包含 Tensor、Program 的嵌套结构。 | ||
|
|
||
| .. note:: | ||
| 与 ``paddle.jit.save`` 不同的是, 由于 ``paddle.save`` 的保存结果为单个文件,因此无需通过添加后缀来区分多个保存的文件。 | ||
| ``paddle.save`` 的 ``path`` 参数将直接用作保存的文件名,而不是前缀。 | ||
| 为了统一保存的文件名格式, 我们推荐使用 paddle 的标准后缀: | ||
| 1. 对于 ``Layer.state_dict`` , 推荐使用 ``.pdparams`` ; | ||
| 2. 对于 ``Optimizer.state_dict`` , 推荐使用 ``.pdopt`` . | ||
| 具体示例请参考 API 代码示例。 | ||
|
|
||
| 参数 | ||
| ::::::::: | ||
| - **obj**(Object) : 要保存的对象。 | ||
| - **path**(str|BytesIO) : 保存的对象的路径/缓冲区。如果保存在当前目录中,则输入路径字符串将用作文件名。 | ||
| - **protocol**(int, 可选): pickle 模块的协议版本必须大于 1 且小于 5。默认值为 4。 | ||
| - ****configs**(dict, 可选): 可选的关键字参数。目前支持以下选项: | ||
|
|
||
| 1. use_binary_format(bool): | ||
| 在 paddle.save 中使用。当保存的对象是静态图形变量时, 可以指定 ``use_binary_for_var``。 | ||
| 如果为 True , 则在保存单个静态图变量时, 以 c++ 二进制格式保存文件;否则, 请将其保存为 pickle 格式。 | ||
| 默认值为 False. | ||
| 2. gather_to(int|list|tuple|None): | ||
| 指定要保存的全局进程。默认值为 None. | ||
| None 表示分布式保存不收集到单个卡上。 | ||
| 3. state_type(str): | ||
| 值可以是 'params' 或 'opt',指定保存参数或优化器状态。 | ||
| 4. max_grouped_size(str|int): | ||
| 限制对象组在一段时间内传输的最大大小(位数)。 | ||
| 如果是字符串, 格式必须为 num+'G/M/K',例如 3G、2K、10M 等。默认值为 3G。 | ||
sunzhongkai588 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| 返回 | ||
| ::::::::: | ||
| None | ||
|
|
||
|
|
||
| 代码示例 | ||
| :::::::::: | ||
|
|
||
| COPY-FROM: paddle.incubate.distributed.utils.io.dist_save.save | ||
35 changes: 35 additions & 0 deletions
35
...i/paddle/incubate/distributed/utils/io/dist_save/save_for_auto_inference_cn.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| .. _cn_api_paddle_incubate_distributed_utils_io_idst_save_save_for_auto_inference: | ||
sunzhongkai588 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| save_for_auto_inference | ||
| ------------------------------- | ||
|
|
||
| .. py:function:: paddle.incubate.distributed.utils.io.dist_save.save_for_auto_inference(path_prefix, dist_model, cvt2cpu=False) | ||
|
|
||
| 描述 | ||
| ::::::::: | ||
| 保存模型参数以进行自动并行推理。支持 dp + mp + pp + shardin(stage1)、dp + sharding stage2-3。 | ||
|
||
| 在自动并行模式下支持 MoE 之前, MoE 不会被支持。 | ||
|
|
||
|
|
||
| 参数 | ||
| ::::::::: | ||
| - **path_prefix**: 要保存的路径前缀。如果 `path_preifx` 以路径分隔符结尾, 则路径将作为目录进行处理,参数将保存在其中,并自动命名为 saved_parameters。 | ||
| 其他,参数将保存为名称 path_preifx_dist{global_rank}.pdparams 和 path_preifx_dist{global_rank}.pdattrs。 | ||
sunzhongkai588 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **dist_model**: 分布式模型中的模型。 | ||
| - **cvt2cpu**: 在使用分片阶段 3 时将参数移动到 CPU。如果不使用分片阶段 3, 则 var 无效。 | ||
|
||
|
|
||
|
|
||
| 返回 | ||
| ::::::::: | ||
| None | ||
|
|
||
|
|
||
| 代码示例 | ||
| :::::::::: | ||
| COPY-FROM: paddle.incubate.distributed.utils.io.dist_save.save_for_auto_inference | ||
|
|
||
|
|
||
| 输出 | ||
| ::::::::: | ||
| path/to/save_infer_dist0.pdparams path/to/save_infer_dist1.pdparams path/to/save_infer_dist2.pdparams ... | ||
| path/to/save_infer_dist0.pdattr path/to/save_infer_dist1.pdattr path/to/save_infer_dist2.pdattr ... | ||
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.
Uh oh!
There was an error while loading. Please reload this page.