[Feature] support seed parameter (#3161)

* support seed

* fix

* add SamplingMetadata seed test

* The next_tokens values are inconsistent!

* add air and rejection seed test

* fix

* add SamplingParams seed test

* fix seed=0

* Default to defualt

* fix

* fix args_utils

* fix review

* fix review

* fix

* fix

* add xpu,gcu,iluvatar support seed

* fix
This commit is contained in:
lizexu123
2025-08-06 15:20:47 +08:00
committed by GitHub
parent 20839abccf
commit afff4d37ea
15 changed files with 386 additions and 5 deletions

View File

@@ -29,6 +29,8 @@ from logging.handlers import BaseRotatingHandler
from pathlib import Path
from typing import Literal, TypeVar, Union
import numpy as np
import paddle
import requests
import yaml
from aistudio_sdk.snapshot_download import snapshot_download as aistudio_download
@@ -295,6 +297,13 @@ def extract_tar(tar_path, output_dir):
raise RuntimeError(f"Extraction failed: {e!s}")
def set_random_seed(seed: int) -> None:
if seed is not None:
random.seed(seed)
np.random.seed(seed)
paddle.seed(seed)
def download_model(url, output_dir, temp_tar):
"""
下载模型,并将其解压到指定目录。