"""Unit tests for SamplingParams seq_seed handling.""" import pytest import torch # noqa: F401 Load torch's shared libraries before deepinfer. from deepinfer.sampling_params import SamplingParams pytestmark = [pytest.mark.ci, pytest.mark.ci_npu] def test_seq_seed_none_is_random_uint64() -> None: params = SamplingParams() assert 0 <= params.seq_seed < 2**64 def test_seq_seed_valid_is_preserved() -> None: assert SamplingParams(seq_seed=42).seq_seed == 42 assert SamplingParams(seq_seed=2**64 - 1).seq_seed == 2**64 - 1 def test_seq_seed_wraps_to_uint64() -> None: assert SamplingParams(seq_seed=2**64 + 5).seq_seed == 5 def test_seq_seed_negative_raises() -> None: with pytest.raises(ValueError, match="seq_seed"): SamplingParams(seq_seed=-1) with pytest.raises(ValueError, match="seq_seed"): SamplingParams(seq_seed=-(2**64) + 5) def test_seq_seed_wrong_type_raises() -> None: with pytest.raises(TypeError, match="seq_seed"): SamplingParams(seq_seed="42") # type: ignore[arg-type] with pytest.raises(TypeError, match="seq_seed"): SamplingParams(seq_seed=1.5) # type: ignore[arg-type]