Fix potential flakiness in test_lora_qwen3 (#10250)

This commit is contained in:
Lifu Huang
2025-09-10 01:04:39 -07:00
committed by GitHub
parent 27760fc1b6
commit e903f695c8
3 changed files with 21 additions and 14 deletions

View File

@@ -13,6 +13,7 @@
# ==============================================================================
import dataclasses
import random
from typing import List
import torch
@@ -386,3 +387,11 @@ def run_lora_test_by_batch(
srt_no_lora_outputs.output_strs[i].strip(" "),
hf_no_lora_outputs.output_strs[i].strip(" "),
)
def ensure_reproducibility():
seed = 42
random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.use_deterministic_algorithms(True)