SobolEngine.draw
does not respect the default dtype
and always uses the passed in dtype (defaulted to float32)
#126478
Labels
module: python frontend
For issues relating to PyTorch's Python frontend
module: random
Related to random number generation in PyTorch (rng generator)
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
馃悰 Describe the bug
Issue description
If the
SobolEngine
is initialized aftertorch.set_default_type(torch.float64)
,SobolEngine.draw
ignoresdtype
argument and instead returns samples with the default dtype .Works as expected with
torch.set_default_type(torch.float32)
Still works as expected if we update the default dtype but keep the previous
SobolEngine
instancedtype
is ignored ifSobolEngine
is initialized aftertorch.set_default_type(torch.float64)
Expected behavior
SobolEngine(...).draw(n=n, dtype=dtype)
should always produce samples with the provideddtype
.Other proposed improvements
Currently, the
dtype
argument defaults totorch.float32
.We can update default argument to
None
and produce samples withdtype=torch.get_default_dtype()
.Versions
PyTorch version: 2.3.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: macOS 14.4.1 (arm64)
GCC version: Could not collect
Clang version: 15.0.0 (clang-1500.3.9.4)
CMake version: Could not collect
Libc version: N/A
Python version: 3.10.14 (main, May 6 2024, 14:42:37) [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-14.4.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Apple M1 Pro
Versions of relevant libraries:
[pip3] torch==2.3.0
[conda] pytorch 2.3.0 py3.10_0 pytorch
cc @pbelevich @albanD
The text was updated successfully, but these errors were encountered: