{{ message }}
Repository navigation
Conversation
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
Contributor
Author
|
@pytorchbot label "release notes: inductor" cc @eellison @jansel @malfet — could you please take a look and approve the CI run when you get a chance? Thanks! |
jianzhi-1
reviewed
Oct 7, 2026
syerva-g
force-pushed
the
fix-198846-inductor-int-geometric
branch
from
October 14, 2026 18:28
c4df698 to
ee32bbc
Compare
Contributor
Author
…dtypes (pytorch#198846) In `torch._refs.geometric`, `torch.rand_like(self)` is called without specifying a floating-point `dtype`. Because `geometric` uses `ELEMENTWISE_TYPE_PROMOTION_KIND.DEFAULT`, an integer tensor `self` (`int64`, `int32`, `int16`, `int8`, `uint8`) preserves its integer dtype. When compiled with TorchInductor, `_rand_like` decomposes `torch.rand_like(self)` to `aten.rand(shape, dtype=self.dtype)`, which `replace_random` lowers to `inductor_prims.random(size, seed, 'rand').to(self.dtype)`. Casting uniform `[0, 1)` floating-point numbers to an integer dtype truncates every sample to `0`, causing `torch.floor(torch.log1p(-0) / math.log1p(-p)) + 1` to silently return all `1`s. Fix this by sampling `torch.rand_like(self, dtype=rand_dtype)` using `torch.get_default_dtype()` when `self.dtype` is an integer dtype, after which `@elementwise_type_promotion_wrapper` casts the result back to `self.dtype`. Fixes pytorch#198846
…eta xfail - Use a fixed torch.float32 for the uniform sample on integer dtypes (review feedback): matches the eager CUDA kernel (DiscreteDistributionType<scalar_t>::type is float for non-double dtypes) and inductor_prims.random (always float32), and is independent of torch.set_default_dtype(). - Remove the unittest.expectedFailure for TestCommon.test_python_ref_meta on integer dtypes in common_methods_invocations.py: the test now passes since _refs.geometric no longer calls rand_like on an integer tensor, which CI reported as 'Unexpected success'.
syerva-g
force-pushed
the
fix-198846-inductor-int-geometric
branch
2 times, most recently
from
October 21, 2026 13:26
ee32bbc to
dd32177
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #198846
Summary
In
torch._refs.geometric,torch.rand_like(self)is called without specifying a floating-pointdtype. BecausegeometricusesELEMENTWISE_TYPE_PROMOTION_KIND.DEFAULT, an integer tensorself(int64,int32,int16,int8,uint8) preserves its integer dtype.When compiled with TorchInductor,
_rand_likedecomposestorch.rand_like(self)toaten.rand(shape, dtype=self.dtype), whichreplace_randomlowers toinductor_prims.random(size, seed, 'rand').to(self.dtype). Casting uniform[0, 1)floating-point numbers to an integer dtype truncates every sample to0, causingtorch.floor(torch.log1p(-0) / math.log1p(-p)) + 1to silently return all1s.Fix
Sample
torch.rand_like(self, dtype=rand_dtype)usingtorch.get_default_dtype()whenself.dtypeis an integer dtype, after which@elementwise_type_promotion_wrappercasts the result back toself.dtype.Test Plan
pytest test/inductor/test_torchinductor.py -k test_geometric_integer_dtypescc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo