Files
lightseekorg--tokenspeed/test/runtime/test_sampling_backend_registry.py
wehub-resource-sync 59a0a3844c
PR Test AMD / cancel-on-close (push) Has been skipped
PR Test NVIDIA ARM / scan (push) Has been skipped
PR Test NVIDIA / cancel-on-close (push) Has been skipped
PR Test AMD / scan (push) Has been skipped
PR Test NVIDIA ARM / cancel-on-close (push) Has been skipped
PR Test NVIDIA / scan (push) Has been skipped
Release Docker Images / build (cu129-torch-2.11.0) (push) Has been skipped
Release Docker Images / build (cu130-torch-2.11.0) (push) Has been skipped
Release PyPI / publish (push) Has been skipped
Scheduler Python Test / test (push) Successful in 27m19s
Docs / build (push) Successful in 28m8s
Scheduler C++ Test / test (push) Successful in 28m19s
Scheduler C++ Test / test-flat (push) Successful in 28m18s
Docs / deploy (push) Has been cancelled
PR Test AMD / finish (push) Has been cancelled
PR Test NVIDIA / finish (push) Has been cancelled
PR Test NVIDIA ARM / finish (push) Has been cancelled
PR Test NVIDIA ARM / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
PR Test AMD / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
PR Test NVIDIA / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:31 +08:00

39 lines
1.5 KiB
Python

"""Regression tests for sampling backend registry defaults."""
import os
import sys
import unittest
from types import SimpleNamespace
from unittest import mock
# CI Registration (parsed via AST, runtime no-op)
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from ci_system.ci_register import register_cuda_ci # noqa: E402
register_cuda_ci(est_time=10, suite="runtime-1gpu")
from tokenspeed.runtime.sampling import registry # noqa: E402
class TestSamplingBackendRegistryDefaults(unittest.TestCase):
def test_unresolved_default_uses_flashinfer_on_nvidia(self):
platform = SimpleNamespace(is_nvidia=True)
server_args = SimpleNamespace(sampling_backend=None)
with mock.patch.object(registry, "current_platform", return_value=platform):
self.assertEqual(registry._resolve_backend_name(server_args), "flashinfer")
def test_unresolved_default_uses_greedy_on_non_nvidia(self):
platform = SimpleNamespace(is_nvidia=False)
server_args = SimpleNamespace(sampling_backend=None)
with mock.patch.object(registry, "current_platform", return_value=platform):
self.assertEqual(registry._resolve_backend_name(server_args), "greedy")
def test_explicit_backend_is_preserved(self):
platform = SimpleNamespace(is_nvidia=False)
server_args = SimpleNamespace(sampling_backend="flashinfer")
with mock.patch.object(registry, "current_platform", return_value=platform):
self.assertEqual(registry._resolve_backend_name(server_args), "flashinfer")