Repository: pytorch
Issue: Dynamo'd `test_mixed_device_dtype` needs higher tolerances for SGD, RAdam and RMSProp 
Labels: module: optimizer,module: tests,triaged,oncall: pt2,module: dynamo

### 🐛 Describe the bug

I had to increase the tolerances 10x for SGD, RMSProp for the PYTORCH_TEST_WITH_DYNAMO tests, which is strange because compared to other optimizers, they do NOT have more ops.

Specifically, what the test tests is that the foreach implementation with mixed dtype parameters do NOT differ too much from the for-loop implementations on the same parameters. In eager, the test passes with the tolerances defined within the test. However, with dynamo, those are not enough. This may just be numerical differences, but raising an issue just in case it's something more sinister.

For Adamax, I had to up the tolerance from 

### Error logs

When using the default tolerances, the tests fail with the following logs:
```
======================================================================
FAIL: test_mixed_device_dtype_impl_foreach_RMSprop_cuda_float32 (__main__.TestOptimRenewedCUDA)
Similar in essence to _test_derived_optimizers above. The main difference is that
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_utils.py", line 2674, in wrapper
    method(*args, **kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_utils.py", line 2674, in wrapper
    method(*args, **kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_device_type.py", line 416, in instantiated_test
    result = test(self, **param_kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_optimizers.py", line 172, in test_wrapper
    return test(*args, **kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_device_type.py", line 1110, in only_fn
    return fn(slf, *args, **kwargs)
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 147, in test_mixed_device_dtype
    torch.rand(2, 3, dtype=torch.float64, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 148, in resume_in_test_mixed_device_dtype_at_147
    torch.rand(2, 3, dtype=torch.float32, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 149, in resume_in_test_mixed_device_dtype_at_148
    torch.rand(2, 3, dtype=torch.float16, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 150, in resume_in_test_mixed_device_dtype_at_149
    torch.rand(2, 3, dtype=torch.bfloat16, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 151, in resume_in_test_mixed_device_dtype_at_150
    torch.rand(2, 3, dtype=torch.float64, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 152, in resume_in_test_mixed_device_dtype_at_151
    torch.rand(2, 3, dtype=torch.float32, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 153, in resume_in_test_mixed_device_dtype_at_152
    torch.rand(2, 3, dtype=torch.float16, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 154, in resume_in_test_mixed_device_dtype_at_153
    torch.rand(2, 3, dtype=torch.bfloat16, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 196, in resume_in_test_mixed_device_dtype_at_154
    self.assertEqual(og_p, new_p, rtol=rtol, atol=atol)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_utils.py", line 3499, in assertEqual
    raise error_metas.pop()[0].to_error(
AssertionError: Tensor-likes are not close!

Mismatched elements: 1 / 6 (16.7%)
Greatest absolute difference: 0.000335693359375 at index (1, 0) (up to 5e-05 allowed)
Greatest relative difference: 0.009490966796875 at index (1, 0) (up to 0.005 allowed)

To execute this test, run the following from the base repo dir:
    PYTORCH_TEST_WITH_DYNAMO=1 python test/test_optim.py -k test_mixed_device_dtype_impl_foreach_RMSprop_cuda_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

======================================================================
FAIL: test_mixed_device_dtype_impl_foreach_SGD_cuda_float32 (__main__.TestOptimRenewedCUDA)
Similar in essence to _test_derived_optimizers above. The main difference is that
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_utils.py", line 2674, in wrapper
    method(*args, **kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_utils.py", line 2674, in wrapper
    method(*args, **kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_device_type.py", line 416, in instantiated_test
    result = test(self, **param_kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_optimizers.py", line 172, in test_wrapper
    return test(*args, **kwargs)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_device_type.py", line 1110, in only_fn
    return fn(slf, *args, **kwargs)
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 147, in test_mixed_device_dtype
    torch.rand(2, 3, dtype=torch.float64, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 148, in resume_in_test_mixed_device_dtype_at_147
    torch.rand(2, 3, dtype=torch.float32, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 149, in resume_in_test_mixed_device_dtype_at_148
    torch.rand(2, 3, dtype=torch.float16, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 150, in resume_in_test_mixed_device_dtype_at_149
    torch.rand(2, 3, dtype=torch.bfloat16, device='cuda:0', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 151, in resume_in_test_mixed_device_dtype_at_150
    torch.rand(2, 3, dtype=torch.float64, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 152, in resume_in_test_mixed_device_dtype_at_151
    torch.rand(2, 3, dtype=torch.float32, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 153, in resume_in_test_mixed_device_dtype_at_152
    torch.rand(2, 3, dtype=torch.float16, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 154, in resume_in_test_mixed_device_dtype_at_153
    torch.rand(2, 3, dtype=torch.bfloat16, device='cuda:1', requires_grad=True),
  File "/data/users/janeyx/pytorch/test/test_optim.py", line 196, in resume_in_test_mixed_device_dtype_at_154
    self.assertEqual(og_p, new_p, rtol=rtol, atol=atol)
  File "/data/users/janeyx/pytorch/torch/testing/_internal/common_utils.py", line 3499, in assertEqual
    raise error_metas.pop()[0].to_error(
AssertionError: Tensor-likes are not close!

Mismatched elements: 1 / 6 (16.7%)
Greatest absolute difference: 0.0003662109375 at index (1, 0) (up to 5e-05 allowed)
Greatest relative difference: 0.005992889404296875 at index (1, 0) (up to 0.005 allowed)

To execute this test, run the following from the base repo dir:
    PYTORCH_TEST_WITH_DYNAMO=1 python test/test_optim.py -k test_mixed_device_dtype_impl_foreach_SGD_cuda_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

----------------------------------------------------------------------
Ran 44 tests in 100.133s

FAILED (failures=2, skipped=22)
```

### Minified repro

`PYTORCH_TEST_WITH_DYNAMO=0 python test/test_optim.py -k test_mixed_device_dtype_impl_foreach_RMSProp -k test_mixed_device_dtype_impl_foreach_SGD`

### Versions

on main

cc @vincentqb @jbschlosser @albanD @crcrpar @mruberry @ZainRizvi @ezyang @msaroufim @wconstab @bdhirsh @anijain2305 @zou3519 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng @mlazos