Skip to content

Commit 35348da

Browse files
Rasmus Diederichsenfacebook-github-bot
Rasmus Diederichsen
authored andcommitted
WIP: Include note on cudnn determinism in each function backed by cudnn (pytorch#11434)
Summary: Ping ezyang This addresses your comment in ROCm#114. Strangely, when running the doc build (`make html`) none of my changes are actually showing, could you point out what I'm doing wrong? Once pytorch#11329 is merged it might make sense to link to the reproducibility note everywhere. Pull Request resolved: pytorch#11434 Differential Revision: D9751208 Pulled By: ezyang fbshipit-source-id: cc672472449564ff099323c39603e8ff2b2d35c9
1 parent 54107ae commit 35348da

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

docs/source/cudnn_deterministic.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. note::
2+
3+
In some circumstances when using the CUDA backend with CuDNN, this operator
4+
may select a nondeterministic algorithm to increase performance. If this is
5+
undesirable, you can try to make the operation deterministic (potentially at
6+
a performance cost) by setting ``torch.backends.cudnn.deterministic =
7+
True``.

torch/nn/functional.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def legacy_get_enum(size_average, reduce, emit_warning=True):
6767
6868
See :class:`~torch.nn.Conv1d` for details and output shape.
6969
70+
.. include:: cudnn_deterministic.rst
71+
7072
Args:
7173
input: input tensor of shape :math:`(\text{minibatch} \times \text{in\_channels} \times iW)`
7274
weight: filters of shape :math:`(\text{out\_channels} \times \frac{\text{in\_channels}}{\text{groups}} \times kW)`
@@ -95,6 +97,8 @@ def legacy_get_enum(size_average, reduce, emit_warning=True):
9597
9698
See :class:`~torch.nn.Conv2d` for details and output shape.
9799
100+
.. include:: cudnn_deterministic.rst
101+
98102
Args:
99103
input: input tensor of shape :math:`(\text{minibatch} \times \text{in\_channels} \times iH \times iW)`
100104
weight: filters of shape :math:`(\text{out\_channels} \times \frac{\text{in\_channels}}{\text{groups}} \times kH \times kW)`
@@ -124,6 +128,8 @@ def legacy_get_enum(size_average, reduce, emit_warning=True):
124128
125129
See :class:`~torch.nn.Conv3d` for details and output shape.
126130
131+
.. include:: cudnn_deterministic.rst
132+
127133
Args:
128134
input: input tensor of shape :math:`(\text{minibatch} \times \text{in\_channels} \times iT \times iH \times iW)`
129135
weight: filters of shape :math:`(\text{out\_channels} \times \frac{\text{in\_channels}}{\text{groups}} \times kT \times kH \times kW)`
@@ -152,6 +158,8 @@ def legacy_get_enum(size_average, reduce, emit_warning=True):
152158
153159
See :class:`~torch.nn.ConvTranspose1d` for details and output shape.
154160
161+
.. include:: cudnn_deterministic.rst
162+
155163
Args:
156164
input: input tensor of shape :math:`(\text{minibatch} \times \text{in\_channels} \times iW)`
157165
weight: filters of shape :math:`(\text{in\_channels} \times \frac{\text{out\_channels}}{\text{groups}} \times kW)`
@@ -183,6 +191,8 @@ def legacy_get_enum(size_average, reduce, emit_warning=True):
183191
184192
See :class:`~torch.nn.ConvTranspose2d` for details and output shape.
185193
194+
.. include:: cudnn_deterministic.rst
195+
186196
Args:
187197
input: input tensor of shape :math:`(\text{minibatch} \times \text{in\_channels} \times iH \times iW)`
188198
weight: filters of shape :math:`(\text{in\_channels} \times \frac{\text{out\_channels}}{\text{groups}} \times kH \times kW)`
@@ -216,6 +226,8 @@ def legacy_get_enum(size_average, reduce, emit_warning=True):
216226
217227
See :class:`~torch.nn.ConvTranspose3d` for details and output shape.
218228
229+
.. include:: cudnn_deterministic.rst
230+
219231
Args:
220232
input: input tensor of shape :math:`(\text{minibatch} \times \text{in\_channels} \times iT \times iH \times iW)`
221233
weight: filters of shape :math:`(\text{in\_channels} \times \frac{\text{out\_channels}}{\text{groups}} \times kT \times kH \times kW)`
@@ -1438,6 +1450,8 @@ def ctc_loss(log_probs, targets, input_lengths, target_lengths, blank=0,
14381450
14391451
See :class:`~torch.nn.CTCLoss` for details.
14401452
1453+
.. include:: cudnn_deterministic.rst
1454+
14411455
Args:
14421456
log_probs: :math:`(T, N, C)` where `C = number of characters in alphabet including blank`,
14431457
`T = input length`, and `N = batch size`.

torch/nn/modules/conv.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class Conv1d(_ConvNd):
120120
a depthwise convolution with a depthwise multiplier `K`, can be constructed by arguments
121121
:math:`(C_\text{in}=C_{in}, C_\text{out}=C_{in} \times K, ..., \text{groups}=C_{in})`.
122122
123+
.. include:: cudnn_deterministic.rst
124+
123125
Args:
124126
in_channels (int): Number of channels in the input image
125127
out_channels (int): Number of channels produced by the convolution
@@ -243,6 +245,8 @@ class Conv2d(_ConvNd):
243245
a depthwise convolution with a depthwise multiplier `K`, can be constructed by arguments
244246
:math:`(in\_channels=C_{in}, out\_channels=C_{in} \times K, ..., groups=C_{in})`.
245247
248+
.. include:: cudnn_deterministic.rst
249+
246250
Args:
247251
in_channels (int): Number of channels in the input image
248252
out_channels (int): Number of channels produced by the convolution
@@ -366,6 +370,8 @@ class Conv3d(_ConvNd):
366370
a depthwise convolution with a depthwise multiplier `K`, can be constructed by arguments
367371
:math:`(in\_channels=C_{in}, out\_channels=C_{in} \times K, ..., groups=C_{in})`.
368372
373+
.. include:: cudnn_deterministic.rst
374+
369375
Args:
370376
in_channels (int): Number of channels in the input image
371377
out_channels (int): Number of channels produced by the convolution
@@ -527,6 +533,8 @@ class ConvTranspose1d(_ConvTransposeMixin, _ConvNd):
527533
that :attr:`output_padding` is only used to find output shape, but does
528534
not actually add zero-padding to output.
529535
536+
.. include:: cudnn_deterministic.rst
537+
530538
Args:
531539
in_channels (int): Number of channels in the input image
532540
out_channels (int): Number of channels produced by the convolution
@@ -637,6 +645,8 @@ class ConvTranspose2d(_ConvTransposeMixin, _ConvNd):
637645
that :attr:`output_padding` is only used to find output shape, but does
638646
not actually add zero-padding to output.
639647
648+
.. include:: cudnn_deterministic.rst
649+
640650
Args:
641651
in_channels (int): Number of channels in the input image
642652
out_channels (int): Number of channels produced by the convolution
@@ -777,6 +787,8 @@ class ConvTranspose3d(_ConvTransposeMixin, _ConvNd):
777787
that :attr:`output_padding` is only used to find output shape, but does
778788
not actually add zero-padding to output.
779789
790+
.. include:: cudnn_deterministic.rst
791+
780792
Args:
781793
in_channels (int): Number of channels in the input image
782794
out_channels (int): Number of channels produced by the convolution

torch/nn/modules/loss.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,11 @@ class CTCLoss(_Loss):
11771177
dtype :attr:`torch.int32`.
11781178
11791179
The regular implementation uses the (more common in PyTorch) `torch.long` dtype.
1180+
1181+
1182+
.. include:: cudnn_deterministic.rst
1183+
1184+
11801185
"""
11811186

11821187
def __init__(self, blank=0, reduction='elementwise_mean'):

0 commit comments

Comments
 (0)