[dLLM] Make FDFO a framework capability for all dLLM algorithms (#27551)
Co-authored-by: Xiaoyu Zhang <1182563586@qq.com>
This commit is contained in:
co-authored by
Xiaoyu Zhang
parent
fc2ef35308
commit
e3ceccf781
+6
-3
@@ -20,7 +20,9 @@ from sglang.test.test_utils import (
|
||||
)
|
||||
|
||||
|
||||
class TestLLaDA2Mini(CustomTestCase):
|
||||
class TestBatchingFDFO(CustomTestCase):
|
||||
"""End-to-end dLLM coverage on the default First-Done-First-Out scheduler."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.model = "inclusionAI/LLaDA2.0-mini"
|
||||
@@ -38,6 +40,7 @@ class TestLLaDA2Mini(CustomTestCase):
|
||||
"flashinfer",
|
||||
"--dllm-algorithm",
|
||||
"LowConfidence",
|
||||
"--dllm-fdfo",
|
||||
"--cuda-graph-bs",
|
||||
"1",
|
||||
"2",
|
||||
@@ -73,7 +76,7 @@ class TestLLaDA2Mini(CustomTestCase):
|
||||
if is_in_amd_ci():
|
||||
self.assertGreater(metrics["output_throughput"], 80)
|
||||
else:
|
||||
self.assertGreater(metrics["output_throughput"], 350)
|
||||
self.assertGreater(metrics["output_throughput"], 450)
|
||||
|
||||
def test_bs_1_speed(self):
|
||||
args = BenchArgs(port=int(self.base_url.split(":")[-1]), max_new_tokens=2048)
|
||||
@@ -83,7 +86,7 @@ class TestLLaDA2Mini(CustomTestCase):
|
||||
|
||||
if is_in_ci():
|
||||
write_github_step_summary(
|
||||
f"### test_bs_1_speed (llada2-mini) with tp1\n"
|
||||
f"### test_bs_1_speed (llada2-mini FDFO) with tp1\n"
|
||||
f"{speed=:.2f} token/s\n"
|
||||
)
|
||||
if is_in_amd_ci():
|
||||
@@ -0,0 +1,89 @@
|
||||
from sglang.test.ci.ci_register import register_cuda_ci
|
||||
|
||||
register_cuda_ci(est_time=300, stage="base-b", runner_config="1-gpu-large")
|
||||
|
||||
import unittest
|
||||
|
||||
import requests
|
||||
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
DEFAULT_URL_FOR_TEST,
|
||||
CustomTestCase,
|
||||
popen_launch_server,
|
||||
)
|
||||
|
||||
PROMPTS = [
|
||||
"Question: Natalia sold clips to 48 friends in April, and half as many in "
|
||||
"May. How many clips did she sell altogether? Answer:",
|
||||
"The capital of France is",
|
||||
"Q: What is 12 times 13? A:",
|
||||
]
|
||||
|
||||
|
||||
class TestBatchingFDFOJointThreshold(CustomTestCase):
|
||||
"""At a single in-flight request, FDFO and synchronous execution run identical
|
||||
forward shapes, so a correct stateful (``dllm_algo_state``) carry must produce
|
||||
byte-identical multi-block output.
|
||||
"""
|
||||
|
||||
model = "inclusionAI/LLaDA2.1-mini"
|
||||
base_url = DEFAULT_URL_FOR_TEST
|
||||
|
||||
def _collect_outputs(self, fdfo: bool):
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--tp-size",
|
||||
"1",
|
||||
"--mem-fraction-static",
|
||||
"0.9",
|
||||
"--max-running-requests",
|
||||
"1",
|
||||
"--attention-backend",
|
||||
"flashinfer",
|
||||
"--dllm-algorithm",
|
||||
"JointThreshold",
|
||||
"--cuda-graph-bs",
|
||||
"1",
|
||||
]
|
||||
# FDFO is the default; the sync arm must opt out explicitly.
|
||||
other_args.append("--dllm-fdfo" if fdfo else "--no-dllm-fdfo")
|
||||
|
||||
process = popen_launch_server(
|
||||
self.model,
|
||||
self.base_url,
|
||||
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
other_args=other_args,
|
||||
)
|
||||
try:
|
||||
outputs = []
|
||||
for prompt in PROMPTS:
|
||||
response = requests.post(
|
||||
f"{self.base_url}/v1/completions",
|
||||
json={
|
||||
"model": self.model,
|
||||
"prompt": prompt,
|
||||
"max_tokens": 128,
|
||||
"temperature": 0,
|
||||
},
|
||||
timeout=120,
|
||||
)
|
||||
outputs.append(response.json()["choices"][0]["text"])
|
||||
return outputs
|
||||
finally:
|
||||
kill_process_tree(process.pid)
|
||||
|
||||
def test_fdfo_matches_sync(self):
|
||||
sync_outputs = self._collect_outputs(fdfo=False)
|
||||
fdfo_outputs = self._collect_outputs(fdfo=True)
|
||||
self.assertEqual(
|
||||
fdfo_outputs,
|
||||
sync_outputs,
|
||||
"JointThreshold FDFO output must match synchronous output, which "
|
||||
"validates the cross-step dllm_algo_state carry across blocks.",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user