main
py 17 lines 606 Bytes
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 import torch
5
6 # Reference default values of atol and rtol are from
7 # https://github.com/pytorch/pytorch/blob/6d96beb6bec24d73ee3f080bac54d2104068f675/test/test_transformers.py#L67
8 default_atol = {torch.float16: 1e-3, torch.bfloat16: 1e-3, torch.float: 1e-5}
9 default_rtol = {torch.float16: 1e-3, torch.bfloat16: 1.6e-2, torch.float: 1.3e-6}
10
11
12 def get_default_atol(output) -> float:
13 return default_atol[output.dtype]
14
15
16 def get_default_rtol(output) -> float:
17 return default_rtol[output.dtype]