Fix duplicate FP8 state updates during activation checkpoint recomputation - #3213
Fix duplicate FP8 state updates during activation checkpoint recomputation#3213AlbertYang514 wants to merge 3 commits into
Conversation
Greptile SummaryThis PR fixes duplicate FP8 state updates during activation-checkpoint recomputation by replacing the shared class-level
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant OA as te.autocast (outer)
participant ARF as activation_recompute_forward<br/>(forward, reserve=True)
participant M1 as Module 1 (Linear)
participant M2 as Module 2 (Linear)
participant ARR as activation_recompute_forward<br/>(recompute, state shared)
participant RA as autocast(_recompute=True)
Note over OA: is_first_fp8_module = True
OA->>ARF: "__enter__ → saves True in state, sets flag=False"
ARF->>M1: "forward → is_first_fp8_module()=False → bwd_update=False"
ARF->>M2: "forward → is_first_fp8_module()=False → bwd_update=False"
ARF->>OA: "__exit__ → forward_completed=True (flag stays False)"
OA->>OA: autocast_exit → reduce_and_update_fp8_tensors(fwd) ×1 ✓
Note over ARR: backward / recompute phase
ARR->>ARR: "__enter__ → restores is_first_fp8_module=True (from state)"
ARR->>RA: "__enter__ (_recompute=True) → depth++ but no flag reset"
RA->>M1: "recompute → is_first_fp8_module()=True → bwd_update=True"
RA->>M2: "recompute → is_first_fp8_module()=False → bwd_update=False"
RA->>ARR: "autocast __exit__ → monotonic merge keeps flag=False, NO fwd update"
ARR->>ARR: __exit__ → restores _previous_is_first_fp8_module
Note over M1: backward → reduce_and_update_fp8_tensors(bwd) ×1 ✓
Reviews (5): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile |
|
Hi @ksivaman and @ptrendx gentle ping when either of you has a chance. This PR has been open for about a week and is currently mergeable. It fixes duplicate FP8 global state updates under activation checkpoint recomputation, with regression coverage for reentrant, non-reentrant, per-layer, and nested checkpoint paths. Could either of you please take a look, or point me to the current owner of the activation-recompute / FP8 state-management path? I’m happy to adjust or split the change if preferred. |
|
Hi @vthumbe1503 — I revised #3213 to cover nested-autocast ownership restoration and transactional recovery from original-forward, recompute-entry, and recompute-body exceptions. The updated candidate passes the existing 8 tests, 6 focused edge tests, and all 49 cases in the local checkpoint audit suite. The residual SM120 RTC cast-transpose failure is still reproducible with correct 1/1 ownership/update counts and is being treated separately in #3215. When convenient, could you please take another look at the revised ownership and rollback logic? |
The activation-checkpoint duplicate-update problem and its regression test scenarios were first diagnosed and addressed in NVIDIA#3213; this PR supersedes that approach by removing first-module ownership entirely. Co-authored-by: AlbertYang514 <201034045+AlbertYang514@users.noreply.github.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
|
@AlbertYang514 sorry for delayed response. I started reviewing this PR and I think this issue may be solved together with other issue, I need one or few days for investigation and will reach out to you soon. |
|
@pggPL |
|
@pggPL |
Signed-off-by: AlbertYang514 <201034045+AlbertYang514@users.noreply.github.com>
Signed-off-by: AlbertYang514 <201034045+AlbertYang514@users.noreply.github.com>
026036c to
aa415db
Compare
|
@pggPL |
for more information, see https://pre-commit.ci
Summary
This change fixes FP8 first-module ownership across activation-checkpoint forward and recompute. The checkpoint frame reserves ownership for the original forward and reuses the captured state during recompute, preventing duplicate FP8 update ownership while preserving the expected single update.
v2 edge-case handling
The revised candidate also covers three state-transition edges:
Ownership merging is monotonic (available may become consumed, but consumed is not restored to available from an older snapshot). The nested-autocast path explicitly reacquires quantization state after restoring the outer autocast state rather than relying on object identity.
Validation
Scope
This PR is limited to checkpoint/autocast state ownership and rollback. A residual SM120 RTC cast-transpose failure can still be reproduced with correct 1/1 ownership/update counts; its investigation and workaround belong to PR #3215 and are not part of this change.