Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 79 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

unit-tests:
runs-on: [self-hosted, linux, arm64, npu]
timeout-minutes: 30
timeout-minutes: 90
defaults:
run:
working-directory: dist-checkout
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
run: |
source activate.sh
pip install nanobind
pip install torch transformers safetensors numpy
pip install torch transformers safetensors numpy fastapi uvicorn pytest

- name: Show ccache stats (after)
run: ccache -s || true
Expand Down Expand Up @@ -172,17 +172,92 @@ jobs:
env:
PYTHONPATH: ${{ github.workspace }}/dist-checkout
PYPTO_QWEN3_MODEL_DIR: /data/l00955553/model/Qwen3-14B
PTO2_RING_DEP_POOL: 16384
PTO2_RING_TASK_WINDOW: 16384
PTO2_RING_HEAP: 1073741824
run: |
source activate.sh
python -m pytest tests/test_qwen3_accuracy.py -q -s
marker="pypto-serving-ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
run_cmd="export CI_TASK_MARKER=$marker"
run_cmd="$run_cmd && cd $GITHUB_WORKSPACE/dist-checkout"
run_cmd="$run_cmd && source activate.sh"
run_cmd="$run_cmd && DEVICE_ID=\$TASK_DEVICE"
run_cmd="$run_cmd PYTHONPATH=$PYTHONPATH"
run_cmd="$run_cmd PYPTO_QWEN3_MODEL_DIR=$PYPTO_QWEN3_MODEL_DIR"
run_cmd="$run_cmd PTO2_RING_DEP_POOL=$PTO2_RING_DEP_POOL"
run_cmd="$run_cmd PTO2_RING_TASK_WINDOW=$PTO2_RING_TASK_WINDOW"
run_cmd="$run_cmd PTO2_RING_HEAP=$PTO2_RING_HEAP"
run_cmd="$run_cmd python -m pytest tests/test_qwen3_accuracy.py -q -s"
task-submit --device auto --timeout 1200 --max-time 1800 --run "$run_cmd"

- name: Run Qwen3 serving guard (prefix cache, chunked prefill, multi-batch)
env:
PYTHONPATH: ${{ github.workspace }}/dist-checkout
PYPTO_QWEN3_MODEL_DIR: /data/l00955553/model/Qwen3-14B
PTO2_RING_DEP_POOL: 16384
PTO2_RING_TASK_WINDOW: 16384
PTO2_RING_HEAP: 1073741824
run: |
source activate.sh
python -m pytest tests/test_qwen3_serving.py -q -s
marker="pypto-serving-ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
run_cmd="export CI_TASK_MARKER=$marker"
run_cmd="$run_cmd && cd $GITHUB_WORKSPACE/dist-checkout"
run_cmd="$run_cmd && source activate.sh"
run_cmd="$run_cmd && DEVICE_ID=\$TASK_DEVICE"
run_cmd="$run_cmd PYTHONPATH=$PYTHONPATH"
run_cmd="$run_cmd PYPTO_QWEN3_MODEL_DIR=$PYPTO_QWEN3_MODEL_DIR"
run_cmd="$run_cmd PTO2_RING_DEP_POOL=$PTO2_RING_DEP_POOL"
run_cmd="$run_cmd PTO2_RING_TASK_WINDOW=$PTO2_RING_TASK_WINDOW"
run_cmd="$run_cmd PTO2_RING_HEAP=$PTO2_RING_HEAP"
run_cmd="$run_cmd python -m pytest tests/test_qwen3_serving.py -q -s"
task-submit --device auto --timeout 1200 --max-time 1800 --run "$run_cmd"

- name: Run DeepSeek V4 HTTP generation accuracy guard
env:
PYPTO_DSV4_MODEL_DIR: /data/l00955553/model/dsv4-flash-w8a8
PYPTO_RUNTIME_LOG: error
PTO2_RING_DEP_POOL: 131072
PTO2_RING_TASK_WINDOW: 131072
PTO2_RING_HEAP: 2147483648
PTO2_OP_EXECUTE_TIMEOUT_US: 400000000
PTO2_STREAM_SYNC_TIMEOUT_MS: 440000
PTO2_SCHEDULER_TIMEOUT_MS: 320000
SERVING_WORKER_STEP_TIMEOUT: 1800
run: |
source activate.sh
marker="pypto-serving-ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
run_cmd="export CI_TASK_MARKER=$marker"
run_cmd="$run_cmd && cd $GITHUB_WORKSPACE/dist-checkout"
run_cmd="$run_cmd && source activate.sh"
run_cmd="$run_cmd && TASK_DEVICE=\$TASK_DEVICE"
run_cmd="$run_cmd PYTHONPATH=$GITHUB_WORKSPACE/dist-checkout"
run_cmd="$run_cmd PYPTO_DSV4_MODEL_DIR=$PYPTO_DSV4_MODEL_DIR"
run_cmd="$run_cmd PYPTO_RUNTIME_LOG=$PYPTO_RUNTIME_LOG"
run_cmd="$run_cmd PTO2_RING_DEP_POOL=$PTO2_RING_DEP_POOL"
run_cmd="$run_cmd PTO2_RING_TASK_WINDOW=$PTO2_RING_TASK_WINDOW"
run_cmd="$run_cmd PTO2_RING_HEAP=$PTO2_RING_HEAP"
run_cmd="$run_cmd PTO2_OP_EXECUTE_TIMEOUT_US=$PTO2_OP_EXECUTE_TIMEOUT_US"
run_cmd="$run_cmd PTO2_STREAM_SYNC_TIMEOUT_MS=$PTO2_STREAM_SYNC_TIMEOUT_MS"
run_cmd="$run_cmd PTO2_SCHEDULER_TIMEOUT_MS=$PTO2_SCHEDULER_TIMEOUT_MS"
run_cmd="$run_cmd SERVING_WORKER_STEP_TIMEOUT=$SERVING_WORKER_STEP_TIMEOUT"
run_cmd="$run_cmd python -m pytest tests/test_deepseek_v4_accuracy.py -q -s"
task-submit --device auto --device-num 8 --ignore-whitelist \
--timeout 1200 --max-time 1800 \
--run "$run_cmd"

- name: Kill orphaned task-submit tasks
if: always()
working-directory: .
run: |
marker="pypto-serving-ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
task-submit --list 2>/dev/null \
| grep -F "CI_TASK_MARKER=$marker" \
| grep -oE 'task_[0-9_]+' \
| sort -u \
| while read -r task_id; do
echo "Killing orphaned task $task_id"
task-submit --kill "$task_id" || true
done || true

platform-build:
runs-on: ubuntu-latest
Expand Down
16 changes: 16 additions & 0 deletions python/core/serving_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ def busy_loop(self) -> None:

logger.info("Worker exiting")

def close(self) -> None:
"""Release executor-owned runtime and device resources."""
executor = self.executor
self.executor = None
if executor is None:
return

close = getattr(executor, "close", None)
if callable(close):
close()

def _execute_step(self, scheduler_output) -> StepOutput:
"""Execute one batch step (may contain prefill + decode requests)."""
runtime_model = self.model_record.runtime_model
Expand Down Expand Up @@ -412,6 +423,11 @@ def _worker_entry(
except Exception as e:
logger.error(f"Worker process failed: {e}", exc_info=True)
ready_event.set()
finally:
try:
worker.close()
except Exception:
logger.exception("Worker process cleanup failed")


def spawn_worker(config: EngineConfig):
Expand Down
Loading
Loading