Skip to content

Backward kernels are always put on the default stream #7601

@ngimel

Description

@ngimel

Issue description

Streams in THC are thread local, so in backward, since autograd creates its own threads, kernels are always put on the default streams, and don't respect stream that was set previously.

Code example

import torch

a=torch.Tensor(128,512).cuda().uniform_()

model = torch.nn.Linear(512,512).cuda()

fwd_stream = torch.cuda.Stream()
bwd_stream = torch.cuda.Stream()


for i in range(3):
   with torch.cuda.stream(fwd_stream):
       out = model(a).sum()
   with torch.cuda.stream(bwd_stream):
       out.backward() #kernels are actually on the default stream
   a.detach()

Pytorch, current master

Metadata

Metadata

Assignees

Labels

featureA request for a proper, new feature.module: cudaRelated to torch.cuda, and CUDA support in generaltriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions