diff --git a/.github/actions/download-rust-ext/action.yml b/.github/actions/download-rust-ext/action.yml index 7809793cef..84caee5e7d 100644 --- a/.github/actions/download-rust-ext/action.yml +++ b/.github/actions/download-rust-ext/action.yml @@ -13,7 +13,7 @@ inputs: cache_key_prefix: description: 'Must match what _pr-test-rust-ext-build.yml saves under.' required: false - default: rust-ext-x86_64-cp310-cp312 + default: rust-ext-x86_64-cp312 outputs: hit: diff --git a/.github/workflows/_pr-test-rust-ext-build.yml b/.github/workflows/_pr-test-rust-ext-build.yml index 73d19a6024..f91582a8c4 100644 --- a/.github/workflows/_pr-test-rust-ext-build.yml +++ b/.github/workflows/_pr-test-rust-ext-build.yml @@ -46,7 +46,7 @@ on: cache_key_prefix: description: 'Cache key prefix. Callers share it on purpose to reuse each other''s build; it encodes the arch and the interpreter ABI set, since the modules are portable across neither.' type: string - default: rust-ext-x86_64-cp310-cp312 + default: rust-ext-x86_64-cp312 max_glibc: description: > Highest GLIBC symbol version the built .so files may require. A ceiling set @@ -168,16 +168,12 @@ jobs: runs-on: ${{ inputs.runs_on }} timeout-minutes: 60 name: Build Rust Ext - # No crate sets abi3, so the pools' interpreters (h100 ships 3.10, h20 ships - # 3.12) each need their own module set, and each its own target dir, since - # PyO3's fingerprint tracks the interpreter. The two passes therefore share - # nothing, which is why they run as parallel jobs rather than back to back. + # No crate sets abi3, so each interpreter the stages run needs its own leg; + # keep this matrix in sync with CI_PYTHON_VER in ci_install_dependency.sh. strategy: - # Both legs run to completion, so a failure in one still leaves the other's - # log to compare against. fail-fast: false matrix: - python-version: ['3.10', '3.12'] + python-version: ['3.12'] steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/_pr-test-simulator-cpu.yml b/.github/workflows/_pr-test-simulator-cpu.yml index 6c47ce9c5e..40886e6b77 100644 --- a/.github/workflows/_pr-test-simulator-cpu.yml +++ b/.github/workflows/_pr-test-simulator-cpu.yml @@ -41,7 +41,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.12' - name: Install uv uses: astral-sh/setup-uv@v5 diff --git a/.github/workflows/_pr-test-stage-cpu.yml b/.github/workflows/_pr-test-stage-cpu.yml index bde128c73f..4d64b736ab 100644 --- a/.github/workflows/_pr-test-stage-cpu.yml +++ b/.github/workflows/_pr-test-stage-cpu.yml @@ -82,14 +82,14 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.12' - name: Install uv uses: astral-sh/setup-uv@v5 # This stage compiled the workspace too - 7+ minutes per partition on # billable hosted minutes. rust-ext-build's modules need an older glibc than - # this runner has, which is the safe direction, and both pin Python 3.10. + # this runner has, which is the safe direction, and both pin Python 3.12. - uses: ./.github/actions/download-rust-ext id: rust_ext with: diff --git a/.github/workflows/ci-coverage-overview.yml b/.github/workflows/ci-coverage-overview.yml index 96c4ce5721..f0b5ea570c 100644 --- a/.github/workflows/ci-coverage-overview.yml +++ b/.github/workflows/ci-coverage-overview.yml @@ -102,8 +102,16 @@ jobs: - name: Install dependencies timeout-minutes: 10 + # Keep this unpinned resolve out of /opt/sglang-ci-py*, which gated jobs reuse; + # `python3 -m uv` runs the uv just upgraded, not an older one on PATH. run: | - pip install -e "python/[test]" + venv="$RUNNER_TEMP/sglang-coverage-venv" + python3 -m pip install --upgrade uv + python3 -m uv python install --upgrade 3.12 --python-preference only-managed + python3 -m uv venv "$venv" --python 3.12 --python-preference only-managed --seed + echo "$venv/bin" >> "$GITHUB_PATH" + echo "VIRTUAL_ENV=$venv" >> "$GITHUB_ENV" + python3 -m uv pip install --python "$venv/bin/python3" -e "python/[test]" - name: Run unit tests with coverage # Non-gating on purpose: running the whole tree in one process diff --git a/.github/workflows/diffusion-ci-gt-gen.yml b/.github/workflows/diffusion-ci-gt-gen.yml index 75c46d96c8..3fe736e9ce 100644 --- a/.github/workflows/diffusion-ci-gt-gen.yml +++ b/.github/workflows/diffusion-ci-gt-gen.yml @@ -216,12 +216,12 @@ jobs: - name: Install official LTX repro dependencies if: matrix.source_group == 'ltx' || matrix.source_group == 'ltx23' run: | - UV_SYSTEM_PYTHON=1 uv pip install \ + uv pip install --python "$(command -v python3)" \ "transformers==4.52.4" \ openimageio \ --index-strategy unsafe-best-match \ --prerelease allow - UV_SYSTEM_PYTHON=1 uv pip uninstall kernels + uv pip uninstall --python "$(command -v python3)" kernels - name: Checkout official Wan2.1 repo if: matrix.source_group == 'wan21' diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 92ac2038e4..9d981e7af9 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -252,7 +252,7 @@ jobs: runs_on: ubuntu-22.04-arm collect_runs_on: ubuntu-22.04-arm artifact_name: rust-ext-aarch64 - cache_key_prefix: rust-ext-aarch64-cp310-cp312 + cache_key_prefix: rust-ext-aarch64-cp312 git_ref: ${{ inputs.git_ref || '' }} skip_pr_test_health_check: ${{ inputs.skip_pr_test_health_check == true || inputs.test_parallel_dispatch == true || inputs.run_all_tests == true }} secrets: inherit diff --git a/.github/workflows/release-pypi-nightly.yml b/.github/workflows/release-pypi-nightly.yml index 68da0726b8..6bd6aaa8fe 100644 --- a/.github/workflows/release-pypi-nightly.yml +++ b/.github/workflows/release-pypi-nightly.yml @@ -38,7 +38,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Install build dependencies run: | diff --git a/.github/workflows/release-pypi-pr.yml b/.github/workflows/release-pypi-pr.yml index 4ac208a91c..1da472f994 100644 --- a/.github/workflows/release-pypi-pr.yml +++ b/.github/workflows/release-pypi-pr.yml @@ -30,7 +30,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Generate PR wheel version id: gen_version diff --git a/.github/workflows/release-pypi.yml b/.github/workflows/release-pypi.yml index 06f255d75e..dd46f7e2cb 100644 --- a/.github/workflows/release-pypi.yml +++ b/.github/workflows/release-pypi.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.11", "3.12", "3.13"] arch: [x86_64, aarch64] include: - arch: x86_64 diff --git a/.github/workflows/rerun-test.yml b/.github/workflows/rerun-test.yml index 0ca63d75ae..b575744cc1 100644 --- a/.github/workflows/rerun-test.yml +++ b/.github/workflows/rerun-test.yml @@ -386,14 +386,14 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.12' - name: Install uv uses: astral-sh/setup-uv@v5 # Worth the most of the three jobs: this runner is hosted, so it has no # persistent cargo target dir and every dispatch compiled cold. Its - # setup-python pins the same 3.10 the modules were built against. + # setup-python pins the same 3.12 the modules were built against. - uses: ./.github/actions/download-rust-ext id: rust_ext @@ -471,7 +471,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.12' - name: Write back result to reply comment env: diff --git a/.github/workflows/seed-rust-ext-cache.yml b/.github/workflows/seed-rust-ext-cache.yml index 6740b16df8..7d3a7d2714 100644 --- a/.github/workflows/seed-rust-ext-cache.yml +++ b/.github/workflows/seed-rust-ext-cache.yml @@ -48,5 +48,5 @@ jobs: runs_on: ubuntu-22.04-arm collect_runs_on: ubuntu-22.04-arm artifact_name: rust-ext-aarch64 - cache_key_prefix: rust-ext-aarch64-cp310-cp312 + cache_key_prefix: rust-ext-aarch64-cp312 secrets: inherit diff --git a/docs/cookbook/autoregressive/MiniMax/MiniMax-M3.mdx b/docs/cookbook/autoregressive/MiniMax/MiniMax-M3.mdx index bfdb5af6c5..af2c2d37b7 100644 --- a/docs/cookbook/autoregressive/MiniMax/MiniMax-M3.mdx +++ b/docs/cookbook/autoregressive/MiniMax/MiniMax-M3.mdx @@ -93,7 +93,7 @@ Key characteristics as served by SGLang: - **GPU**: NVIDIA SM100 family — sm_100 (B200 / GB200) and sm_103 (B300 / GB300). - **Toolchain**: CUDA Toolkit with `nvcc` ≥ 12.x on `PATH` (or `CUDA_HOME` set) — the kernels are JIT-compiled at first import. -- **Python**: ≥ 3.10; **OS**: Linux — works on both **x86_64 and aarch64 (Grace, e.g. GB200 / GB300)**; the aarch64 build needs no source edits. +- **Python**: ≥ 3.11; **OS**: Linux — works on both **x86_64 and aarch64 (Grace, e.g. GB200 / GB300)**; the aarch64 build needs no source edits. diff --git a/docs/cookbook/autoregressive/Poolside/Laguna-XS.2.mdx b/docs/cookbook/autoregressive/Poolside/Laguna-XS.2.mdx index 62d9eef229..c5c2d4499a 100644 --- a/docs/cookbook/autoregressive/Poolside/Laguna-XS.2.mdx +++ b/docs/cookbook/autoregressive/Poolside/Laguna-XS.2.mdx @@ -53,7 +53,7 @@ For details, see the [Hugging Face model card](https://huggingface.co/poolside/L Laguna-XS.2 support is on `main` but not yet in a tagged release; install from the SGLang nightly wheel index, or pull a pre-built Docker image: ```bash Command -# Install SGLang via pip (CUDA 13) — requires Python 3.10 (nightly wheels are cp310 only) +# Install SGLang via pip (CUDA 13) — requires Python 3.10 (this nightly wheel is cp310 only) python3 -m pip install --upgrade pip python3 -m pip install --extra-index-url https://docs.sglang.ai/whl/cu130 \ "sglang[all]==0.5.12.dev20260509+g096ad02b0" diff --git a/docs/docs/developer_guide/bench_serving.mdx b/docs/docs/developer_guide/bench_serving.mdx index 5673ad3189..a5cb473314 100644 --- a/docs/docs/developer_guide/bench_serving.mdx +++ b/docs/docs/developer_guide/bench_serving.mdx @@ -25,7 +25,7 @@ If `--base-url` is provided, requests are sent to it. Otherwise, `--host` and `- ### Prerequisites -- Python 3.10+ +- Python 3.11+ - Dependencies typically used by this script: `aiohttp`, `numpy`, `requests`, `tqdm`, `transformers`, and for some datasets `datasets`, `pillow`, `pybase64`. Install as needed. - An inference server running and reachable via the endpoints above - If your server requires authentication, set environment variable `OPENAI_API_KEY` (used as `Authorization: Bearer `) diff --git a/docs/docs/developer_guide/serve_backend_plugins.mdx b/docs/docs/developer_guide/serve_backend_plugins.mdx index ddeda6fe7e..9f51257ac0 100644 --- a/docs/docs/developer_guide/serve_backend_plugins.mdx +++ b/docs/docs/developer_guide/serve_backend_plugins.mdx @@ -13,7 +13,7 @@ The extension retains its own argument parser, process topology, API endpoints, ## Prerequisites -- Install your extension and a compatible SGLang version in the same Python 3.10+ environment. +- Install your extension and a compatible SGLang version in the same Python 3.11+ environment. - Declare the SGLang version range tested by your extension in its package dependencies. - Keep the backend factory and detector independent of GPU initialization and model loading. diff --git a/docs/docs/get-started/install.mdx b/docs/docs/get-started/install.mdx index e24082785f..9065a2ddab 100644 --- a/docs/docs/get-started/install.mdx +++ b/docs/docs/get-started/install.mdx @@ -61,7 +61,7 @@ The container shell is ready for `sglang serve`. -Use Python 3.10 or higher and a compatible CUDA 13 environment. +Use Python 3.11 or higher and a compatible CUDA 13 environment. @@ -111,7 +111,7 @@ For `CUDA_HOME` errors, see [Troubleshooting](#cuda_home). -Use Python 3.10 or higher in an activated Python environment, with CUDA dependencies appropriate for the version you build. +Use Python 3.11 or higher in an activated Python environment, with CUDA dependencies appropriate for the version you build. **Get the source** diff --git a/python/pyproject.toml b/python/pyproject.toml index 324b6929f9..c1cff46ed9 100755 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,7 +13,7 @@ name = "sglang" dynamic = ["version"] description = "SGLang is a fast serving framework for large language models and vision language models." readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.11" license = { file = "LICENSE" } classifiers = [ "Programming Language :: Python :: 3", @@ -86,7 +86,6 @@ dependencies = [ "timm==1.0.16", "tokenizers==0.23.2", "tokenspeed_mla==0.1.8", - "tomli ; python_version < '3.11'", "torch==2.14.1", "torch_memory_saver>=0.0.9.post1", "torchaudio==2.11.0", diff --git a/python/pyproject_cpu.toml b/python/pyproject_cpu.toml index 01096f2a4d..964c9159a1 100644 --- a/python/pyproject_cpu.toml +++ b/python/pyproject_cpu.toml @@ -8,7 +8,7 @@ name = "sglang-cpu" dynamic = ["version"] description = "SGLang is a fast serving framework for large language models and vision language models." readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.11" license = { file = "LICENSE" } classifiers = [ "Programming Language :: Python :: 3", diff --git a/python/pyproject_npu.toml b/python/pyproject_npu.toml index 3bc34ee5ef..42a4d83acf 100644 --- a/python/pyproject_npu.toml +++ b/python/pyproject_npu.toml @@ -7,7 +7,7 @@ name = "sglang" dynamic = ["version"] description = "SGLang is a fast serving framework for large language models and vision language models." readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.11" license = { file = "LICENSE" } classifiers = [ "Programming Language :: Python :: 3", diff --git a/python/pyproject_xpu.toml b/python/pyproject_xpu.toml index 5cb72360dc..2256a8417e 100644 --- a/python/pyproject_xpu.toml +++ b/python/pyproject_xpu.toml @@ -7,7 +7,7 @@ name = "sglang" dynamic = ["version"] description = "SGLang is a fast serving framework for large language models and vision language models." readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.11" license = { file = "LICENSE" } classifiers = [ "Programming Language :: Python :: 3", diff --git a/python/sglang/multimodal_gen/runtime/entrypoints/http_server.py b/python/sglang/multimodal_gen/runtime/entrypoints/http_server.py index f67de09570..6e559e0e63 100644 --- a/python/sglang/multimodal_gen/runtime/entrypoints/http_server.py +++ b/python/sglang/multimodal_gen/runtime/entrypoints/http_server.py @@ -46,6 +46,7 @@ from sglang.multimodal_gen.runtime.utils.logging_utils import ( globally_suppress_loggers, init_logger, ) +from sglang.srt.observability.trace import fastapi_telemetry_disabled_kwargs from sglang.srt.utils.common import ( add_prometheus_middleware, add_prometheus_track_response_middleware, @@ -430,7 +431,7 @@ def create_app(server_args: ServerArgs): Create and configure the FastAPI application instance. """ globally_suppress_loggers() - app = FastAPI(lifespan=lifespan) + app = FastAPI(lifespan=lifespan, **fastapi_telemetry_disabled_kwargs()) if server_args.enable_metrics: configure_metrics() add_prometheus_middleware(app) diff --git a/python/sglang/multimodal_gen/test/unit/test_minimax_h3_streamed_encode.py b/python/sglang/multimodal_gen/test/unit/test_minimax_h3_streamed_encode.py index d1c099e9d2..e4b7950524 100644 --- a/python/sglang/multimodal_gen/test/unit/test_minimax_h3_streamed_encode.py +++ b/python/sglang/multimodal_gen/test/unit/test_minimax_h3_streamed_encode.py @@ -104,10 +104,7 @@ class TestDecodeHandsOutFinishedFrames(CustomTestCase): ) -@unittest.skipUnless( - torch.cuda.is_available() and hasattr(os, "memfd_create"), - "needs CUDA and memfd", -) +@unittest.skipUnless(condition=torch.cuda.is_available(), reason="needs CUDA") class TestStreamedEncode(CustomTestCase): @staticmethod def _video(height: int, width: int) -> torch.Tensor: diff --git a/python/sglang/multimodal_gen/test/unit/test_wan_streamed_encode.py b/python/sglang/multimodal_gen/test/unit/test_wan_streamed_encode.py index d1bdbe9cde..03aa0c13dd 100644 --- a/python/sglang/multimodal_gen/test/unit/test_wan_streamed_encode.py +++ b/python/sglang/multimodal_gen/test/unit/test_wan_streamed_encode.py @@ -5,7 +5,6 @@ The frame hand-off itself is covered in python/sglang/multimodal_gen/test/unit/test_wan_vae_on_frames.py. """ -import os import tempfile import unittest from pathlib import Path @@ -103,10 +102,7 @@ def _video_request(**overrides) -> SimpleNamespace: return SimpleNamespace(**fields) -@unittest.skipUnless( - torch.cuda.is_available() and hasattr(os, "memfd_create"), - "needs CUDA and memfd", -) +@unittest.skipUnless(condition=torch.cuda.is_available(), reason="needs CUDA") class TestStreamedEncode(CustomTestCase): @torch.no_grad() def test_hunyuan_without_callback_matches_one_shot_mp4(self): diff --git a/python/sglang/srt/disaggregation/encoder/http_server.py b/python/sglang/srt/disaggregation/encoder/http_server.py index 29053ef0c4..6d6f557ebb 100644 --- a/python/sglang/srt/disaggregation/encoder/http_server.py +++ b/python/sglang/srt/disaggregation/encoder/http_server.py @@ -47,6 +47,7 @@ from sglang.srt.managers.io_struct import ( wrap_as_pickle, ) from sglang.srt.managers.schedule_batch import Modality +from sglang.srt.observability.trace import fastapi_telemetry_disabled_kwargs from sglang.srt.runtime_context import ( get_disagg, get_observability, @@ -100,7 +101,7 @@ async def _lifespan(app: FastAPI): await local_runtime.stop() -app = FastAPI(lifespan=_lifespan) +app = FastAPI(lifespan=_lifespan, **fastapi_telemetry_disabled_kwargs()) def _register_encoder_url_with_bootstrap(): diff --git a/python/sglang/srt/disaggregation/encoder/receiver.py b/python/sglang/srt/disaggregation/encoder/receiver.py index 4fa9e1149d..e9e4dec545 100644 --- a/python/sglang/srt/disaggregation/encoder/receiver.py +++ b/python/sglang/srt/disaggregation/encoder/receiver.py @@ -36,6 +36,7 @@ from sglang.srt.managers.multimodal_processor import get_mm_processor, import_pr from sglang.srt.managers.schedule_batch import Modality, Req from sglang.srt.multimodal.cache import media_preprocess_kwargs from sglang.srt.multimodal.transport import determine_tensor_transport_mode +from sglang.srt.observability.trace import fastapi_telemetry_disabled_kwargs from sglang.srt.runtime_context import ( get_device, get_disagg, @@ -164,7 +165,9 @@ class EncoderBootstrapServer: except (asyncio.CancelledError, Exception): pass - self.app = FastAPI(lifespan=lifespan, openapi_url=None) + self.app = FastAPI( + lifespan=lifespan, openapi_url=None, **fastapi_telemetry_disabled_kwargs() + ) @self.app.get("/health") async def _health() -> Response: diff --git a/python/sglang/srt/distributed/gated_launch.py b/python/sglang/srt/distributed/gated_launch.py index 09fd229d44..6e281b0ad8 100644 --- a/python/sglang/srt/distributed/gated_launch.py +++ b/python/sglang/srt/distributed/gated_launch.py @@ -10,6 +10,7 @@ from fastapi import FastAPI from fastapi.responses import PlainTextResponse from sglang.srt.distributed.parallel_state import get_world_group +from sglang.srt.observability.trace import fastapi_telemetry_disabled_kwargs logger = logging.getLogger(__name__) @@ -82,7 +83,7 @@ class _GatedLaunchServer: def _build_app(server: _GatedLaunchServer) -> FastAPI: - app = FastAPI() + app = FastAPI(**fastapi_telemetry_disabled_kwargs()) @app.get("/health") def health(): diff --git a/python/sglang/srt/entrypoints/engine_info_bootstrap_server.py b/python/sglang/srt/entrypoints/engine_info_bootstrap_server.py index 77de7fc7d0..7d933bf69c 100644 --- a/python/sglang/srt/entrypoints/engine_info_bootstrap_server.py +++ b/python/sglang/srt/entrypoints/engine_info_bootstrap_server.py @@ -20,6 +20,8 @@ import uvicorn from fastapi import FastAPI, HTTPException from fastapi.responses import PlainTextResponse +from sglang.srt.observability.trace import fastapi_telemetry_disabled_kwargs + logger = logging.getLogger(__name__) @@ -42,7 +44,7 @@ class EngineInfoBootstrapServer: self.transfer_engine_info: Dict[int, Tuple] = {} self.lock = threading.Lock() - app = FastAPI() + app = FastAPI(**fastapi_telemetry_disabled_kwargs()) @app.get("/health") def health(): diff --git a/python/sglang/srt/entrypoints/http_server.py b/python/sglang/srt/entrypoints/http_server.py index c662f6a2f5..609d790ca3 100644 --- a/python/sglang/srt/entrypoints/http_server.py +++ b/python/sglang/srt/entrypoints/http_server.py @@ -169,6 +169,7 @@ from sglang.srt.managers.multi_tokenizer_mixin import ( from sglang.srt.managers.tokenizer_manager import ServerStatus, TokenizerManager from sglang.srt.observability.func_timer import enable_func_timer from sglang.srt.observability.trace import ( + fastapi_telemetry_disabled_kwargs, process_tracing_init, set_global_trace_level, trace_set_thread_info, @@ -479,6 +480,7 @@ class ORJSONRoute(APIRoute): app = FastAPI( lifespan=lifespan, openapi_url=None if get_bool_env_var("DISABLE_OPENAPI_DOC") else "/openapi.json", + **fastapi_telemetry_disabled_kwargs(), ) app.router.route_class = ORJSONRoute app.add_middleware( diff --git a/python/sglang/srt/observability/trace.py b/python/sglang/srt/observability/trace.py index 127be7f2b9..0599fe432f 100644 --- a/python/sglang/srt/observability/trace.py +++ b/python/sglang/srt/observability/trace.py @@ -269,6 +269,11 @@ def get_global_tracing_enabled(): return opentelemetry_initialized +def fastapi_telemetry_disabled_kwargs() -> Dict[str, Any]: + # FastAPI traces every request under process_tracing_init's provider by default. + return {"telemetry": {"tracing": False, "metrics": False, "logs": False}} + + def get_otlp_span_exporter(endpoint): protocol = os.environ.get(OTEL_EXPORTER_OTLP_TRACES_PROTOCOL, "grpc") supported_protocols = {"grpc", "http/protobuf"} diff --git a/python/sglang/srt/utils/common.py b/python/sglang/srt/utils/common.py index b935de39aa..fa07444af5 100644 --- a/python/sglang/srt/utils/common.py +++ b/python/sglang/srt/utils/common.py @@ -3678,9 +3678,10 @@ def launch_dummy_health_check_server(host, port, enable_metrics): import uvicorn from fastapi import FastAPI, Response + from sglang.srt.observability.trace import fastapi_telemetry_disabled_kwargs from sglang.srt.utils.network import NetworkAddress - app = FastAPI() + app = FastAPI(**fastapi_telemetry_disabled_kwargs()) @app.get("/ping") async def ping(): diff --git a/rust/sglang-grpc/pyproject.toml b/rust/sglang-grpc/pyproject.toml index 83fc607dea..4072ce844b 100644 --- a/rust/sglang-grpc/pyproject.toml +++ b/rust/sglang-grpc/pyproject.toml @@ -12,7 +12,7 @@ build-backend = "maturin" name = "sglang-grpc" dynamic = ["version"] description = "In-process Rust gRPC server for SGLang" -requires-python = ">=3.10" +requires-python = ">=3.11" [tool.maturin] module-name = "_grpc" diff --git a/rust/sglang-mm/pyproject.toml b/rust/sglang-mm/pyproject.toml index 1ef9cdec37..4f80aafc83 100644 --- a/rust/sglang-mm/pyproject.toml +++ b/rust/sglang-mm/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "maturin" name = "sglang-mm" dynamic = ["version"] description = "Rust-accelerated multimodal preprocessing for SGLang" -requires-python = ">=3.10" +requires-python = ">=3.11" [tool.maturin] module-name = "_multimodal" diff --git a/rust/sglang-server/pyproject.toml b/rust/sglang-server/pyproject.toml index 7e332b5095..707a0ff9ed 100644 --- a/rust/sglang-server/pyproject.toml +++ b/rust/sglang-server/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "sglang-server" -requires-python = ">=3.10" +requires-python = ">=3.11" classifiers = [ "Programming Language :: Rust", "Programming Language :: Python :: Implementation :: CPython", diff --git a/scripts/ci/cuda/ci_install_dependency.sh b/scripts/ci/cuda/ci_install_dependency.sh index b66b50e10e..5c890ec60a 100755 --- a/scripts/ci/cuda/ci_install_dependency.sh +++ b/scripts/ci/cuda/ci_install_dependency.sh @@ -55,36 +55,67 @@ configure_environment() { USE_VENV="${USE_VENV:-0}" echo "USE_VENV=${USE_VENV}" - python3 -m pip install --upgrade pip - if ! command -v uv >/dev/null 2>&1; then - pip install uv + # A stale uv only knows the managed Python builds released before it. + python3 -m pip install --upgrade pip uv + # Put that uv ahead of any older copy on PATH (runner image, standalone installer). + UV_BIN_DIR="$(dirname "$(python3 -c 'import uv; print(uv.find_uv_bin())')")" + export PATH="${UV_BIN_DIR}:${PATH}" + if [ -n "${GITHUB_PATH:-}" ]; then + mkdir -p "$(dirname "$GITHUB_PATH")" 2>/dev/null || true + echo "$UV_BIN_DIR" >> "$GITHUB_PATH" || true + fi + uv --version + + # Every job installs into a uv-managed venv, whatever Python the runner image ships. + # Keep in sync with the python-version matrix in _pr-test-rust-ext-build.yml. + CI_PYTHON_VER="3.12" + + # Managed builds ship Python.h, which Triton's runtime launcher compiles against. + # The download comes from github.com, which some pools reach slowly enough to time + # out this step, so keep the installed build unless it predates os.memfd_create + # (python-build-standalone before 20260718). --upgrade repoints uv's minor-version + # link at the latest patch; a kept venv follows it. + CI_PYTHON_BIN="$(uv python find "$CI_PYTHON_VER" --system --python-preference only-managed 2>/dev/null || true)" + if [ -z "$CI_PYTHON_BIN" ] || ! "$CI_PYTHON_BIN" -c 'import os; os.memfd_create' 2>/dev/null; then + uv python install --upgrade "$CI_PYTHON_VER" --python-preference only-managed fi - SYS_PYTHON_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") - + UV_VENV_COMPLETE_MARKER="" if [ "$USE_VENV" = "1" ]; then UV_VENV="/tmp/sglang-ci-${GITHUB_RUN_ID:-norun}-${GITHUB_JOB:-nojob}-$$" - uv venv "$UV_VENV" --python "python${SYS_PYTHON_VER}" --seed - # shellcheck disable=SC1091 - source "$UV_VENV/bin/activate" - [ "${VIRTUAL_ENV:-}" = "$UV_VENV" ] || { echo "FATAL: venv activation did not set VIRTUAL_ENV correctly"; exit 1; } - [ "$(command -v python3)" = "$UV_VENV/bin/python3" ] || { echo "FATAL: python3 still resolves outside venv (got $(command -v python3))"; exit 1; } - - if [ -n "${GITHUB_ENV:-}" ]; then - # Self-heal: see install_rustup.sh for context on missing _runner_file_commands/. - mkdir -p "$(dirname "$GITHUB_ENV")" 2>/dev/null || true - echo "VIRTUAL_ENV=$UV_VENV" >> "$GITHUB_ENV" || true - echo "SGLANG_CI_VENV_PATH=$UV_VENV" >> "$GITHUB_ENV" || true - echo "BASH_ENV=$UV_VENV/env.sh" >> "$GITHUB_ENV" || true - touch "$UV_VENV/env.sh" - fi - if [ -n "${GITHUB_PATH:-}" ]; then - mkdir -p "$(dirname "$GITHUB_PATH")" 2>/dev/null || true - echo "$UV_VENV/bin" >> "$GITHUB_PATH" || true - fi + uv venv "$UV_VENV" --python "$CI_PYTHON_VER" --python-preference only-managed --seed else - echo "USE_VENV=0: skipping uv venv creation, installing into system Python" - UV_VENV="" + # Kept across jobs so installs stay incremental and path-keyed JIT caches hit. + UV_VENV="/opt/sglang-ci-py${CI_PYTHON_VER}" + # A cancelled install leaves dist-info that later installs treat as satisfied; + # rebuild unless the last install ran to completion. + UV_VENV_COMPLETE_MARKER="$UV_VENV/.install-complete" + if [ ! -f "$UV_VENV_COMPLETE_MARKER" ]; then + rm -rf "$UV_VENV" + uv venv "$UV_VENV" --python "$CI_PYTHON_VER" --python-preference only-managed --seed + fi + rm -f "$UV_VENV_COMPLETE_MARKER" + fi + + # shellcheck disable=SC1091 + source "$UV_VENV/bin/activate" + [ "${VIRTUAL_ENV:-}" = "$UV_VENV" ] || { echo "FATAL: venv activation did not set VIRTUAL_ENV correctly"; exit 1; } + [ "$(command -v python3)" = "$UV_VENV/bin/python3" ] || { echo "FATAL: python3 still resolves outside venv (got $(command -v python3))"; exit 1; } + + if [ -n "${GITHUB_ENV:-}" ]; then + # Self-heal: see install_rustup.sh for context on missing _runner_file_commands/. + mkdir -p "$(dirname "$GITHUB_ENV")" 2>/dev/null || true + echo "VIRTUAL_ENV=$UV_VENV" >> "$GITHUB_ENV" || true + # ci_cleanup_venv.sh deletes this path, so only the per-job venv exports it. + if [ "$USE_VENV" = "1" ]; then + echo "SGLANG_CI_VENV_PATH=$UV_VENV" >> "$GITHUB_ENV" || true + fi + echo "BASH_ENV=$UV_VENV/env.sh" >> "$GITHUB_ENV" || true + : > "$UV_VENV/env.sh" + fi + if [ -n "${GITHUB_PATH:-}" ]; then + mkdir -p "$(dirname "$GITHUB_PATH")" 2>/dev/null || true + echo "$UV_VENV/bin" >> "$GITHUB_PATH" || true fi mark_step_done "${FUNCNAME[0]}" @@ -382,14 +413,8 @@ release_cargo_cache_lock() { } setup_pip_toolchain() { - if [ "$USE_VENV" = "1" ]; then - # The bootstrap upgrade hit system pip; this upgrades the venv's own. - python3 -m pip install --upgrade pip - fi - - if [ "$USE_VENV" != "1" ]; then - export UV_SYSTEM_PYTHON=1 - fi + # The bootstrap upgrade hit system pip; this upgrades the venv's own. + python3 -m pip install --upgrade pip export UV_LINK_MODE=copy PIP_CMD="uv pip" @@ -548,9 +573,8 @@ require_prebuilt_rust_exts() { # Exact EXT_SUFFIX rather than an _*.so glob: no crate sets abi3, so a module # built for another minor version satisfies the glob while the import system # ignores it, leaving is_rust_server_built() false and the Rust-server tests - # silently skipped. Stages have no setup-python, so the interpreter is whatever - # the image ships, and the pools are not on one version (h20 is 3.12 while - # h100 is 3.10) - a mismatch is drift to route around, not a failure. + # silently skipped. A CI_PYTHON_VER outside the build matrix has no module; + # build it from source rather than fail. local suffix suffix=$(python3 -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))') local missing=() @@ -809,7 +833,9 @@ install_extra_deps() { fi if [ "$IS_BLACKWELL" != "1" ]; then - $PIP_CMD install "lmms_eval==0.5.0" $PIP_INSTALL_SUFFIX + # pyarrow 26 needs NumPy 2 at import, but lmms_eval pins numpy 1.26.4; + # drop the cap once lmms_eval allows NumPy 2. + $PIP_CMD install "lmms_eval==0.5.0" "pyarrow<26" $PIP_INSTALL_SUFFIX # lmms_eval 0.5.0 pulls antlr4-python3-runtime==4.7.2, clobbering the # 4.9.3 that sgl-eval's latex2sympy2_extended needs (4.7.2 ImportError # at sgl-eval import). Pin it back so the nightly sgl-eval path works. @@ -835,9 +861,7 @@ setup_ld_library_path() { VENV_LD="${NVIDIA_LIBS}${TORCH_LIB}" export LD_LIBRARY_PATH="${VENV_LD}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - if [ "$USE_VENV" = "1" ] && [ -n "$UV_VENV" ]; then - echo "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" >> "$UV_VENV/env.sh" - fi + echo "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" >> "$UV_VENV/env.sh" if [ -n "${GITHUB_ENV:-}" ]; then echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> "$GITHUB_ENV" || echo "WARNING: GITHUB_ENV write failed; LD_LIBRARY_PATH will be set via BASH_ENV instead" fi @@ -943,6 +967,9 @@ main() { prepare_runner setup_ld_library_path verify_imports + if [ -n "$UV_VENV_COMPLETE_MARKER" ]; then + touch "$UV_VENV_COMPLETE_MARKER" + fi } main "$@" diff --git a/scripts/ci/test_diffusion_rust_gate.py b/scripts/ci/test_diffusion_rust_gate.py index 455844ac41..72bf8c1830 100644 --- a/scripts/ci/test_diffusion_rust_gate.py +++ b/scripts/ci/test_diffusion_rust_gate.py @@ -85,19 +85,33 @@ class TestDiffusionRustGate(unittest.TestCase): functions + """ mark_step_done() { :; } -python3() { if [ "$1" = "-c" ]; then echo .test.so; fi; } -uv() { :; } +# python3 must be a file, not a function, so the venv's copy wins on PATH. +mkdir bin +printf '#!/bin/sh\\nif [ "$1" = "-c" ]; then echo .test.so; fi\\n' > bin/python3 +chmod +x bin/python3 +PATH="$PWD/bin:$PATH" +uv() { + if [ "$1" = venv ]; then + mkdir -p "$2/bin" + cp bin/python3 "$2/bin/python3" + printf 'VIRTUAL_ENV=%s\\nPATH=%s/bin:$PATH\\n' "$2" "$2" > "$2/bin/activate" + fi +} pip() { :; } configure_environment "$1" require_prebuilt_rust_exts if [ "$1" = diffusion ]; then setup_cargo_cache; fi printf 'RESULT=%s:%s\n' "$SGLANG_BUILD_RUST_EXTS" "$SGLANG_RUST_BUILD_MODE" +rm -rf "$UV_VENV" """ ) env = dict( os.environ, GITHUB_ENV=f"{tmp}/env", - USE_VENV="0", + GITHUB_PATH=f"{tmp}/path", + # The per-job venv lives under /tmp; the persistent one is the + # runner's real /opt/sglang-ci-py*, which this test must not touch. + USE_VENV="1", SGLANG_BUILD_RUST_EXTS="none", SGLANG_RUST_BUILD_MODE="never", ) diff --git a/test/registered/hicache/test_hicache_storage_mooncake_backend.py b/test/registered/hicache/test_hicache_storage_mooncake_backend.py index e2e036fd3a..c5f11f46ca 100644 --- a/test/registered/hicache/test_hicache_storage_mooncake_backend.py +++ b/test/registered/hicache/test_hicache_storage_mooncake_backend.py @@ -1,7 +1,7 @@ """ Benchmark tests for HiCache Storage with Mooncake backend. Usage: - python3.10 -m pytest test/registered/hicache/test_hicache_storage_mooncake_backend.py -v + python3 -m pytest test/registered/hicache/test_hicache_storage_mooncake_backend.py -v """ import os diff --git a/test/registered/unit/multimodal/test_vit_npu_graph_runner.py b/test/registered/unit/multimodal/test_vit_npu_graph_runner.py index ebe2be3443..64bb0dbc64 100644 --- a/test/registered/unit/multimodal/test_vit_npu_graph_runner.py +++ b/test/registered/unit/multimodal/test_vit_npu_graph_runner.py @@ -27,7 +27,7 @@ class _FakeGraph: pass -def _load_npu_graph_runner(): +def _load_npu_graph_runner_module(): # Load shared modules before stubbing torch_npu so platform detection stays on CPU. importlib.import_module("sglang.srt.multimodal.vit_cuda_graph_runner") torch_npu = SimpleNamespace() @@ -37,14 +37,14 @@ def _load_npu_graph_runner(): "torch_npu": torch_npu, }, ): - module = importlib.import_module( + return importlib.import_module( "sglang.srt.hardware_backend.npu.graph_runner.vit_npu_graph_runner" ) - return module.ViTNpuGraphRunner def test_npu_vit_graph_keys_include_attention_boundaries(): - runner_cls = _load_npu_graph_runner() + module = _load_npu_graph_runner_module() + runner_cls = module.ViTNpuGraphRunner vit = SimpleNamespace( blocks=[_Block()], merger=lambda x: x, @@ -70,10 +70,8 @@ def test_npu_vit_graph_keys_include_attention_boundaries(): first_layout = torch.tensor([0, 4, 8], dtype=torch.int32) second_layout = torch.tensor([0, 2, 8], dtype=torch.int32) - with patch( - "sglang.srt.hardware_backend.npu.graph_runner." - "vit_npu_graph_runner.set_graph_pool_id" - ): + # patch.dict dropped the module from sys.modules, so patch it by object. + with patch.object(target=module, attribute="set_graph_pool_id"): runner.run( x, first_layout, diff --git a/tools/sglang-simulator/pyproject.toml b/tools/sglang-simulator/pyproject.toml index 949bf3dd7c..dcbd400044 100644 --- a/tools/sglang-simulator/pyproject.toml +++ b/tools/sglang-simulator/pyproject.toml @@ -14,5 +14,8 @@ dependencies = [ [project.optional-dependencies] aic = [ - "aiconfigurator==0.10.0" + "aiconfigurator==0.10.0", + # pyarrow 26 needs NumPy 2 at import, but aiconfigurator pins numpy 1.26.4; + # drop the cap once aiconfigurator allows NumPy 2. + "pyarrow<26", ]