48 lines
2.3 KiB
Bash
48 lines
2.3 KiB
Bash
#!/bin/bash
|
|||
|
|
# Decode-speed ablation on cores 32-55 (node 0; another session holds 0-31).
|
||
|
|
# One change at a time, each engine start back to back on the same cores, so
|
||
|
|
# the deltas are attributable even though the machine is not idle.
|
||
|
|
# gate head-gate projection as an eager reduction instead of aten::mm
|
||
|
|
# chunk inductor keeps small elementwise kernels single-threaded
|
||
|
|
set -u
|
||
|
|
HERE=/data/zhoutaichang/embedding_infer/analysis/experiments/spark_edge
|
||
|
|
V=/data/zhoutaichang/embedding_infer/.venvs/omni-cpu
|
||
|
|
G=/data/zhoutaichang/.cache/huggingface/hub/models--XHToken--Spark-X2.5-1.7B-GGUF/snapshots/23e1fcac55e7dd71e4c12a23723cc228ba0e5e85
|
||
|
|
B=/data/zhoutaichang/embedding_infer/llama.cpp/build/bin/llama-bench
|
||
|
|
M=/data/zhoutaichang/embedding_infer/models
|
||
|
|
CHUNK='{"inductor_compile_config":{"cpp.min_chunk_size":65536}}'
|
||
|
|
OUT=$HERE/ab_grid.jsonl
|
||
|
|
CORES=32-55
|
||
|
|
T=24
|
||
|
|
cd $HERE
|
||
|
|
|
||
|
|
run () { # tag model gate_reduction [--cc json]
|
||
|
|
local tag=$1 model=$2 gate=$3; shift 3
|
||
|
|
local cc=""
|
||
|
|
[ "${1:-}" = "--cc" ] && { cc="$2"; shift 2; }
|
||
|
|
VLLM_OMNI_SPARK_GATE_REDUCTION=$gate \
|
||
|
|
KMP_BLOCKTIME=infinite OMP_WAIT_POLICY=active \
|
||
|
|
LD_PRELOAD="$V/lib/python3.12/site-packages/vllm/libs/libtcmalloc_minimal.so.4:$V/lib/libiomp5.so" \
|
||
|
|
CUDA_VISIBLE_DEVICES= VLLM_TARGET_DEVICE=cpu VLLM_CPU_KVCACHE_SPACE=4 VLLM_ENABLE_V1_MULTIPROCESSING=0 \
|
||
|
|
OMP_NUM_THREADS=$T VLLM_CPU_OMP_THREADS_BIND=$CORES \
|
||
|
|
taskset -c $CORES timeout 2400 $V/bin/python bench_cpu_vllm.py --model "$model" \
|
||
|
|
--tag "$tag" --reps 3 --out $OUT ${cc:+--compilation-config "$cc"} 2>&1 \
|
||
|
|
| grep -E '"(tag|pp_tps|tg_tps)"'
|
||
|
|
}
|
||
|
|
|
||
|
|
llamacpp () {
|
||
|
|
taskset -c $CORES $B -m $G/Spark-X2.5-1.7B-Q4_K_M.gguf -p 512 -n 128 -t $T -o json 2>/dev/null \
|
||
|
|
> $HERE/ab_llamacpp_$1.json
|
||
|
|
python3 -c "
|
||
|
|
import json;d=json.load(open('$HERE/ab_llamacpp_$1.json'))
|
||
|
|
print(' llama.cpp Q4_K_M', {('pp512' if r['n_prompt'] else 'tg128'): round(1e9*(r['n_prompt'] or r['n_gen'])/r['avg_ns'],2) for r in d})"
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "#### llama.cpp Q4_K_M t=$T (before)"; llamacpp before
|
||
|
|
run "base" $M/spark2_5-int4-g64 0
|
||
|
|
run "gate" $M/spark2_5-int4-g64 1
|
||
|
|
run "gate+chunk" $M/spark2_5-int4-g64 1 --cc "$CHUNK"
|
||
|
|
run "gate+chunk+g128" $M/spark2_5-int4-g128 1 --cc "$CHUNK"
|
||
|
|
run "w4a8+gate+chunk" $M/spark2_5-gptq-g64 1 --cc "$CHUNK"
|
||
|
|
echo "#### llama.cpp Q4_K_M t=$T (after, drift check)"; llamacpp after
|
||
|
|
echo "#### AB GRID DONE"
|