Seed sgl-kernel topk sigmoid tests on all backends (#30754)
This commit is contained in:
@@ -5,17 +5,13 @@ import pytest
|
|||||||
import torch
|
import torch
|
||||||
from sgl_kernel import topk_sigmoid
|
from sgl_kernel import topk_sigmoid
|
||||||
|
|
||||||
_IS_HIP = torch.version.hip is not None
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def _deterministic_seed():
|
def _deterministic_seed():
|
||||||
# AMD/ROCm only: pin RNG so torch.randn produces identical gating scores
|
# Pin RNG on every backend so torch.randn produces identical gating scores
|
||||||
# across runs. atol=0 indices comparison is otherwise tripped by near-tied
|
# across runs. The exact index comparison can otherwise be tripped by
|
||||||
# sigmoid scores where hipCUB's tie-break inside torch.topk disagrees with
|
# near-tied sigmoid scores whose rounded values have different top-k
|
||||||
# sgl_kernel.topk_sigmoid. Not observed on CUDA, so leave CUDA behavior
|
# tie-break ordering between torch.topk and sgl_kernel.topk_sigmoid.
|
||||||
# unchanged.
|
|
||||||
if _IS_HIP:
|
|
||||||
torch.manual_seed(0)
|
torch.manual_seed(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user