[fix] Dropout2d-3d no-batch-dim#69885
Conversation
CI Flow Status⚛️ CI FlowRuleset - Version:
You can add a comment to the PR and tag @pytorchbot with the following commands: # ciflow rerun, "ciflow/default" will always be added automatically
@pytorchbot ciflow rerun
# ciflow rerun with additional labels "-l <ciflow/label_name>", which is equivalent to adding these labels manually and trigger the rerun
@pytorchbot ciflow rerun -l ciflow/scheduled -l ciflow/slowFor more information, please take a look at the CI Flow Wiki. |
|
Looks like JIT tests are also failing. Will have a look. |
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 546af0d (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
|
@jbschlosser I couldn't find a test for |
One option is to input a tensor that is known to be fully non-zero and check that the output only has entire channels zeroed out (i.e. anywhere a zero is present, the entire channel should also be zero). |
| for b, c in product(range(B), range(C)): | ||
| self.assertTrue(result[b, c].count_nonzero() in (0, channel_numel)) | ||
|
|
||
| @expectedFailureXLA # seems like freeze_rng_state is not honoured by XLA |
| supports_out=False, | ||
| sample_inputs_func=partial(sample_inputs_dropout, train=True, min_input_dim=2), | ||
| # As per the docs, valid input dims are (4, 5) | ||
| sample_inputs_func=partial(sample_inputs_dropout, train=True, valid_input_dim=(4, 5)), |
There was a problem hiding this comment.
This is OpInfo entry for feature_alpha_dropout.
There was a problem hiding this comment.
This is good for the purposes of this PR, but eventually FeatureAlphaDropout should be documented and tested to work on dims besides 4 and 5 (see #69960 (comment))
| supports_out=False, | ||
| sample_inputs_func=partial(sample_inputs_dropout, min_input_dim=2), | ||
| # As per the docs, valid input dims are (3, 4) | ||
| sample_inputs_func=partial(sample_inputs_dropout, valid_input_dim=(3, 4)), |
There was a problem hiding this comment.
This is OpInfo entry for dropout2d.
|
@jbschlosser has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Hey @kshitij12345, FYI there's a whole bunch of internal breakage from this change. It seems there are people using dropout2d with 2D inputs expecting normal dropout to occur, which does happen to be the case. There may also be people passing 3D inputs expecting something, and redefining 3D to mean no-batch-dim input would silently break them, which is worse than loudly breaking them. So I propose a tweak to this PR to handle this case:
(do the analogous thing for Dropout3d / 5D input as well) wdyt about this? |
|
Wouldn't this be weird? The support for no-batch-dim for these two modules was added in https://pytorch.org/docs/1.10.0/generated/torch.nn.Dropout2d.html?highlight=dropout2d#torch.nn.Dropout2d |
|
@jbschlosser as discussed offline, I have updated the PR to be less strict. |
jbschlosser
left a comment
There was a problem hiding this comment.
Thanks for the update! Minor comments below for warning wording to make deprecations actionable
| warn_msg = ("dropout3d: 3-D input is being deprecated for Dropout3d." | ||
| " Look at the docs for correct input shapes and usage.") |
There was a problem hiding this comment.
nit: deprecation should be actionable to remove the warning - in this case, switching to F.dropout is the way to go:
Received a 3D input to dropout3d, which is deprecated and will result in an error in a future release. To retain the behavior and silence this warning, please use dropout instead. Note that dropout3d exists to provide channel-wise dropout on inputs with 3 spatial dimensions, a channel dimension, and an optional batch dimension (i.e. 4D or 5D inputs).
| warn_msg = ("dropout2d: 2-D input is being deprecated for Dropout2d." | ||
| " Look at the docs for correct input shapes and usage.") |
There was a problem hiding this comment.
Wording suggestion as below:
Received a 2D input to dropout2d, which is deprecated and will result in an error in a future release. To retain the behavior and silence this warning, please use dropout instead. Note that dropout2d exists to provide channel-wise dropout on inputs with 2 spatial dimensions, a channel dimension, and an optional batch dimension (i.e. 3D or 4D inputs).
|
@jbschlosser has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
jbschlosser
left a comment
There was a problem hiding this comment.
Thanks for the update! One minor thing and we can get this in :)
| assert inp_dim in (2, 3, 4), msg | ||
| if inp_dim == 2: | ||
| if inp_dim not in (3, 4): | ||
| warn_msg = ("dropout2d: Received a 2D input to dropout2d, which is deprecated " |
There was a problem hiding this comment.
nit: warning msg should correctly specify the dimension of the input now; here it's hardcoded to 2D
There was a problem hiding this comment.
Sorry. Thanks :)
| assert inp_dim in (3, 4, 5), msg | ||
| if inp_dim == 3: | ||
| if inp_dim not in (4, 5): | ||
| warn_msg = ("dropout3d: Received a 3D input to dropout3d, which is deprecated " |
|
@jbschlosser has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Hey kshitij12345. |
Summary: Fixes pytorch/pytorch#69801 TODO: * [x] Update C++ API cc albanD mruberry jbschlosser walterddr kshitij12345 Pull Request resolved: pytorch/pytorch#69885 Reviewed By: mruberry Differential Revision: D33175470 Pulled By: jbschlosser fbshipit-source-id: c9d7d9e0f59ba290a0157725c338a345f3d58b9f (cherry picked from commit 7e4271a)
Summary: Fixes pytorch/pytorch#69801 TODO: * [x] Update C++ API cc albanD mruberry jbschlosser walterddr kshitij12345 Pull Request resolved: pytorch/pytorch#69885 Reviewed By: mruberry Differential Revision: D33175470 Pulled By: jbschlosser fbshipit-source-id: c9d7d9e0f59ba290a0157725c338a345f3d58b9f (cherry picked from commit 7e4271a)
Summary: Fixes pytorch/pytorch#69801 TODO: * [x] Update C++ API cc albanD mruberry jbschlosser walterddr kshitij12345 Pull Request resolved: pytorch/pytorch#69885 Reviewed By: mruberry Differential Revision: D33175470 Pulled By: jbschlosser fbshipit-source-id: c9d7d9e0f59ba290a0157725c338a345f3d58b9f (cherry picked from commit 7e4271a)
Summary: Fixes pytorch/pytorch#69801 TODO: * [x] Update C++ API cc albanD mruberry jbschlosser walterddr kshitij12345 Pull Request resolved: pytorch/pytorch#69885 Reviewed By: mruberry Differential Revision: D33175470 Pulled By: jbschlosser fbshipit-source-id: c9d7d9e0f59ba290a0157725c338a345f3d58b9f (cherry picked from commit 7e4271a)
Summary: Fixes pytorch#69801 TODO: * [x] Update C++ API cc albanD mruberry jbschlosser walterddr kshitij12345 Pull Request resolved: pytorch#69885 Reviewed By: mruberry Differential Revision: D33175470 Pulled By: jbschlosser fbshipit-source-id: c9d7d9e0f59ba290a0157725c338a345f3d58b9f (cherry picked from commit 7e4271a)
Fixes #69801
TODO:
cc @albanD @mruberry @jbschlosser @walterddr @kshitij12345