Fast local LLM inference on plain CPUs. No GPU, 8 GB of RAM. OpenAI-compatible server.
Python aiavx512cpu-inferenceedge-aiggufinference-enginellama-cppllmllm-inferencelocal-ailocal-llmno-gpuon-device-aiopenai-apiopenai-compatiblequantizationqwenself-hostedspeculative-decodingternary
fix(bench): keep failed phases resumable instead of marking them done (#106)
Afloat6c0d1ec740bc
diff --git a/bench/jobs.sh b/bench/jobs.shindex c39d9b1..c6678b4 100644--- a/bench/jobs.sh+++ b/bench/jobs.sh@@ -20,7 +20,7 @@# quality GSM8K-40 + 160 coding problems, new default vs the earlier build's default (task-quality gate for 0008)# kld KL divergence of every attention path (-ub 1/4/512, GGML_ATTN 1/0) vs the fork's tiled path# ppl WikiText-2 PPL, 32 x 512: the release build, and GGML_ATTN=0-set -u+set -euo pipefailL=${L:-$(cd "$(dirname "$0")" && pwd)}; R=~/res; mkdir -p $R # L = this bench/ folderREPLAY=${REPLAY:-$L/replay.json} # agent-replay input (not shipped; see README.md)BROAD=${BROAD:-$L/prompts_broad.jsonl}@@ -60,7 +60,8 @@ replay() {[ -f $O/steps_$arm.done ] && continuelog "replay $arm start"python3 rrun.py --arms arms_replay.json --arm $arm --replay $REPLAY ${REPLAY_TOKENS:+--tokens $REPLAY_TOKENS} --ctx 16384 \- --gen 64 $st --out $O > $O/$arm.out 2>&1 && touch $O/steps_$arm.done+ --gen 64 $st --out $O > $O/$arm.out 2>&1+ touch $O/steps_$arm.donelog "replay $arm end"done}@@ -154,8 +155,9 @@ ppl() {O=$R/ppl; mkdir -p $Oif [ ! -x ~/.prev/bin/llama-perplexity ]; then # the earlier build tree was pruned after installS=~/.prev/llama.cpp; cmake -S $S -B $S/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=OFF -DLLAMA_BUILD_TESTS=OFF \- -DLLAMA_BUILD_EXAMPLES=OFF -DGGML_NATIVE=ON -DBUILD_SHARED_LIBS=OFF > $O/build-prev.log 2>&1 && \- cmake --build $S/build -j 8 --target llama-perplexity >> $O/build-prev.log 2>&1 && cp $S/build/bin/llama-perplexity ~/.prev/bin/+ -DLLAMA_BUILD_EXAMPLES=OFF -DGGML_NATIVE=ON -DBUILD_SHARED_LIBS=OFF > $O/build-prev.log 2>&1+ cmake --build $S/build -j 8 --target llama-perplexity >> $O/build-prev.log 2>&1+ cp $S/build/bin/llama-perplexity ~/.prev/bin/fifor a in new attn0 prev; doE=; [ $a = attn0 ] && E="GGML_ATTN=0"; B=~/.openset-llm/bin; [ $a = prev ] && B=~/.prev/bindiff --git a/bench/test_jobs_failures.py b/bench/test_jobs_failures.pynew file mode 100644index 0000000..594a24f--- /dev/null+++ b/bench/test_jobs_failures.py@@ -0,0 +1,76 @@+import os+from pathlib import Path+import subprocess+import tempfile+import unittest+++class JobsFailureTest(unittest.TestCase):+ def setUp(self):+ self.directory = tempfile.TemporaryDirectory()+ self.addCleanup(self.directory.cleanup)+ self.root = Path(self.directory.name)+ (self.root / 'tools').mkdir()+ (self.root / 'results/q_code').mkdir(parents=True)+ # Redirect only the driver's fixed local paths; execute its actual phase/marker logic.+ source = Path(__file__).with_name('jobs.sh').read_text()+ source = source.replace('R=~/res', 'R="$JOB_TEST_ROOT/results"')+ for path in ('~/.openset-llm/bin/llama-bench', '~/.prev/bin/llama-bench'):+ source = source.replace(path, '"$JOB_TEST_ROOT/tools/llama-bench"')+ source = source.replace('~/.prev', '"$JOB_TEST_ROOT/prev"')+ (self.root / 'jobs.sh').write_text(source)+ self.command('python3', '''printf '%s\\n' "$1" >> "$JOB_TEST_ROOT/calls"+[ "$JOB_TEST_FAIL" = "$1" ] && exit 37+printf '{}\\n'+''')+ self.command('cmake', '[ "$JOB_TEST_FAIL" = cmake ] && exit 37\nexit 0\n')+ self.command('llama-bench', '''[ "$JOB_TEST_FAIL" = llama-bench ] && exit 37+printf '[{"avg_ts":1}]\\n'+''')++ def command(self, name, body):+ path = self.root / 'tools' / name+ path.write_text('#!/bin/sh\n' + body)+ path.chmod(0o755)++ def run_jobs(self, *phases, failure=''):+ env = dict(os.environ, JOB_TEST_ROOT=str(self.root), JOB_TEST_FAIL=failure,+ L=str(Path(__file__).parent.resolve()),+ PATH=str(self.root / 'tools') + os.pathsep + os.environ['PATH'])+ return subprocess.run(['bash', str(self.root / 'jobs.sh'), *phases], env=env,+ capture_output=True, text=True, timeout=15)++ def assert_failed(self, result, tag):+ self.assertEqual(result.returncode, 37, result.stderr)+ self.assertFalse((self.root / 'results' / ('DONE.' + tag)).exists())+ self.assertNotIn('ALL_DONE', (self.root / 'results/jobs.log').read_text())++ def test_failed_simple_phase_is_not_marked_complete(self):+ self.assert_failed(self.run_jobs('short', '1', failure='bench2.py'), 'short_1')++ def test_failed_pipeline_is_not_marked_complete(self):+ self.assert_failed(self.run_jobs('lbprev', failure='llama-bench'), 'lbprev')++ def test_failed_replay_arm_is_not_marked_complete(self):+ self.assert_failed(self.run_jobs('replay', '0', 'ours,prism', failure='rrun.py'), 'replay_0')+ self.assertFalse((self.root / 'results/replay/steps_ours.done').exists())+ self.assertEqual((self.root / 'calls').read_text().splitlines(), ['rrun.py'])++ def test_quality_stops_before_grading_after_runner_failure(self):+ self.assert_failed(self.run_jobs('quality', failure='bench2.py'), 'quality')+ self.assertEqual((self.root / 'calls').read_text().splitlines(), ['bench2.py'])++ def test_failed_perplexity_build_stops_phase(self):+ self.assert_failed(self.run_jobs('ppl', failure='cmake'), 'ppl')+ self.assertFalse((self.root / 'results/ppl/summary.txt').exists())++ def test_successful_phase_is_skipped_on_retry(self):+ for _ in range(2):+ result = self.run_jobs('short', '1')+ self.assertEqual(result.returncode, 0, result.stderr)+ self.assertTrue((self.root / 'results/DONE.short_1').exists())+ self.assertEqual((self.root / 'calls').read_text().splitlines(), ['bench2.py'])+++if __name__ == '__main__':+ unittest.main()