@@ -64,17 +64,18 @@ def matmul(lhs, rhs):
6464 return output
6565
6666
67- def _device_dtype_config (devices , fp16_atol ):
67+ def _device_dtype_config (devices , * , fp16_rtol , fp16_atol ):
6868 config = []
6969
7070 for device in devices :
71- config .append (pytest .param (device , torch .float16 , fp16_atol ))
71+ config .append (pytest .param (device , torch .float16 , fp16_rtol , fp16_atol ))
7272
7373 if hasattr (torch , "float8_e5m2" ):
7474 config .append (
7575 pytest .param (
7676 device ,
7777 torch .float8_e5m2 ,
78+ 1e-5 ,
7879 0.125 ,
7980 marks = pytest .mark .requires_capability (
8081 f"tests.capabilities.float8:float8_e5m2_{ device } "
@@ -86,13 +87,17 @@ def _device_dtype_config(devices, fp16_atol):
8687
8788
8889@pytest .mark .parametrize (
89- "device, dtype, atol" ,
90- _device_dtype_config (get_available_devices (), fp16_atol = _FP16_ATOL ),
90+ "device, dtype, rtol, atol" ,
91+ _device_dtype_config (
92+ get_available_devices (),
93+ fp16_rtol = _FP16_RTOL ,
94+ fp16_atol = _FP16_ATOL ,
95+ ),
9196)
9297@pytest .mark .parametrize ("k" , (512 ,))
9398@pytest .mark .parametrize ("n" , (512 ,))
9499@pytest .mark .parametrize ("m" , (512 ,))
95- def test (m , n , k , dtype , device , atol ):
100+ def test (m , n , k , dtype , device , rtol , atol ):
96101 randn_dtype = dtype if dtype != torch .float8_e5m2 else torch .float16
97102
98103 input = torch .randn ((m , k ), dtype = randn_dtype , device = device )
@@ -108,5 +113,4 @@ def test(m, n, k, dtype, device, atol):
108113 output = matmul (input , other )
109114 expected = torch .matmul (input , other )
110115
111- rtol = _FP16_RTOL if dtype == torch .float16 else 1e-5
112116 assert torch .allclose (output , expected , rtol = rtol , atol = atol )
0 commit comments