okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
5438023a6
main
1#!/usr/bin/env bash 2# strata-sycl.sh: the SYCL-built engine as a drop-in `exe` for serve/server.py (--engine strata). The port's binary 3# needs the oneAPI runtime of the dev image, so this runs it there with stdin/stdout attached (the serve protocol is 4# lines on those pipes) and stderr going to the server's log. Paths in the config's args are the container's: 5# the data root is mounted at /work. 6# STRATA_SYCL_ROOT host directory mounted at /work (default: two levels above this script's repo) 7# STRATA_SYCL_IMAGE the runtime image (default: strata-sycl-dev) 8# STRATA_SYCL_BIN the engine binary, relative to the repo (default: build-sycl-aot/strata) 9# STRATA_SYCL_NAME the container's name (default: strata-sycl-serve) 10# STRATA_SYCL_SHM 1 (default): the host's /dev/shm is the container's /dev/shm. Pictures: the server (on the host) writes the 11# image embeddings of a request into /dev/shm and names that file on the engine's GENI line, so the engine in 12# the container must see the same file. 0: the container keeps a private /dev/shm. 13# Passed into the container: every variable of this script's environment that starts with STRATA_ (the config's 14# "env" block arrives that way: the server puts it in the engine's environment), ONEAPI_ (level_zero:* for a 15# two-card split, #423), UR_, IGC_, SYCL_ or ZES_. The port's own defaults (below) are overridden the same way, 16# e.g. "env": {"STRATA_VERIFY_NO_HOST": "0"} in the config. 17set -euo pipefail 18here =$( cd " $( dirname " $ 0" ) /../.." && pwd ) # the repo 19root =${ STRATA_SYCL_ROOT :-$( dirname " $ here " )} 20repo_in =/work/$( basename " $ here " ) 21name =${ STRATA_SYCL_NAME :- strata -sycl-serve} 22docker rm-f " $ name " > /dev/null2 >&1 ||true # a container left behind by a killed server 23args ="" 24for a in " $ @" ;do args +=" $( printf '%q' " $ a " ) " ;done 25# the port's run-time switches: the device-built verify plan, and no host handshakes in it. NO_HOST is for a card on 26# the xe driver (the host<->GPU flag stores are not visible there); an i915 card (Arc A-series) runs without it 27# (docs/INTEL.md) 28# STRATA_CACHE_DIR: the engine's measurements that outlive a run (the int8 prompt experts' crossover, measured at 29# the first prompt of each format: ~1.4 s of a B70's first 2K prompt) - under the mounted data root, not in the 30# throwaway container's home 31declare -Asetting =([STRATA_VERIFY_DEVICE_PLAN]=1 [STRATA_VERIFY_NO_HOST]=1 [STRATA_STAGER_THREADS]=12 32 [STRATA_CACHE_DIR]=/work/.strata-cache) 33while IFS =read -r k;do 34case " $ k " in 35 STRATA_SYCL_*) ;;# this script's own settings 36 STRATA_*| ONEAPI_*| UR_*| IGC_*| SYCL_*| ZES_*| NEOReadDebugKeys| OverrideDefaultFP64Settings)setting [$ k ]=${! k } ;; 37esac 38done < <( compgen -e ) 39envs =() 40for k in " ${! setting [@]} " ;do 41# the engine tests the switches by presence: a value of 0 (or empty) means "not set", so it is not passed on 42case " ${ setting [ $ k ]} " in 0| "" ) ;; *)envs +=(-e" $ k = ${ setting [ $ k ]} " ) ;;esac 43done 44shm =() 45if [" ${ STRATA_SYCL_SHM :-1} " != 0 ]&& [ -d /dev/shm ];then shm =(-v /dev/shm:/dev/shm);fi 46exec docker run--rm -i --name " $ name " --device /dev/dri--oom-score-adj 1000--stop-timeout 30--no-healthcheck \ 47--ulimit memlock=-1 \ 48-v " $ root :/work" \ 49" ${ shm [@]} " \ 50" ${ envs [@]} " \ 51" ${ STRATA_SYCL_IMAGE :- strata -sycl-dev} " \ 52"cd $ repo_in && exec ${ STRATA_SYCL_BIN :- build -sycl-aot/strata} $ args "