8000 change GPT2ForSequenceClassification inference accuracy tolerance (#1… · pytorch/pytorch@67883e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67883e7

Browse files
Valentine233pytorchmergebot
authored andcommitted
change GPT2ForSequenceClassification inference accuracy tolerance (#136749)
Fixes #123503. #121866 makes GPT2ForSequenceClassification hit the SDPA pattern 18 and then encounter the accuracy issue. The issue only happens with BF16 inference single thread. This PR tends to increase the model tolerance from 4e-3 to 5e-3 and make the check pass. Note that the issue is due to some small implementation diff. For example, the sdpa math backend scales q, k before matmul for stability; the flash attention backend has more diffs as a new algorithm. Pull Request resolved: #136749 Approved by: https://github.com/jgong5, https://github.com/jansel
1 parent fba2c0a commit 67883e7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

benchmarks/dynamo/huggingface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,12 @@ def get_tolerance_and_cosine_flag(self, is_training, current_device, name):
501501
else:
502502
return 1e-2, cosine
503503
else:
504-
if name in self._config["tolerance"]["higher_inference"]:
505-
return 4e-3, cosine
506504
if (
507505
current_device == "cpu"
508506
and name in self._config["tolerance"]["higher_inference_cpu"]
509507
):
508+
return 5e-3, cosine
509+
if name in self._config["tolerance"]["higher_inference"]:
510510
return 4e-3, cosine
511511
return 1e-3, cosine
512512

benchmarks/dynamo/huggingface.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ tolerance:
8989

9090
higher_inference_cpu:
9191
- LayoutLMForSequenceClassification
92+
- GPT2ForSequenceClassification
9293

9394
cosine: []
9495

0 commit comments

Comments
 (0)
0