Repository: pytorch
Issue: Got "KeyError: 'classname'" while runing pytorch unit tests
Labels: triaged,module: testing

### 🐛 Describe the bug

See below job logs

```python
test_ops.py::TestCommonCUDA::test_out___rsub___cuda_float32 PASSED [0.0027s] [ 14%]
test_ops.py::TestCommonCUDA::test_out__chunk_cat_cuda_float32 FAILED [0.5560s] [ 14%]
test_ops.py::TestCommonCUDA::test_out__refs__conversions_short_cuda_float32 

=================================== FAILURES ===================================
_______________ TestCommonCUDA.test_out__chunk_cat_cuda_float32 ________________
Traceback (most recent call last):
  File "/opt/pytorch/pytorch/torch/testing/_comparison.py", line 1225, in not_close_error_metas
    pair.compare()
  File "/opt/pytorch/pytorch/torch/testing/_comparison.py", line 707, in compare
    self._compare_values(actual, expected)
  File "/opt/pytorch/pytorch/torch/testing/_comparison.py", line 834, in _compare_values
    compare_fn(
  File "/opt/pytorch/pytorch/torch/testing/_comparison.py", line 1016, in _compare_regular_values_close
    if torch.all(matches):
RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 940, in test_wrapper
    return test(*args, **kwargs)
  File "/opt/pytorch/pytorch/test/test_ops.py", line 921, in test_out
    _compare_out(_case_two_transform, compare_strides_and_data_ptrs=False)
  File "/opt/pytorch/pytorch/test/test_ops.py", line 882, in _compare_out
    self.assertEqual(expected, out)
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 3585, in assertEqual
    error_metas = not_close_error_metas(
  File "/opt/pytorch/pytorch/torch/testing/_comparison.py", line 1232, in not_close_error_metas
    f"Comparing\n\n"
  File "/opt/pytorch/pytorch/torch/testing/_comparison.py", line 375, in __repr__
    body = [
  File "/opt/pytorch/pytorch/torch/testing/_comparison.py", line 376, in <listcomp>
    f"    {name}={value!s},"
  File "/opt/pytorch/pytorch/torch/_tensor.py", line 464, in __repr__
    return torch._tensor_str._str(self, tensor_contents=tensor_contents)
  File "/opt/pytorch/pytorch/torch/_tensor_str.py", line 697, in _str
    return _str_intern(self, tensor_contents=tensor_contents)
  File "/opt/pytorch/pytorch/torch/_tensor_str.py", line 617, in _str_intern
    tensor_str = _tensor_str(self, indent)
  File "/opt/pytorch/pytorch/torch/_tensor_str.py", line 349, in _tensor_str
    formatter = _Formatter(get_summarized_data(self) if summarize else self)
  File "/opt/pytorch/pytorch/torch/_tensor_str.py", line 138, in __init__
    tensor_view, torch.isfinite(tensor_view) & tensor_view.ne(0)
RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 2739, in wrapper
    method(*args, **kwargs)
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 2739, in wrapper
    method(*args, **kwargs)
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 419, in instantiated_test
    result = test(self, **param_kwargs)
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 1352, in wrapper
    fn(*args, **kwargs)
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 946, in test_wrapper
    raise Exception(
Exception: Caused by sample input at index 0: SampleInput(input=TensorList[Tensor[size=(1, 2, 3), device="cuda:0", dtype=torch.float32], Tensor[size=(1, 2, 3), device="cuda:0", dtype=torch.float32]], args=(-1,5), kwargs={}, broadcasts_input=False, name='')

To execute this test, run the following from the base repo dir:
     python test/test_ops.py -k test_out__chunk_cat_cuda_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
- generated xml file: /opt/pytorch/pytorch/test/test-reports/python-pytest/test_ops/test_ops-b4bd09e58069cde2.xml -
=========================== short test summary info ============================
FAILED [0.5560s] test_ops.py::TestCommonCUDA::test_out__chunk_cat_cuda_float32 - Exception: Caused by sample input at index 0: SampleInput(input=TensorList[Tensor[size=(1, 2, 3), device="cuda:0", dtype=torch.float32], Tensor[size=(1, 2, 3), device="cuda:0", dtype=torch.float32]], args=(-1,5), kwargs={}, broadcasts_input=False, name='')

To execute this test, run the following from the base repo dir:
     python test/test_ops.py -k test_out__chunk_cat_cuda_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
!!!!!!!!!! _pytest.outcomes.Exit: PYTEST EARLY EXIT FOR CUDA FAILURES !!!!!!!!!!
= 1 failed, 266 passed, 114 skipped, 2745 deselected, 3 xfailed in 72.06s (0:01:12) =
Traceback (most recent call last):
  File "/opt/pytorch/pytorch/test/test_ops.py", line 2395, in <module>
    run_tests()
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 1113, in run_tests
    sanitize_pytest_xml(test_report_path)
  File "/opt/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 983, in sanitize_pytest_xml
    full_classname = testcase.attrib['classname']
KeyError: 'classname'
Got exit code 1
Retrying...
Test results will be stored in test-reports/python-pytest/test_ops/test_ops-015eb3265d1fc7aa.xml
```

Would it be better to use `get` here?

```python
full_classname = testcase.get('classname')
```

https://github.com/pytorch/pytorch/blob/e25054b248d3f6839f25c326463b47e974188a95/torch/testing/_internal/common_utils.py#L980-L983

### Versions

at commit e25054b248d3f6839f25c326463b47e974188a95
python 3.10.12

CUDA IMA is not the issue, don't worry about that.

cc @clee2000