From 0e0091c6c8aea4f728a9cb5c93c2016f43859d08 Mon Sep 17 00:00:00 2001 From: Kurt Shuster Date: Sun, 12 Apr 2026 05:17:22 -0400 Subject: [PATCH] [server] Add --quantization unquant to explicitly opt out of quantization (#21863) --- python/sglang/srt/server_args.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/python/sglang/srt/server_args.py b/python/sglang/srt/server_args.py index e52739187..5f92dc531 100644 --- a/python/sglang/srt/server_args.py +++ b/python/sglang/srt/server_args.py @@ -122,9 +122,10 @@ QUANTIZATION_CHOICES = [ "compressed-tensors", # for Ktransformers "modelslim", # for NPU "quark_int4fp8_moe", + "unquant", ] -SPECULATIVE_DRAFT_MODEL_QUANTIZATION_CHOICES = [*QUANTIZATION_CHOICES, "unquant"] +SPECULATIVE_DRAFT_MODEL_QUANTIZATION_CHOICES = QUANTIZATION_CHOICES ATTENTION_BACKEND_CHOICES = [ # Common @@ -777,6 +778,16 @@ class ServerArgs: # Handle deprecated environment variables for prefill delayer. self._handle_prefill_delayer_env_compat() + # Resolve --quantization unquant: explicitly opt out of quantization. + # Convert to None now (before model config validation), but record + # the intent so auto-detection in _handle_model_specific_adjustments + # does not override it. + if self.quantization == "unquant": + self.quantization = None + self._quantization_explicitly_unset = True + else: + self._quantization_explicitly_unset = False + # Set missing default values. self._handle_missing_default_values() @@ -1692,7 +1703,10 @@ class ServerArgs: and weights_cfg.get("strategy") == "group" and weights_cfg.get("type") == "int" ) - if self.quantization is None: + if ( + self.quantization is None + and not self._quantization_explicitly_unset + ): # Default DeepSeek V3/R1 native FP8 when not explicitly set, # Because we need this condition for an assertion in # flashinfer_trtllm MoE runner backend. @@ -2027,7 +2041,11 @@ class ServerArgs: ]: if is_sm100_supported(): quant_method = get_quantization_config(hf_config) - if self.quantization is None and quant_method is not None: + if ( + self.quantization is None + and not self._quantization_explicitly_unset + and quant_method is not None + ): self.quantization = quant_method if ( ( @@ -2081,7 +2099,11 @@ class ServerArgs: if quantization_config is not None else None ) - if self.quantization is None and quant_method is not None: + if ( + self.quantization is None + and not self._quantization_explicitly_unset + and quant_method is not None + ): self.quantization = quant_method if ( self.quantization == "modelopt_fp4"