perf: reduce redundant CUDA initialization and synchronization - #190
Open
chen2021673 wants to merge 1 commit into
Open
perf: reduce redundant CUDA initialization and synchronization#190chen2021673 wants to merge 1 commit into
chen2021673 wants to merge 1 commit into
Conversation
Chamberlain0w0
approved these changes
Jul 31, 2026
kilinchange
requested changes
Jul 31, 2026
| class AutogradLinearForwardTest : public infini_train::test::InfiniTrainTest {}; | ||
|
|
||
| namespace { | ||
| std::shared_ptr<Tensor> CopyToCPU(const std::shared_ptr<Tensor> &tensor) { |
Collaborator
There was a problem hiding this comment.
直接在调用处用 Tensor->to(device) 函数就行吧,不需要额外封装工具函数,其他测试文件同理,
| class AutogradNormalizationBackwardTest : public infini_train::test::InfiniTrainTest {}; | ||
|
|
||
| namespace { | ||
| void ExpectValues(const std::shared_ptr<Tensor> &tensor, float expected) { |
Collaborator
There was a problem hiding this comment.
其他测试函数似乎都用到了类似的对比逻辑,建议封装成 tests 里的统一工具函数供所有测例使用。
| class AutogradReductionBackwardTest : public infini_train::test::InfiniTrainTest {}; | ||
|
|
||
| namespace { | ||
| void ExpectValues(const std::shared_ptr<Tensor> &tensor, const std::vector<float> &expected) { |
Collaborator
There was a problem hiding this comment.
同上,其他测试文件里直接写在测例里的精度对比逻辑,也都改成调用统一的精度对比工具函数吧。
Collaborator
There was a problem hiding this comment.
麻烦在所有涉及 loss 统计位置调整的地方补充注释,说明将 loss 拷贝到 CPU 并读取标量放在 backward 之后,是为了避免在反向开始前触发 D2H 同步、阻塞反向任务提交,从而让反向 kernel 尽早启动。
- defer loss host synchronization until after backward across training paths - skip zero fills when CUDA kernels or cuBLAS fully overwrite outputs - retain and document initialization required by partial-write paths - add CPU and CUDA numerical tests for affected operators
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.
Summary
Test