Feat: Activation Checkpointing#154
Open
Chamberlain0w0 wants to merge 3 commits into
Open
Conversation
d87926e to
ba8db8f
Compare
chen2021673
reviewed
Jun 9, 2026
| @@ -1,12 +1,15 @@ | |||
| #include "infini_train/include/nn/modules/transformer/transformer.h" | |||
Contributor
There was a problem hiding this comment.
之后扩展 recompute 其他功能(如selective)的话就不适合全放在transformer.cc里了,之后可以拆分activation_recompute.cc。本PR可以不做修改
Contributor
Author
There was a problem hiding this comment.
确实,这块确实没太想清楚,主要是 megatron 的实现里面也把很多重计算逻辑融在了 transformer 模型层,之后可以再讨论下
chen2021673
reviewed
Jun 9, 2026
chen2021673
reviewed
Jun 9, 2026
chen2021673
reviewed
Jun 9, 2026
9cdf73c to
a38a4d3
Compare
a38a4d3 to
e594d9c
Compare
Chamberlain0w0
commented
Jun 25, 2026
| // Used by non-reentrant checkpoint recomputation so downstream SetupContext | ||
| // calls see the same needs_input_grad_ pattern as the original forward, | ||
| // without wiring the recompute graph into the engine. | ||
| class PropagateRequiresGradGuard { |
Contributor
Author
There was a problem hiding this comment.
本质上是需要一个 2*2=4 种情况的精细控制(with_grad/no_grad x 带引用计数建图/仅传递 requires_grad)。
也可以不单独实现一个 guard,而是给原先的 GradGuard 重载一个带参数 (比如 bool record_context = false) 的构造方式,让 GradGuard 本身能够覆盖这四种情况。
Chamberlain0w0
commented
Jun 25, 2026
| try { | ||
| forward_fn(detached_inputs); | ||
| } catch (const StopRecomputeError &) { | ||
| // Early-stop: expected when all needed tensors are recomputed. |
Contributor
Author
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.

No description provided.