Add configurable FlashInfer autotune skips (#31389)
This commit is contained in:
@@ -1451,6 +1451,12 @@ Please consult the documentation below and [server_args.py](https://github.com/s
|
|||||||
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>Flashinfer autotune is enabled by default. Set this flag to disable the autotune.</td>
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>Flashinfer autotune is enabled by default. Set this flag to disable the autotune.</td>
|
||||||
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.02)"}}>`False`</td>
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.02)"}}>`False`</td>
|
||||||
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>bool flag (set to enable)</td>
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>bool flag (set to enable)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style={{padding: "9px 12px", fontWeight: 500, backgroundColor: "rgba(255,255,255,0.02)"}}>`--flashinfer-autotune-skip-ops`</td>
|
||||||
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>FlashInfer custom-op identifiers to skip during autotuning. See <a href="https://docs.flashinfer.ai/autotuning.html">FlashInfer's autotuning documentation</a>. Skipped ops use the heuristic fallback. SGLang temporarily skips <code>mxfp8_gemm</code> by default due to an IMA.</td>
|
||||||
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.02)"}}>`None`</td>
|
||||||
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>string</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style={{padding: "9px 12px", fontWeight: 500, backgroundColor: "rgba(255,255,255,0.02)"}}>`--radix-cache-backend`</td>
|
<td style={{padding: "9px 12px", fontWeight: 500, backgroundColor: "rgba(255,255,255,0.02)"}}>`--radix-cache-backend`</td>
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# TODO: Remove after FlashInfer fixes the mxfp8_gemm autotuning IMA.
|
||||||
|
FLASHINFER_AUTOTUNE_WORKAROUND_SKIPS = frozenset({"mxfp8_gemm"})
|
||||||
|
|
||||||
|
|
||||||
|
def get_flashinfer_autotune_skip_ops(model_runner: ModelRunner) -> set[str]:
|
||||||
|
skip_ops = set(model_runner.server_args.flashinfer_autotune_skip_ops or ())
|
||||||
|
skip_ops.update(FLASHINFER_AUTOTUNE_WORKAROUND_SKIPS)
|
||||||
|
return skip_ops
|
||||||
|
|
||||||
|
|
||||||
def should_run_flashinfer_autotune(
|
def should_run_flashinfer_autotune(
|
||||||
model_runner: ModelRunner, *, for_speculative_draft: bool = False
|
model_runner: ModelRunner, *, for_speculative_draft: bool = False
|
||||||
@@ -124,6 +133,9 @@ def flashinfer_autotune_cache_path(model_runner: ModelRunner) -> Path:
|
|||||||
str(mr.ps.moe_ep_size),
|
str(mr.ps.moe_ep_size),
|
||||||
str(mr.model_config.hf_config.__class__.__name__),
|
str(mr.model_config.hf_config.__class__.__name__),
|
||||||
]
|
]
|
||||||
|
# A different skip policy must not reuse previously tuned tactics.
|
||||||
|
skip_ops = get_flashinfer_autotune_skip_ops(mr)
|
||||||
|
model_key_parts.append("skip_ops=" + ",".join(sorted(skip_ops)))
|
||||||
if mr.is_draft_worker:
|
if mr.is_draft_worker:
|
||||||
model_key_parts.append(f"draft_quant={mr.model_config.quantization}")
|
model_key_parts.append(f"draft_quant={mr.model_config.quantization}")
|
||||||
model_key = "|".join(model_key_parts)
|
model_key = "|".join(model_key_parts)
|
||||||
@@ -172,11 +184,11 @@ def flashinfer_autotune_context(model_runner: ModelRunner, *, skip_logits: bool)
|
|||||||
from sglang.srt.layers.logits_processor import autotune_dummy_run_mode
|
from sglang.srt.layers.logits_processor import autotune_dummy_run_mode
|
||||||
|
|
||||||
maybe_skip_logits = autotune_dummy_run_mode()
|
maybe_skip_logits = autotune_dummy_run_mode()
|
||||||
|
skip_ops = get_flashinfer_autotune_skip_ops(mr)
|
||||||
with torch.inference_mode(), autotune(
|
with torch.inference_mode(), autotune(
|
||||||
# Autotuning mxfp8_gemm hits an IMA; skip it.
|
|
||||||
True,
|
True,
|
||||||
cache=str(autotune_cache),
|
cache=str(autotune_cache),
|
||||||
skip_ops={"mxfp8_gemm"},
|
skip_ops=skip_ops,
|
||||||
), maybe_skip_logits:
|
), maybe_skip_logits:
|
||||||
yield
|
yield
|
||||||
torch.cuda.current_stream().wait_stream(mr.forward_stream)
|
torch.cuda.current_stream().wait_stream(mr.forward_stream)
|
||||||
|
|||||||
@@ -1739,6 +1739,18 @@ class ServerArgs:
|
|||||||
disable_flashinfer_autotune: A[
|
disable_flashinfer_autotune: A[
|
||||||
bool, "Disable FlashInfer autotuning.", NS("exec.kernel")
|
bool, "Disable FlashInfer autotuning.", NS("exec.kernel")
|
||||||
] = False
|
] = False
|
||||||
|
flashinfer_autotune_skip_ops: A[
|
||||||
|
Optional[List[str]],
|
||||||
|
Arg(
|
||||||
|
help=(
|
||||||
|
"FlashInfer custom-op identifiers to skip during autotuning. "
|
||||||
|
"Skipped ops use FlashInfer's heuristic fallback. SGLang "
|
||||||
|
"temporarily skips mxfp8_gemm by default due to an IMA."
|
||||||
|
),
|
||||||
|
nargs="+",
|
||||||
|
),
|
||||||
|
NS("exec.kernel"),
|
||||||
|
] = None
|
||||||
mamba_backend: A[
|
mamba_backend: A[
|
||||||
str,
|
str,
|
||||||
Arg(
|
Arg(
|
||||||
|
|||||||
Reference in New Issue
Block a user