Update XPU Docker runtime stack & hf_home config (#23820)
Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
This commit is contained in:
@@ -72,8 +72,6 @@ jobs:
|
|||||||
needs: [check-changes, pr-gate]
|
needs: [check-changes, pr-gate]
|
||||||
if: needs.check-changes.outputs.main_package == 'true'
|
if: needs.check-changes.outputs.main_package == 'true'
|
||||||
runs-on: intel-bmg
|
runs-on: intel-bmg
|
||||||
env:
|
|
||||||
HF_HOME: /home/sdp/.cache/huggingface
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -99,8 +97,10 @@ jobs:
|
|||||||
container_id=$(docker run -dt \
|
container_id=$(docker run -dt \
|
||||||
--group-add 992 \
|
--group-add 992 \
|
||||||
--group-add $(getent group video | cut -d: -f3) \
|
--group-add $(getent group video | cut -d: -f3) \
|
||||||
-v ${HF_HOME}:/root/.cache/huggingface \
|
--group-add $(getent group render | cut -d: -f3) \
|
||||||
|
-v $HOME/.cache/huggingface:/root/.cache/huggingface \
|
||||||
--device /dev/dri \
|
--device /dev/dri \
|
||||||
|
-v /dev/dri/by-path:/dev/dri/by-path \
|
||||||
-e HF_TOKEN="$(cat ~/huggingface_token.txt)" \
|
-e HF_TOKEN="$(cat ~/huggingface_token.txt)" \
|
||||||
xpu_sglang_main:bmg)
|
xpu_sglang_main:bmg)
|
||||||
echo "Started container: $container_id"
|
echo "Started container: $container_id"
|
||||||
|
|||||||
+10
-6
@@ -20,6 +20,16 @@ ARG SG_LANG_KERNEL_BRANCH=main
|
|||||||
RUN useradd -m -d /home/sdp -s /bin/bash sdp && \
|
RUN useradd -m -d /home/sdp -s /bin/bash sdp && \
|
||||||
chown -R sdp:sdp /home/sdp
|
chown -R sdp:sdp /home/sdp
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Install the latest UMD driver for SYCL-TLA
|
||||||
|
RUN apt-get install -y software-properties-common && \
|
||||||
|
add-apt-repository -y ppa:kobuk-team/intel-graphics && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y libze-intel-gpu1 libze1 intel-metrics-discovery intel-opencl-icd clinfo intel-gsc && \
|
||||||
|
apt-get install -y intel-media-va-driver-non-free libmfx-gen1 libvpl2 libvpl-tools libva-glx2 va-driver-all vainfo && \
|
||||||
|
apt-get install -y libze-dev intel-ocloc
|
||||||
|
|
||||||
# Switch to non-root user 'sdp'
|
# Switch to non-root user 'sdp'
|
||||||
USER sdp
|
USER sdp
|
||||||
|
|
||||||
@@ -38,12 +48,6 @@ RUN curl -fsSL -v -o miniforge.sh -O https://github.com/conda-forge/miniforge/re
|
|||||||
# Append environment activation to .bashrc for interactive shells
|
# Append environment activation to .bashrc for interactive shells
|
||||||
echo ". /home/sdp/miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; . /opt/intel/oneapi/setvars.sh; cd /home/sdp" >> /home/sdp/.bashrc
|
echo ". /home/sdp/miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; . /opt/intel/oneapi/setvars.sh; cd /home/sdp" >> /home/sdp/.bashrc
|
||||||
|
|
||||||
USER root
|
|
||||||
RUN apt-get update && apt install -y intel-ocloc
|
|
||||||
|
|
||||||
# Switch back to user sdp
|
|
||||||
USER sdp
|
|
||||||
|
|
||||||
RUN --mount=type=secret,id=github_token \
|
RUN --mount=type=secret,id=github_token \
|
||||||
cd /home/sdp && \
|
cd /home/sdp && \
|
||||||
. /home/sdp/miniforge3/bin/activate && \
|
. /home/sdp/miniforge3/bin/activate && \
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
python3 -m unittest test_deepseek_ocr.py
|
python3 -m unittest test_deepseek_ocr.py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import gc
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
@@ -21,22 +20,8 @@ from sglang.test.test_utils import (
|
|||||||
|
|
||||||
|
|
||||||
class TestDeepSeekOCR(CustomTestCase):
|
class TestDeepSeekOCR(CustomTestCase):
|
||||||
@classmethod
|
|
||||||
def _cleanup_xpu_memory(cls):
|
|
||||||
gc.collect()
|
|
||||||
try:
|
|
||||||
import torch
|
|
||||||
|
|
||||||
if hasattr(torch, "xpu") and torch.xpu.is_available():
|
|
||||||
torch.xpu.synchronize()
|
|
||||||
torch.xpu.empty_cache()
|
|
||||||
except Exception:
|
|
||||||
# Best-effort cleanup only; tests should continue if cleanup is unavailable.
|
|
||||||
pass
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls._cleanup_xpu_memory()
|
|
||||||
cls.model = "deepseek-ai/DeepSeek-OCR"
|
cls.model = "deepseek-ai/DeepSeek-OCR"
|
||||||
cls.tokenizer = get_tokenizer(cls.model)
|
cls.tokenizer = get_tokenizer(cls.model)
|
||||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||||
@@ -65,8 +50,12 @@ class TestDeepSeekOCR(CustomTestCase):
|
|||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
"""Fixture that is run once after all tests in the class."""
|
"""Fixture that is run once after all tests in the class."""
|
||||||
if hasattr(cls, "process") and cls.process:
|
if hasattr(cls, "process") and cls.process:
|
||||||
|
cls.process.terminate()
|
||||||
|
try:
|
||||||
|
cls.process.wait(timeout=30)
|
||||||
|
except Exception:
|
||||||
|
# Force kill if it didn't exit cleanly in time
|
||||||
kill_process_tree(cls.process.pid)
|
kill_process_tree(cls.process.pid)
|
||||||
cls._cleanup_xpu_memory()
|
|
||||||
|
|
||||||
def get_request_json(self, max_new_tokens=32, n=1):
|
def get_request_json(self, max_new_tokens=32, n=1):
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import test_deepseek_ocr as deepseek_ocr
|
from test_deepseek_ocr import TestDeepSeekOCR
|
||||||
|
|
||||||
from sglang.srt.utils.hf_transformers import get_tokenizer
|
from sglang.srt.utils.hf_transformers import get_tokenizer
|
||||||
from sglang.test.test_utils import (
|
from sglang.test.test_utils import (
|
||||||
@@ -16,10 +16,11 @@ from sglang.test.test_utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestDeepSeekOCRTriton(deepseek_ocr.TestDeepSeekOCR):
|
# TODO: Temporarily disable this test and re-enable it after Triton-XPU is upgraded.
|
||||||
|
@unittest.skip("Temporarily disabled until Triton-XPU upgrade")
|
||||||
|
class TestDeepSeekOCRTriton(TestDeepSeekOCR):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls._cleanup_xpu_memory()
|
|
||||||
cls.model = "deepseek-ai/DeepSeek-OCR"
|
cls.model = "deepseek-ai/DeepSeek-OCR"
|
||||||
cls.tokenizer = get_tokenizer(cls.model)
|
cls.tokenizer = get_tokenizer(cls.model)
|
||||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||||
@@ -45,5 +46,8 @@ class TestDeepSeekOCRTriton(deepseek_ocr.TestDeepSeekOCR):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Prevent pytest from collecting the imported base test class here.
|
||||||
|
del TestDeepSeekOCR
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Usage:
|
|||||||
python3 -m unittest test_intel_xpu_backend.TestIntelXPUBackend.test_latency_qwen_model
|
python3 -m unittest test_intel_xpu_backend.TestIntelXPUBackend.test_latency_qwen_model
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import gc
|
|
||||||
import unittest
|
import unittest
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
@@ -16,29 +15,17 @@ from sglang.test.test_utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _cleanup_xpu_memory():
|
def intel_xpu_benchmark(
|
||||||
gc.collect()
|
extra_args=None, min_throughput=None, mem_fraction_static="0.4"
|
||||||
try:
|
):
|
||||||
import torch
|
|
||||||
|
|
||||||
if hasattr(torch, "xpu") and torch.xpu.is_available():
|
|
||||||
torch.xpu.synchronize()
|
|
||||||
torch.xpu.empty_cache()
|
|
||||||
except Exception:
|
|
||||||
# Best-effort cleanup only.
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def intel_xpu_benchmark(extra_args=None, min_throughput=None):
|
|
||||||
def decorator(test_func):
|
def decorator(test_func):
|
||||||
@wraps(test_func)
|
@wraps(test_func)
|
||||||
def wrapper(self):
|
def wrapper(self):
|
||||||
_cleanup_xpu_memory()
|
|
||||||
common_args = [
|
common_args = [
|
||||||
"--disable-radix",
|
"--disable-radix",
|
||||||
"--trust-remote-code",
|
"--trust-remote-code",
|
||||||
"--mem-fraction-static",
|
"--mem-fraction-static",
|
||||||
"0.4",
|
str(mem_fraction_static),
|
||||||
"--batch-size",
|
"--batch-size",
|
||||||
"1",
|
"1",
|
||||||
"--device",
|
"--device",
|
||||||
@@ -48,12 +35,9 @@ def intel_xpu_benchmark(extra_args=None, min_throughput=None):
|
|||||||
full_args = common_args + ci_args + (extra_args or [])
|
full_args = common_args + ci_args + (extra_args or [])
|
||||||
|
|
||||||
model = test_func(self)
|
model = test_func(self)
|
||||||
try:
|
prefill_latency, decode_throughput, decode_latency = run_bench_one_batch(
|
||||||
prefill_latency, decode_throughput, decode_latency = (
|
model, full_args
|
||||||
run_bench_one_batch(model, full_args)
|
|
||||||
)
|
)
|
||||||
finally:
|
|
||||||
_cleanup_xpu_memory()
|
|
||||||
|
|
||||||
print(f"{model=}")
|
print(f"{model=}")
|
||||||
print(f"{prefill_latency=}")
|
print(f"{prefill_latency=}")
|
||||||
@@ -70,11 +54,14 @@ def intel_xpu_benchmark(extra_args=None, min_throughput=None):
|
|||||||
|
|
||||||
class TestIntelXPUBackend(CustomTestCase):
|
class TestIntelXPUBackend(CustomTestCase):
|
||||||
|
|
||||||
@intel_xpu_benchmark(min_throughput=10)
|
@intel_xpu_benchmark(min_throughput=10, mem_fraction_static="0.3")
|
||||||
def test_latency_qwen_model(self):
|
def test_latency_qwen_model(self):
|
||||||
return DEFAULT_SMALL_MODEL_NAME_FOR_TEST_QWEN
|
return DEFAULT_SMALL_MODEL_NAME_FOR_TEST_QWEN
|
||||||
|
|
||||||
@intel_xpu_benchmark(["--attention-backend", "intel_xpu", "--page-size", "128"])
|
@intel_xpu_benchmark(
|
||||||
|
["--attention-backend", "intel_xpu", "--page-size", "128"],
|
||||||
|
mem_fraction_static="0.5",
|
||||||
|
)
|
||||||
def test_attention_backend(self):
|
def test_attention_backend(self):
|
||||||
return DEFAULT_SMALL_MODEL_NAME_FOR_TEST_BASE
|
return DEFAULT_SMALL_MODEL_NAME_FOR_TEST_BASE
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user