[FlashInfer v0.6.4] [RL] Integrate FlashInfer mxfp8 gemm, MoE, and routed MoE (#19537)

This commit is contained in:
Ziang Li
2026-03-10 15:37:57 -07:00
committed by GitHub
parent bd460e9565
commit 76ee4bb98c
14 changed files with 671 additions and 86 deletions

View File

@@ -12,10 +12,12 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=300, suite="nightly-4-gpu-b200", nightly=True)
register_cuda_ci(est_time=500, suite="nightly-4-gpu-b200", nightly=True)
class TestFlashinferTrtllmGenMoeBackendFP8(CustomTestCase):
class FlashinferTrtllmGenMoeBackendFP8Base:
backend = None
@classmethod
def setUpClass(cls):
cls.model = "Qwen/Qwen3-Next-80B-A3B-Instruct-FP8"
@@ -29,7 +31,7 @@ class TestFlashinferTrtllmGenMoeBackendFP8(CustomTestCase):
"--attention-backend",
"triton",
"--moe-runner-backend",
"flashinfer_trtllm",
cls.backend,
"--tp-size",
"4",
"--ep-size",
@@ -60,7 +62,9 @@ class TestFlashinferTrtllmGenMoeBackendFP8(CustomTestCase):
self.assertGreater(metrics["accuracy"], 0.93)
class TestFlashinferTrtllmGenMoeBackendBF16(CustomTestCase):
class FlashinferTrtllmGenMoeBackendBF16Base:
backend = None
@classmethod
def setUpClass(cls):
cls.model = "Qwen/Qwen3-Next-80B-A3B-Instruct"
@@ -73,7 +77,7 @@ class TestFlashinferTrtllmGenMoeBackendBF16(CustomTestCase):
"--attention-backend",
"triton",
"--moe-runner-backend",
"flashinfer_trtllm",
cls.backend,
"--cuda-graph-max-bs",
"512",
"--tp-size",
@@ -106,5 +110,82 @@ class TestFlashinferTrtllmGenMoeBackendBF16(CustomTestCase):
self.assertGreater(metrics["accuracy"], 0.93)
class FlashinferTrtllmGenMoeBackendMXFP8Base:
backend = None
@classmethod
def setUpClass(cls):
cls.model = "Qwen/Qwen3-30B-A3B-Instruct-2507"
cls.base_url = DEFAULT_URL_FOR_TEST
cls.process = popen_launch_server(
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
env={**os.environ, "SGLANG_ENABLE_JIT_DEEPGEMM": "False"},
other_args=[
"--quantization",
"mxfp8",
"--fp8-gemm-backend",
"flashinfer_trtllm",
"--moe-runner-backend",
cls.backend,
"--tp-size",
"4",
"--ep-size",
"4",
"--mem-fraction-static",
"0.7",
],
)
@classmethod
def tearDownClass(cls):
kill_process_tree(cls.process.pid)
def test_gsm8k(self):
args = SimpleNamespace(
num_shots=5,
data_path=None,
num_questions=200,
max_new_tokens=512,
parallel=128,
host="http://127.0.0.1",
port=int(self.base_url.split(":")[-1]),
)
metrics = run_eval(args)
print(f"{metrics=}")
self.assertGreater(metrics["accuracy"], 0.93)
class TestFlashinferTrtllmGenMoeBackendFP8(
FlashinferTrtllmGenMoeBackendFP8Base, CustomTestCase
):
backend = "flashinfer_trtllm"
class TestFlashinferTrtllmGenMoeBackendMXFP8(
FlashinferTrtllmGenMoeBackendMXFP8Base, CustomTestCase
):
backend = "flashinfer_trtllm"
class TestFlashinferTrtllmGenMoeBackendBF16(
FlashinferTrtllmGenMoeBackendBF16Base, CustomTestCase
):
backend = "flashinfer_trtllm"
class TestFlashinferTrtllmGenMoeBackendFP8Routed(
FlashinferTrtllmGenMoeBackendFP8Base, CustomTestCase
):
backend = "flashinfer_trtllm_routed"
class TestFlashinferTrtllmGenMoeBackendMXFP8Routed(
FlashinferTrtllmGenMoeBackendMXFP8Base, CustomTestCase
):
backend = "flashinfer_trtllm_routed"
if __name__ == "__main__":
unittest.main()

View File

@@ -12,9 +12,10 @@ from sglang.test.test_utils import (
try_cached_model,
)
register_cuda_ci(est_time=280, suite="stage-c-test-4-gpu-b200")
register_cuda_ci(est_time=420, suite="stage-c-test-4-gpu-b200")
MODEL_PATH = "Qwen/Qwen3-4B-Instruct-2507-FP8"
BF16_MODEL_PATH = "Qwen/Qwen3-4B-Instruct-2507"
class FP8BlockwiseGemmBase:
@@ -56,7 +57,51 @@ class FP8BlockwiseGemmBase:
metrics = run_eval_few_shot_gsm8k(args)
print(metrics)
self.assertGreaterEqual(metrics["accuracy"], 0.41)
self.assertGreaterEqual(metrics["accuracy"], 0.8)
class MXFP8GemmBase:
backend = None
@classmethod
def setUpClass(cls):
if cls.backend is None:
raise NotImplementedError("Subclass must set 'backend' attribute")
cls.model = try_cached_model(BF16_MODEL_PATH)
cls.base_url = DEFAULT_URL_FOR_TEST
other_args = [
"--trust-remote-code",
"--quantization",
"mxfp8",
"--fp8-gemm-backend",
cls.backend,
]
cls.process = popen_launch_server(
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=other_args,
)
@classmethod
def tearDownClass(cls):
kill_process_tree(cls.process.pid)
def test_gsm8k(self):
parsed_url = urlparse(self.base_url)
args = SimpleNamespace(
num_shots=8,
data_path=None,
num_questions=1319,
max_new_tokens=512,
parallel=200,
host=f"{parsed_url.scheme}://{parsed_url.hostname}",
port=parsed_url.port,
)
metrics = run_eval_few_shot_gsm8k(args)
print(metrics)
self.assertGreaterEqual(metrics["accuracy"], 0.8)
class TestFP8BlockwiseGemmTriton(FP8BlockwiseGemmBase, unittest.TestCase):
@@ -77,5 +122,15 @@ class TestFP8BlockwiseGemmFlashinferDeepGemm(FP8BlockwiseGemmBase, unittest.Test
backend = "flashinfer_deepgemm"
@unittest.skipIf(get_device_sm() < 100, "Test requires CUDA SM 100 or higher")
class TestMXFP8GemmTriton(MXFP8GemmBase, unittest.TestCase):
backend = "triton"
@unittest.skipIf(get_device_sm() < 100, "Test requires CUDA SM 100 or higher")
class TestMXFP8GemmFlashinferTrtllm(MXFP8GemmBase, unittest.TestCase):
backend = "flashinfer_trtllm"
if __name__ == "__main__":
unittest.main()