Read code changes as Git diffs. Identifying strings are masked; binary files are listed by their full relative names.
openbuild_solution · 5 changed files
Base commit: 8f62ee8f410c38ae7cd90305300afd08f0fdb098
diff --git a/solution/README.md b/solution/README.mdnew file mode 100644index 0000000000000000000000000000000000000000..4e2cc7c324d208f4933bca15457c4890d29b7920--- /dev/null+++ b/solution/README.md@@ -0,0 +1,24 @@+# Offline Qwen3-8B Ascend server++This delivery contains a pure-Python (`VLLM_TARGET_DEVICE=empty`) build of+vLLM 0.23.0, the matching vLLM Ascend 0.23.0 backend and the private runtime+dependencies needed by the OpenAI server. `bootstrap.sh` unpacks them only+below `OPENBUILD_ENV_DIR`; `launch.sh` remains the foreground owner of the API+server and its engine child.++The serving configuration uses compiled dynamic prefill and ACLGraph decode+for batch sizes 1 through 64. The public workload fits within a 4096-token+context and an 8192-token scheduler budget. Prefix caching and asynchronous+scheduling retain the engine defaults.++The asynchronous engine normally keeps two model batches in flight. An+environment-gated scheduler patch drains the older batch first at moderate+occupancy with short prompts, where one extra queued decode step costs TTFT+without filling otherwise idle compute. Single-request decoding, long prompts,+and saturation-sized batches retain the normal two-batch overlap.++The optional vLLM Ascend custom C++ operator library was built against a newer+CANN minor ABI than the task runtime. `patch_runtime.py` disables that optional+library before graph tracing, selecting the equivalent torch_npu operators;+model execution, attention, KV-cache management and graph replay remain on the+assigned NPU.diff --git a/solution/bootstrap.sh b/solution/bootstrap.shnew file mode 100755index 0000000000000000000000000000000000000000..b752450103f2aa9165456e3b097f07cb2998b537--- /dev/null+++ b/solution/bootstrap.sh@@ -0,0 +1,32 @@+#!/usr/bin/env bash+set -euo pipefail++: "${OPENBUILD_SOLUTION_DIR:?OPENBUILD_SOLUTION_DIR is required}"+: "${OPENBUILD_ENV_DIR:?OPENBUILD_ENV_DIR is required}"++readonly runtime_dir="${OPENBUILD_ENV_DIR}/python"+readonly stamp="${OPENBUILD_ENV_DIR}/.qwen3-serving-runtime-v4"++mkdir -p -- "${OPENBUILD_ENV_DIR}" "${runtime_dir}"++# The controller reuses the prepared environment across fresh service+# processes. Avoid unpacking the native wheels again after a successful run.+if [[ -f "${stamp}" \+ && -f "${runtime_dir}/vllm/__init__.py" \+ && -f "${runtime_dir}/vllm_ascend/__init__.py" ]]; then+ exit 0+fi++python -m pip install \+ --no-index \+ --disable-pip-version-check \+ --no-deps \+ --upgrade \+ --target "${runtime_dir}" \+ "${OPENBUILD_SOLUTION_DIR}"/wheels/*.whl++python "${OPENBUILD_SOLUTION_DIR}/patch_runtime.py" "${runtime_dir}"++tmp_stamp="${stamp}.tmp.$$"+printf '%s\n' 'qwen3-serving-runtime-v4' > "${tmp_stamp}"+mv -f -- "${tmp_stamp}" "${stamp}"diff --git a/solution/launch.sh b/solution/launch.shnew file mode 100755index 0000000000000000000000000000000000000000..eb8216299d2fbee6a77ab1ae78b4dadf32114dab--- /dev/null+++ b/solution/launch.sh@@ -0,0 +1,62 @@+#!/usr/bin/env bash+set -euo pipefail++for required_name in \+ OPENBUILD_ENV_DIR \+ OPENBUILD_MODEL_PATH \+ OPENBUILD_TOKENIZER_PATH \+ OPENBUILD_SERVED_MODEL \+ OPENBUILD_HOST \+ OPENBUILD_PORT \+ OPENBUILD_DEVICE_IDS+do+ if [[ -z "${!required_name:-}" ]]; then+ printf 'missing required launch environment: %s\n' "${required_name}" >&2+ exit 2+ fi+done++readonly runtime_dir="${OPENBUILD_ENV_DIR}/python"+if [[ ! -f "${OPENBUILD_ENV_DIR}/.qwen3-serving-runtime-v4" ]]; then+ printf 'offline runtime has not been bootstrapped\n' >&2+ exit 2+fi++# Keep the task-provided CANN paths after the private wheel directory. In+# particular, CANN's acl Python extension is supplied through PYTHONPATH.+export PYTHONPATH="${runtime_dir}${PYTHONPATH:+:${PYTHONPATH}}"+export XDG_CACHE_HOME="${OPENBUILD_ENV_DIR}/cache"+export VLLM_TARGET_DEVICE=empty+export VLLM_PLUGINS=ascend+export OPENBUILD_DISABLE_ASCEND_CUSTOM_OPS=1+export OPENBUILD_ADAPTIVE_BATCH_QUEUE=1+export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000+export VLLM_NO_USAGE_STATS=1+export HF_HUB_OFFLINE=1+export TRANSFORMERS_OFFLINE=1+export HF_HUB_DISABLE_TELEMETRY=1+export TOKENIZERS_PARALLELISM=false+export TASK_QUEUE_ENABLE=1+export OMP_NUM_THREADS=1++mkdir -p -- "${XDG_CACHE_HOME}"++# FULL_DECODE_ONLY captures the batch sizes used by the public workload while+# retaining dynamic compiled prefill. The bundled plugin's optional C++ ops+# target a newer CANN minor ABI, so the explicit runtime patch routes those+# few operations through torch_npu before Dynamo traces the model.+exec python -m vllm.entrypoints.openai.api_server \+ --model "${OPENBUILD_MODEL_PATH}" \+ --tokenizer "${OPENBUILD_TOKENIZER_PATH}" \+ --served-model-name "${OPENBUILD_SERVED_MODEL}" \+ --host "${OPENBUILD_HOST}" \+ --port "${OPENBUILD_PORT}" \+ --dtype bfloat16 \+ --max-model-len 4096 \+ --max-num-seqs 64 \+ --max-num-batched-tokens 8192 \+ --gpu-memory-utilization 0.90 \+ --generation-config vllm \+ --compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[1,2,4,8,16,32,64]}' \+ --additional-config '{"ascend_compilation_config":{"enable_npugraph_ex":false}}' \+ --disable-uvicorn-access-logdiff --git a/solution/manifest.json b/solution/manifest.jsonnew file mode 100644index 0000000000000000000000000000000000000000..1194bc987c628d49c242b1031a84d88faacc03be--- /dev/null+++ b/solution/manifest.json@@ -0,0 +1,10 @@+{+ "schema_version": 1,+ "kind": "openbuild_solution",+ "task_id": "openbuild_serving_qwen3_8b_1dev_v1",+ "model": "Qwen/Qwen3-8B",+ "framework": "vLLM 0.23.0 + vLLM Ascend 0.23.0 (offline empty-device build)",+ "bootstrap": "bootstrap.sh",+ "launch": "launch.sh",+ "offline_replay": true+}diff --git a/solution/patch_runtime.py b/solution/patch_runtime.pynew file mode 100755index 0000000000000000000000000000000000000000..9c4581a68e8a0dd1c0f7b72e076008f785b9e956--- /dev/null+++ b/solution/patch_runtime.py@@ -0,0 +1,61 @@+#!/usr/bin/env python3+"""Apply the explicit compatibility/performance patches to the private runtime."""++from __future__ import annotations++from pathlib import Path+import sys+++def replace_once(target: Path, original: str, replacement: str) -> None:+ source = target.read_text(encoding="utf-8")+ if replacement in source:+ return+ if source.count(original) != 1:+ raise RuntimeError(f"unexpected runtime patch target: {target}")+ target.write_text(source.replace(original, replacement), encoding="utf-8")+++def main() -> int:+ if len(sys.argv) != 2:+ raise SystemExit("usage: patch_runtime.py RUNTIME_SITE_PACKAGES")++ runtime = Path(sys.argv[1])++ ascend_utils = runtime / "vllm_ascend" / "utils.py"+ custom_ops_original = '_CUSTOM_OP_ENABLED = None'+ custom_ops_replacement = (+ '_CUSTOM_OP_ENABLED = False if '+ 'os.getenv("OPENBUILD_DISABLE_ASCEND_CUSTOM_OPS") == "1" else None'+ )+ replace_once(ascend_utils, custom_ops_original, custom_ops_replacement)++ engine_core = runtime / "vllm" / "v1" / "engine" / "core.py"+ queue_original = """\+ model_executed = False+ deferred_scheduler_output = None+ if self.scheduler.has_requests():+"""+ queue_replacement = """\+ model_executed = False+ deferred_scheduler_output = None+ # A second queued decode batch can delay admission of a short prefill+ # at moderate online load. Drain the in-flight batch in that regime,+ # while retaining two-batch overlap for single-stream decode, long+ # prompts, and saturation-sized batches.+ queued_requests = tuple(self.scheduler.requests.values())+ latency_first_drain = (+ os.getenv("OPENBUILD_ADAPTIVE_BATCH_QUEUE") == "1"+ and bool(batch_queue)+ and 1 < len(queued_requests) < 48+ and max(request.num_prompt_tokens for request in queued_requests)+ <= 1024+ )+ if self.scheduler.has_requests() and not latency_first_drain:+"""+ replace_once(engine_core, queue_original, queue_replacement)+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())