pytorch - 💡(How to fix) Fix [pipelining] Pipelines reuse recv buffer tensors and directly pass them to the stage, causing backward hooks on stage boundary activations to persist between steps

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

Attaching hooks to the activation tensors that double as the recv buffers of a pipeline cause the hooks to persist across subsequent backward passes. My understanding is that this is due to the recv buffers being persistent across pipeline steps, unlike normal activations in pipelined/non-pipelined models, which are destroyed and reinstantiated across steps. This leads to the attached hooks on these buffers accumulating. The recv buffers are affected by the hooks because they are directly passed on to the subsequent stage as an input tensor, which means the tensor instance of the activation is the same instance as the persistent recv buffer. In my mind there are 2 fixes, use separate tensors for the recv buffers and the stage input (clone the recv buffer before passing to the stage), or clear all hooks on the recv buffer after each step.

Fix Action

Fix / Workaround

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 52 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 256 On-line CPU(s) list: 0-255 Vendor ID: AuthenticAMD Model name: AMD EPYC 9555 64-Core Processor CPU family: 26 Model: 2 Thread(s) per core: 2 Core(s) per socket: 64 Socket(s): 2 Stepping: 1 Frequency boost: enabled CPU(s) scaling MHz: 55% CPU max MHz: 4410.8110 CPU min MHz: 1210.8110 BogoMIPS: 6391.45 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpuid_fault cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid cqm rdt_a avx512f avx512dq adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx_vnni avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid bus_lock_detect movdiri movdir64b overflow_recov succor smca avx512_vp2intersect flush_l1d debug_swap amd_lbr_pmc_freeze Virtualization: AMD-V L1d cache: 6 MiB (128 instances) L1i cache: 4 MiB (128 instances) L2 cache: 128 MiB (128 instances) L3 cache: 512 MiB (16 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-63,128-191 NUMA node1 CPU(s): 64-127,192-255 Vulnerability Gather data sampling: Not affected Vulnerability Ghostwrite: Not affected Vulnerability Indirect target selection: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Old microcode: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Mitigation; Reduced Speculation Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; PBRSB-eIBRS Not affected; BHI Not affected Vulnerability Srbds: Not affected Vulnerability Tsa: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Mitigation; IBPB before exit to userspace

Code Example

import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from torch.distributed.pipelining import Schedule1F1B, SplitPoint, pipeline

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(4, 4)
        self.fc2 = nn.Linear(4, 4)

    def forward(self, x):
        # Split after fc1. In the pipelined run, fc2 receives a pipeline
        # boundary activation from rank 0.
        return self.fc2(self.fc1(x))


def add_tensor_hook(module, fired_hook_ids, next_hook_id):
    def pre_hook(_module, inputs):
        x = inputs[0]
        hook_id = next_hook_id[0]
        next_hook_id[0] += 1

        # Registering a tensor hook from a module hook is common in debugging
        # and activation/gradient collection code.
        def tensor_hook(_grad):
            fired_hook_ids.append(hook_id)

        x.register_hook(tensor_hook)

    module.register_forward_pre_hook(pre_hook)


def run_normal_reference():
    model = Model()

    fired_hook_ids = []
    next_hook_id = [0]
    add_tensor_hook(model.fc2, fired_hook_ids, next_hook_id)

    print("normal non-pipelined run")
    for step in range(5):
        fired_hook_ids.clear()
        model.zero_grad(set_to_none=True)
        x = torch.randn(4, 4)
        target = torch.randn(4, 4)

        # Use the same number of microbatches as the pipelined run.
        loss = 0
        for x_mb, target_mb in zip(torch.tensor_split(x, 2), torch.tensor_split(target, 2)):
            loss = loss + F.mse_loss(model(x_mb), target_mb)
        loss.backward()

        print(f"  step {step}: hooks fired = {fired_hook_ids}")


def run_pipeline():
    dist.init_process_group("gloo")
    rank = dist.get_rank()

    try:
        if rank == 0:
            run_normal_reference()
        dist.barrier()

        model = Model()
        sample = torch.zeros(2, 4)

        pipe = pipeline(
            module=model,
            mb_args=(sample,),
            split_spec={"fc1": SplitPoint.END},
        )
        stage = pipe.build_stage(rank, torch.device("cpu"), None)
        schedule = Schedule1F1B(stage, n_microbatches=2, loss_fn=F.mse_loss)

        fired_hook_ids = []
        next_hook_id = [0]

        if rank == 1:
            # Find fc2 inside this rank's local pipeline stage and hook its
            # input. This input is the persistent recv buffer exposed as an
            # activation.
            for name, module in stage.submod.named_modules():
                if name == "fc2" or name.endswith(".fc2"):
                    add_tensor_hook(module, fired_hook_ids, next_hook_id)
                    break

        if rank == 0:
            print("\npipelined run")

        for step in range(5):
            fired_hook_ids.clear()
            x = torch.randn(4, 4)
            target = torch.randn(4, 4)

            if rank == 0:
                schedule.step(x, return_outputs=False)
            else:
                schedule.step(target=target, return_outputs=False)

            dist.barrier()
            if rank == 1:
                print(f"  step {step}: hooks fired = {fired_hook_ids}")
            dist.barrier()
    finally:
        dist.destroy_process_group()


if __name__ == "__main__":
    run_pipeline()

---

(pt) fyguan@beast:~/disk20/codex_pipelining_fix$ torchrun --nproc-per-node 2 pipelining_hook_accumulation_repro.py 
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] 
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] *****************************************
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. 
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] *****************************************
normal non-pipelined run
  step 0: hooks fired = [1, 0]
  step 1: hooks fired = [3, 2]
  step 2: hooks fired = [5, 4]
  step 3: hooks fired = [7, 6]
  step 4: hooks fired = [9, 8]
/mnt/disk20/user/fyguan/miniconda3/envs/pt/lib/python3.12/copyreg.py:99: FutureWarning: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead.
  return cls.__new__(cls, *args)
/mnt/disk20/user/fyguan/miniconda3/envs/pt/lib/python3.12/copyreg.py:99: FutureWarning: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead.
  return cls.__new__(cls, *args)

pipelined run
  step 0: hooks fired = [0, 1]
  step 1: hooks fired = [0, 2, 1, 3]
  step 2: hooks fired = [0, 2, 4, 1, 3, 5]
  step 3: hooks fired = [0, 2, 4, 6, 1, 3, 5, 7]
  step 4: hooks fired = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]

---

(pt) fyguan@beast:~/disk20/codex_pipelining_fix$ curl -sL https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py | python
Collecting environment information...
PyTorch version: 2.11.0+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.4 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: version 3.28.3
Libc version: glibc-2.39

Python version: 3.12.13 | packaged by conda-forge | (main, Mar  5 2026, 16:50:00) [GCC 14.3.0] (64-bit runtime)
Python platform: Linux-6.18.20-fyguan-x86_64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: 13.2.78
CUDA_MODULE_LOADING set to: 
GPU models and configuration: 
GPU 0: NVIDIA H200 NVL
GPU 1: NVIDIA H200 NVL
GPU 2: NVIDIA H200 NVL
GPU 3: NVIDIA H200 NVL

Nvidia driver version: 595.71.05
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  256
On-line CPU(s) list:                     0-255
Vendor ID:                               AuthenticAMD
Model name:                              AMD EPYC 9555 64-Core Processor
CPU family:                              26
Model:                                   2
Thread(s) per core:                      2
Core(s) per socket:                      64
Socket(s):                               2
Stepping:                                1
Frequency boost:                         enabled
CPU(s) scaling MHz:                      55%
CPU max MHz:                             4410.8110
CPU min MHz:                             1210.8110
BogoMIPS:                                6391.45
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpuid_fault cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid cqm rdt_a avx512f avx512dq adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx_vnni avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid bus_lock_detect movdiri movdir64b overflow_recov succor smca avx512_vp2intersect flush_l1d debug_swap amd_lbr_pmc_freeze
Virtualization:                          AMD-V
L1d cache:                               6 MiB (128 instances)
L1i cache:                               4 MiB (128 instances)
L2 cache:                                128 MiB (128 instances)
L3 cache:                                512 MiB (16 instances)
NUMA node(s):                            2
NUMA node0 CPU(s):                       0-63,128-191
NUMA node1 CPU(s):                       64-127,192-255
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Mitigation; Reduced Speculation
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB before exit to userspace

Versions of relevant libraries:
[pip3] numpy==2.4.3
[pip3] nvidia-cublas==13.1.0.3
[pip3] nvidia-cuda-cupti==13.0.85
[pip3] nvidia-cuda-nvrtc==13.0.88
[pip3] nvidia-cuda-runtime==13.0.96
[pip3] nvidia-cudnn-cu13==9.19.0.56
[pip3] nvidia-cufft==12.0.0.61
[pip3] nvidia-curand==10.4.0.35
[pip3] nvidia-cusolver==12.0.4.66
[pip3] nvidia-cusparse==12.6.3.3
[pip3] nvidia-cusparselt-cu13==0.8.0
[pip3] nvidia-nccl-cu13==2.28.9
[pip3] nvidia-nvjitlink==13.0.88
[pip3] nvidia-nvtx==13.0.85
[pip3] torch==2.11.0+cu130
[pip3] torchaudio==2.11.0+cu130
[pip3] torchvision==0.26.0+cu130
[pip3] triton==3.6.0
[conda] cuda-nvrtc                 13.2.51          hecca717_0            conda-forge
[conda] libcufft                   12.2.0.37        hecca717_0            conda-forge
[conda] numpy                      2.3.5            pypi_0                pypi
[conda] nvidia-cublas              13.1.0.3         pypi_0                pypi
[conda] nvidia-cuda-cupti          13.0.85          pypi_0                pypi
[conda] nvidia-cuda-nvrtc          13.0.88          pypi_0                pypi
[conda] nvidia-cuda-runtime        13.0.96          pypi_0                pypi
[conda] nvidia-cudnn-cu13          9.19.0.56        pypi_0                pypi
[conda] nvidia-cufft               12.0.0.61        pypi_0                pypi
[conda] nvidia-curand              10.4.0.35        pypi_0                pypi
[conda] nvidia-cusolver            12.0.4.66        pypi_0                pypi
[conda] nvidia-cusparse            12.6.3.3         pypi_0                pypi
[conda] nvidia-cusparselt-cu13     0.8.0            pypi_0                pypi
[conda] nvidia-nccl-cu13           2.28.9           pypi_0                pypi
[conda] nvidia-nvjitlink           13.0.88          pypi_0                pypi
[conda] nvidia-nvtx                13.0.85          pypi_0                pypi
[conda] torch                      2.11.0+cu130     pypi_0                pypi
[conda] torchaudio                 2.11.0+cu130     pypi_0                pypi
[conda] torchvision                0.26.0+cu130     pypi_0                pypi
[conda] triton                     3.6.0            pypi_0                pypi
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

Attaching hooks to the activation tensors that double as the recv buffers of a pipeline cause the hooks to persist across subsequent backward passes. My understanding is that this is due to the recv buffers being persistent across pipeline steps, unlike normal activations in pipelined/non-pipelined models, which are destroyed and reinstantiated across steps. This leads to the attached hooks on these buffers accumulating. The recv buffers are affected by the hooks because they are directly passed on to the subsequent stage as an input tensor, which means the tensor instance of the activation is the same instance as the persistent recv buffer. In my mind there are 2 fixes, use separate tensors for the recv buffers and the stage input (clone the recv buffer before passing to the stage), or clear all hooks on the recv buffer after each step.

My expected behavior for attaching hooks to these stage-boundary activations while pipelining would be that they behave the same way as hooks on the same points when not pipelining (destroyed after each step). The repro code below shows that this is not the case; each subsequent step causes additional tensor backward hooks to be attached by the module forward hook while the previous ones are not destroyed, causing the number of hooks triggering to increase instead of staying constant. I am using a modified pt 2.11 install, but the likely locations for the separate tensors/cloning fix (https://github.com/pytorch/pytorch/blob/696ebd85f523f61ec64846ae78e99bc9d93b8e42/torch/distributed/pipelining/stage.py#L633) and hook clearing fix (https://github.com/pytorch/pytorch/blob/696ebd85f523f61ec64846ae78e99bc9d93b8e42/torch/distributed/pipelining/stage.py#L552) are the same.

<details> <summary> Repro code: pipelining_hook_accumulation_repro.py (written by Codex) </summary>

Run on CPU with $ torchrun --nproc-per-node 2 pipelining_hook_accumulation_repro.py

import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from torch.distributed.pipelining import Schedule1F1B, SplitPoint, pipeline

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(4, 4)
        self.fc2 = nn.Linear(4, 4)

    def forward(self, x):
        # Split after fc1. In the pipelined run, fc2 receives a pipeline
        # boundary activation from rank 0.
        return self.fc2(self.fc1(x))


def add_tensor_hook(module, fired_hook_ids, next_hook_id):
    def pre_hook(_module, inputs):
        x = inputs[0]
        hook_id = next_hook_id[0]
        next_hook_id[0] += 1

        # Registering a tensor hook from a module hook is common in debugging
        # and activation/gradient collection code.
        def tensor_hook(_grad):
            fired_hook_ids.append(hook_id)

        x.register_hook(tensor_hook)

    module.register_forward_pre_hook(pre_hook)


def run_normal_reference():
    model = Model()

    fired_hook_ids = []
    next_hook_id = [0]
    add_tensor_hook(model.fc2, fired_hook_ids, next_hook_id)

    print("normal non-pipelined run")
    for step in range(5):
        fired_hook_ids.clear()
        model.zero_grad(set_to_none=True)
        x = torch.randn(4, 4)
        target = torch.randn(4, 4)

        # Use the same number of microbatches as the pipelined run.
        loss = 0
        for x_mb, target_mb in zip(torch.tensor_split(x, 2), torch.tensor_split(target, 2)):
            loss = loss + F.mse_loss(model(x_mb), target_mb)
        loss.backward()

        print(f"  step {step}: hooks fired = {fired_hook_ids}")


def run_pipeline():
    dist.init_process_group("gloo")
    rank = dist.get_rank()

    try:
        if rank == 0:
            run_normal_reference()
        dist.barrier()

        model = Model()
        sample = torch.zeros(2, 4)

        pipe = pipeline(
            module=model,
            mb_args=(sample,),
            split_spec={"fc1": SplitPoint.END},
        )
        stage = pipe.build_stage(rank, torch.device("cpu"), None)
        schedule = Schedule1F1B(stage, n_microbatches=2, loss_fn=F.mse_loss)

        fired_hook_ids = []
        next_hook_id = [0]

        if rank == 1:
            # Find fc2 inside this rank's local pipeline stage and hook its
            # input. This input is the persistent recv buffer exposed as an
            # activation.
            for name, module in stage.submod.named_modules():
                if name == "fc2" or name.endswith(".fc2"):
                    add_tensor_hook(module, fired_hook_ids, next_hook_id)
                    break

        if rank == 0:
            print("\npipelined run")

        for step in range(5):
            fired_hook_ids.clear()
            x = torch.randn(4, 4)
            target = torch.randn(4, 4)

            if rank == 0:
                schedule.step(x, return_outputs=False)
            else:
                schedule.step(target=target, return_outputs=False)

            dist.barrier()
            if rank == 1:
                print(f"  step {step}: hooks fired = {fired_hook_ids}")
            dist.barrier()
    finally:
        dist.destroy_process_group()


if __name__ == "__main__":
    run_pipeline()
</details> <details> <summary> Output </summary>
(pt) fyguan@beast:~/disk20/codex_pipelining_fix$ torchrun --nproc-per-node 2 pipelining_hook_accumulation_repro.py 
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] 
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] *****************************************
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. 
W0527 06:44:59.065000 366351 site-packages/torch/distributed/run.py:851] *****************************************
normal non-pipelined run
  step 0: hooks fired = [1, 0]
  step 1: hooks fired = [3, 2]
  step 2: hooks fired = [5, 4]
  step 3: hooks fired = [7, 6]
  step 4: hooks fired = [9, 8]
/mnt/disk20/user/fyguan/miniconda3/envs/pt/lib/python3.12/copyreg.py:99: FutureWarning: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead.
  return cls.__new__(cls, *args)
/mnt/disk20/user/fyguan/miniconda3/envs/pt/lib/python3.12/copyreg.py:99: FutureWarning: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead.
  return cls.__new__(cls, *args)

pipelined run
  step 0: hooks fired = [0, 1]
  step 1: hooks fired = [0, 2, 1, 3]
  step 2: hooks fired = [0, 2, 4, 1, 3, 5]
  step 3: hooks fired = [0, 2, 4, 6, 1, 3, 5, 7]
  step 4: hooks fired = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
</details> <details> <summary> Versions </summary>
(pt) fyguan@beast:~/disk20/codex_pipelining_fix$ curl -sL https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py | python
Collecting environment information...
PyTorch version: 2.11.0+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.4 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: version 3.28.3
Libc version: glibc-2.39

Python version: 3.12.13 | packaged by conda-forge | (main, Mar  5 2026, 16:50:00) [GCC 14.3.0] (64-bit runtime)
Python platform: Linux-6.18.20-fyguan-x86_64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: 13.2.78
CUDA_MODULE_LOADING set to: 
GPU models and configuration: 
GPU 0: NVIDIA H200 NVL
GPU 1: NVIDIA H200 NVL
GPU 2: NVIDIA H200 NVL
GPU 3: NVIDIA H200 NVL

Nvidia driver version: 595.71.05
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  256
On-line CPU(s) list:                     0-255
Vendor ID:                               AuthenticAMD
Model name:                              AMD EPYC 9555 64-Core Processor
CPU family:                              26
Model:                                   2
Thread(s) per core:                      2
Core(s) per socket:                      64
Socket(s):                               2
Stepping:                                1
Frequency boost:                         enabled
CPU(s) scaling MHz:                      55%
CPU max MHz:                             4410.8110
CPU min MHz:                             1210.8110
BogoMIPS:                                6391.45
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpuid_fault cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid cqm rdt_a avx512f avx512dq adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx_vnni avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid bus_lock_detect movdiri movdir64b overflow_recov succor smca avx512_vp2intersect flush_l1d debug_swap amd_lbr_pmc_freeze
Virtualization:                          AMD-V
L1d cache:                               6 MiB (128 instances)
L1i cache:                               4 MiB (128 instances)
L2 cache:                                128 MiB (128 instances)
L3 cache:                                512 MiB (16 instances)
NUMA node(s):                            2
NUMA node0 CPU(s):                       0-63,128-191
NUMA node1 CPU(s):                       64-127,192-255
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Mitigation; Reduced Speculation
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB before exit to userspace

Versions of relevant libraries:
[pip3] numpy==2.4.3
[pip3] nvidia-cublas==13.1.0.3
[pip3] nvidia-cuda-cupti==13.0.85
[pip3] nvidia-cuda-nvrtc==13.0.88
[pip3] nvidia-cuda-runtime==13.0.96
[pip3] nvidia-cudnn-cu13==9.19.0.56
[pip3] nvidia-cufft==12.0.0.61
[pip3] nvidia-curand==10.4.0.35
[pip3] nvidia-cusolver==12.0.4.66
[pip3] nvidia-cusparse==12.6.3.3
[pip3] nvidia-cusparselt-cu13==0.8.0
[pip3] nvidia-nccl-cu13==2.28.9
[pip3] nvidia-nvjitlink==13.0.88
[pip3] nvidia-nvtx==13.0.85
[pip3] torch==2.11.0+cu130
[pip3] torchaudio==2.11.0+cu130
[pip3] torchvision==0.26.0+cu130
[pip3] triton==3.6.0
[conda] cuda-nvrtc                 13.2.51          hecca717_0            conda-forge
[conda] libcufft                   12.2.0.37        hecca717_0            conda-forge
[conda] numpy                      2.3.5            pypi_0                pypi
[conda] nvidia-cublas              13.1.0.3         pypi_0                pypi
[conda] nvidia-cuda-cupti          13.0.85          pypi_0                pypi
[conda] nvidia-cuda-nvrtc          13.0.88          pypi_0                pypi
[conda] nvidia-cuda-runtime        13.0.96          pypi_0                pypi
[conda] nvidia-cudnn-cu13          9.19.0.56        pypi_0                pypi
[conda] nvidia-cufft               12.0.0.61        pypi_0                pypi
[conda] nvidia-curand              10.4.0.35        pypi_0                pypi
[conda] nvidia-cusolver            12.0.4.66        pypi_0                pypi
[conda] nvidia-cusparse            12.6.3.3         pypi_0                pypi
[conda] nvidia-cusparselt-cu13     0.8.0            pypi_0                pypi
[conda] nvidia-nccl-cu13           2.28.9           pypi_0                pypi
[conda] nvidia-nvjitlink           13.0.88          pypi_0                pypi
[conda] nvidia-nvtx                13.0.85          pypi_0                pypi
[conda] torch                      2.11.0+cu130     pypi_0                pypi
[conda] torchaudio                 2.11.0+cu130     pypi_0                pypi
[conda] torchvision                0.26.0+cu130     pypi_0                pypi
[conda] triton                     3.6.0            pypi_0                pypi
</details>

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix [pipelining] Pipelines reuse recv buffer tensors and directly pass them to the stage, causing backward hooks on stage boundary activations to persist between steps