feat: support deterministic FA4 for GLM-4.7-Flash (#33945)
This commit is contained in:
@@ -2050,6 +2050,7 @@ def _deterministic_is_deepseek_model(view: Any) -> bool:
|
||||
"MistralLarge3ForCausalLM",
|
||||
"PixtralForConditionalGeneration",
|
||||
"GlmMoeDsaForCausalLM",
|
||||
"Glm4MoeLiteForCausalLM",
|
||||
]
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
@@ -90,11 +90,18 @@ def initialize_bf16_gemm_config(server_args: ServerArgs) -> None:
|
||||
|
||||
backend_str = server_args.bf16_gemm_backend
|
||||
if backend_str == "auto" and is_sm100_supported():
|
||||
backend_str = "cutedsl"
|
||||
backend_str = (
|
||||
"torch" if server_args.enable_deterministic_inference else "cutedsl"
|
||||
)
|
||||
|
||||
backend = Bf16GemmBackend(backend_str)
|
||||
|
||||
if backend.is_cutedsl():
|
||||
if server_args.enable_deterministic_inference:
|
||||
raise ValueError(
|
||||
"--bf16-gemm-backend cutedsl is batch-size dependent and cannot "
|
||||
"be combined with --enable-deterministic-inference"
|
||||
)
|
||||
if not is_sm100_supported():
|
||||
raise ValueError("--bf16-gemm-backend cutedsl requires an SM10x GPU")
|
||||
|
||||
|
||||
@@ -1754,7 +1754,7 @@ class ServerArgs:
|
||||
bf16_gemm_backend: A[
|
||||
str,
|
||||
Arg(
|
||||
help="Choose the backend for unquantized BF16 GEMM operations. Options: 'auto' (default; selects 'cutedsl' on SM10x GPUs, otherwise uses cuBLAS via torch.nn.functional.linear), 'cutedsl' (SGLang JIT CuTe DSL TGV BF16 GEMM on SM10x; dispatches between the CuTe DSL kernel and cuBLAS), 'torch' (always uses cuBLAS via torch.nn.functional.linear).",
|
||||
help="Choose the backend for unquantized BF16 GEMM operations. Options: 'auto' (default; selects 'cutedsl' on SM10x GPUs, except deterministic inference selects 'torch'; otherwise uses cuBLAS via torch.nn.functional.linear), 'cutedsl' (SGLang JIT CuTe DSL TGV BF16 GEMM on SM10x; dispatches between the CuTe DSL kernel and cuBLAS), 'torch' (always uses cuBLAS via torch.nn.functional.linear).",
|
||||
cli_name="--bf16-gemm-backend",
|
||||
choices=BF16_GEMM_BACKEND_CHOICES,
|
||||
),
|
||||
@@ -8082,6 +8082,7 @@ class ServerArgs:
|
||||
"MistralLarge3ForCausalLM",
|
||||
"PixtralForConditionalGeneration",
|
||||
"GlmMoeDsaForCausalLM",
|
||||
"Glm4MoeLiteForCausalLM",
|
||||
]
|
||||
except Exception:
|
||||
pass
|
||||
@@ -8096,11 +8097,11 @@ class ServerArgs:
|
||||
not in RADIX_SUPPORTED_DETERMINISTIC_ATTENTION_BACKEND
|
||||
):
|
||||
raise ValueError(
|
||||
f"Currently only {RADIX_SUPPORTED_DETERMINISTIC_ATTENTION_BACKEND} attention backends are supported for deterministic inference with DeepSeek models. But you're using {attention_backend}."
|
||||
f"Currently only {RADIX_SUPPORTED_DETERMINISTIC_ATTENTION_BACKEND} attention backends are supported for deterministic inference with absorbed-MLA models. But you're using {attention_backend}."
|
||||
)
|
||||
if attention_backend == "fa4" and not is_sm100_or_sm110_supported():
|
||||
raise ValueError(
|
||||
"Deterministic inference with DeepSeek models on the fa4 "
|
||||
"Deterministic inference with absorbed-MLA models on the fa4 "
|
||||
"attention backend requires SM100/SM110: it runs "
|
||||
"absorbed MLA, whose qv argument flash_attn.cute only "
|
||||
"implements on those archs."
|
||||
|
||||
@@ -31,7 +31,9 @@ class TestDeterministicBase(CustomTestCase):
|
||||
def setUpClass(cls):
|
||||
cls.model = cls.get_model()
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
if "--attention-backend" not in cls.get_server_args():
|
||||
# Identity, not a probe for --attention-backend: a subclass that
|
||||
# deliberately leaves the backend unspecified is a real test case.
|
||||
if cls is TestDeterministicBase:
|
||||
raise unittest.SkipTest("Skip the base test class")
|
||||
|
||||
cls.process = popen_launch_server(
|
||||
|
||||
Reference in New Issue
Block a user