embeddinggemma-2 / code /scripts /device_server_smoke.sh
changh95's picture
tt-model push embeddinggemma-2 (container)
5c33f00 verified
Raw History Blame Contribute Delete
1.26 kB
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Serving gate on the host (no container): start the HTTP server on the device, run server/smoke_test.py against it,
# stop the server. The server is the ONLY device process; run the whole script inside one device-lock window:
#
# bin/devrun -t 1200 --reset-on-timeout -- bash code/scripts/device_server_smoke.sh [port] [out.json]
#
# Env: the server's EMBGEMMA_* configuration (defaults: ttnn engines, ETH dispatch). Exit code: the smoke test's.
set -u
PORT="${1:-20124}"
OUT="${2:-}"
HERE="$(cd "$(dirname "$0")" && pwd)"
CODE="$(cd "$HERE/.." && pwd)"
# run outside code/ (tt-metal writes generated/ into the CWD); the package comes from PYTHONPATH
RUN="${EMBGEMMA_RUN_DIR:-${TMPDIR:-/tmp}/embgemma-server-smoke}"
mkdir -p "$RUN" && cd "$RUN"
export PYTHONPATH="$CODE${PYTHONPATH:+:$PYTHONPATH}"
export TT_MESH_SHAPE="${TT_MESH_SHAPE:-1x1}"
python -u -m uvicorn --host 127.0.0.1 --port "$PORT" --lifespan on tt_embgemma.server.app:app &
SRV=$!
stop() { kill -TERM "$SRV" 2>/dev/null; for _ in $(seq 1 90); do kill -0 "$SRV" 2>/dev/null || break; sleep 1; done; }
trap stop EXIT
python3 "$HERE/../tt_embgemma/server/smoke_test.py" --url "http://127.0.0.1:$PORT" --wait 1100 ${OUT:+--out "$OUT"}