- create_app reads distributed_executor_backend with getattr(..., None): the MLX server passes a SimpleNamespace without it, so since #1746 the server could not start (28 test_openai_video_client failures). An explicit external_launcher request is still rejected. - test_cpu_sdpa patches fastvideo.platforms._current_platform instead of current_platform. monkeypatch restored the real platform as a module attribute that shadowed the lazy __getattr__, so later tests that fake _current_platform (gpu_worker dist timeout, ROCm detection, selector role override) failed on GPU hosts. GB200 unit lane, A/B on one tray: main 36 failures, this change 0 (2720 passed).
33 lines
1.5 KiB
Python
33 lines
1.5 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
"""CPU reference models must resolve real SDPA without a CUDA backend."""
|
|
|
|
import pytest
|
|
import torch
|
|
|
|
from fastvideo.platforms.cpu import CpuPlatform
|
|
from fastvideo.platforms.interface import AttentionBackendEnum
|
|
|
|
|
|
@pytest.mark.parametrize("requested", [None, AttentionBackendEnum.TORCH_SDPA])
|
|
def test_cpu_sdpa_resolution_through_selector(monkeypatch, requested):
|
|
from fastvideo import platforms
|
|
from fastvideo.attention.backends.sdpa import SDPABackend
|
|
from fastvideo.attention.selector import _cached_get_attn_backend, get_attn_backend
|
|
|
|
# Patch the platform behind the lazy `current_platform` lookup. Patching
|
|
# `current_platform` itself makes monkeypatch restore the real platform as a
|
|
# module attribute afterwards, which shadows the lookup for every later test
|
|
# that patches `_current_platform` (test_gpu_worker, the ROCm detection test).
|
|
monkeypatch.setattr(platforms, "_current_platform", CpuPlatform())
|
|
_cached_get_attn_backend.cache_clear()
|
|
try:
|
|
backend = get_attn_backend(64, torch.float32, (AttentionBackendEnum.TORCH_SDPA,), requested=requested)
|
|
assert backend is SDPABackend
|
|
finally:
|
|
_cached_get_attn_backend.cache_clear()
|
|
|
|
|
|
def test_cpu_rejects_sparse_backend_instead_of_changing_attention():
|
|
with pytest.raises(NotImplementedError, match="not supported on CPU"):
|
|
CpuPlatform.get_attn_backend_cls(AttentionBackendEnum.VIDEO_SPARSE_ATTN, 64, torch.float32)
|