Repository navigation
[Feature, Hardware] Enable SGLang on XPU GPUs via PyTorch - #1480
Conversation
Co-authored-by: Lianmin Zheng <[email protected]>
Co-authored-by: Lianmin Zheng <[email protected]>
Co-authored-by: Lianmin Zheng <[email protected]>
|
@liangan1 Thanks for the contribution. Could you fix the unit tests https://github.com/sgl-project/sglang/tree/main/test? |
Sure. I will work on it and let you know when all UTs pass. |
|
It is almost there! There are only a few remaining issues for multi-gpu test cases. |
|
We will push some big refactor soon, starting from #1534. To prevent too many conflicts, it is better to merge this PR soon or split this PR into multiple smaller ones. |
Sorry, I don't have enough GPUs to reproduce this tensor parallel related UTs, do you have any comments abouts about this issues? According to the UT logs, the distributed backend and model init has been finished and the timeout occurs during the CUDAGraph initialization, but I don't need to change anything for this part. |
d28c647 to
3bddad3
Compare
Spliting this PR into smaller ones.
|
…s its state weg2xsn241/243 (P, --max-running-requests 2, write_back): the mamba pool's interior-node branch freed the recurrent state without a backup (28 x 'sgl-project#1469 EVICT backuped=False host=False' per minute under the second 98k prompt); the node's later KV write-through carried mamba_value=EMPTY, the store held 93,775 leading KV pages with no anchor in the page-floored tail range (the final anchor at 97872 lies outside ..97870), every hold re-read on D answered zero (#1035c CAPPED by=mamba) until the settle bound lapsed -> W31 -> second prefill. Mirror _evict_device_leaf: under write_back, write_backup(node, write_back=True) + writing_check(write_back=True) before the device value is freed; refused/failed backups evict as before. sgl-project#1469 note BACKUP-BEFORE-EVICT (written, ms). Tests: test_weg2_backup_before_mamba_evict_1480 (5) + 1469/1470/1467/924 -> 22 passed.
…ol evicts its state" This reverts commit f606f72.
…up (replaces sgl-project#1480) weg2xsn245 (6x100k, running-req 2): sgl-project#1480 backed up EVERY evicted interior node (124 x 128 MiB KV) into P's 1 GB staging arena; the flip flush (sgl-project#1470 sweep) then blocked in the arena's claim_slots for six minutes -> IDLE-WEDGE. Reverted (e55448c). What the hand-back actually needs is ONE anchor: the N-1 node the END-ANCHOR SPLIT (sgl-project#1233) creates, which becomes an interior node the moment the final 1-token chunk is inserted below it. The mamba pool's interior branch evicted it un-backed under the second concurrent prompt (xsn243: 28 unbacked evicts/min); the final node's own anchor sits one unit past the tail a reader asks for (token_ids[:-1]), so the read had no anchor in range (#1035c CAPPED by=mamba) -> 20 s settle -> W31 -> second prefill. The END-ANCHOR witness now marks that node; the mamba eviction skips it while un-backed (bounded by the finished prompts awaiting the flip, never the whole backlog -- the #1470b hazard); the flush publishes it and lifts the hold. Tests: test_weg2_end_anchor_hold_1481 (4) + 1469/1470/1467/924/1479/1471 -> 35 passed.
…ct#1540 D-SIGNAL-SEATS / sgl-project#1976 D-SIGNAL-LOCKED default on Regression of 31c8d07 on metal (dual round 2, boot dkr27bnvfp4dualbar1drei10220138, image rc31b4): 9 min, 0 prefill / 0 decode batches, 10x CLIENT-GONE. Chain (front.log): 01:42:32,818 "d_signal id_space=0.99 -- D is short beyond the ledger bytes" (the own-tag reading now finds D's signal file; D maps 8192 of its 1M-row id space and the table fill counts the rows it never mapped) -> 01:42:32,822 stage=1 -> 01:42:33,029 stage=1-lend -> 01:42:33,649 stage=2 sleeping (P SLEEP-LEND 6312427520 / 5131730944 / 4846518272 B). From 01:42:43 every request is "LONG -> P leg 1 / BATCH queued"; D gets no seat, d_seat_done never moves, and the sleeping wake (dual_d_priority.PressureStages.tick: pressure <= 0 AND seats_done > seat_mark AND room) waits for a seat end that cannot come. No wake line, no sgl-project#1480 line (the gate only speaks in 'reclaiming'). B9e again: the companions built for the seeing front (sgl-project#1540 seats gate, sgl-project#1976 locked rows) were default off. Fix: - PressureStages.tick(d_idle=...): from sleep, an idle D (no live seat, nothing waiting for one) counts like a finished seat -- with no pressure and the room on every card P wakes. A live D seat still holds P until it ends. The front passes d_idle = not (_d_seats_live or _ready_for_d). - FLLIPER_PDFLIP_DUAL_D_SIGNAL_SEATS and FLLIPER_PDFLIP_DUAL_D_SIGNAL_LOCKED default ON (user order 14.10.); =0 = the old reading. A standing table fill with no D work is no pressure, so P does not lend/sleep at boot. - The front's reading tolerates stubs without _d_seats_live / a bound sgl-project#1480 gate (both default on now). Rank agreement unchanged (front decides alone, SOLL R11); no reserve; features stay on. Tests (serial, flock, MemoryMax=2G, DevicePolicy=closed, CUDA_VISIBLE_DEVICES=""): new test_27b_dual_p_asleep_long_waits_1022 (5: boot without D work does not sleep P; P asleep + LONG waiting + idle D wakes, with the standing 0.99 signal and without any signal; a live seat still waits for its end; pure rule): 31c8d07 sources 4 red -> green. 1540/1976/1480/q660 re-pinned to the new defaults (off = explicit 0). Isolated 8 dual modules: 31c8d07 sources 21 failed -> fix 2 failed (dual22_resume_order, 1002::test_b1, both red at a4f4b8f as well). Battery of 65 modules: 3 failed / 1241 passed (the two above + told_anchor_hold_y9d4::test_q610, order effect only, green in isolation).
Pytorch already support XPU device since 2.4 release and xpu is also supported in OpenAI Trition. So, it should works with the Trition attention backend in SGLang. In this PR, We add 'xpu' device into SGLang.
Blocked issue: The vllm is only compatible with 2.3 now and he binary whl support for torch xpu should be ready since torch-2.5(should be ready in the Oct/2024), so we should wait the vllm to be compatible with torch-2.5.
Status
Both XPU & CUDA works with latency benchmark
LLama-2-7b works for the latency benchmark.
VLLM_TEST_COMPILE_NO_CUSTOM_OPS=1 python -m sglang.bench_latency --model-path ~/.cache/huggingface/hub/models--meta-llama--Llama-2-7b-hf/snapshots/6fdf2e60f86ff2481f2241aaee459f85b5b0bbb9/ --device xxxx
Both XPU & CUDA generate same outputs with launch_server
python -m sglang.launch_server --model-path ~/models/llama7b/6fdf2e60f86ff2481f2241aaee459f85b5b0bbb9/ --port 30000 --device xxx
ToDO In other PRs:
Functionality
Performance