Commit Graph
14 Commits
Author SHA1 Message Date
TheTom e36048f2a6 fix: add -o shorthand for --output-dir in NIAH script 2026-03-26 13:50:09 -05:00
c8b5d7ba88 feat: NIAH benchmark — needle-in-a-haystack retrieval accuracy test
niah_test.py — standalone NIAH benchmark for TurboQuant:
- Spins up llama-server per config, inserts 6-digit "secret code" needles
  into filler text, queries via /v1/chat/completions, scores exact match
- Tests all combos of depths x needles x cache types
- Needle positions span 5%-95% of context (not just first half)
- Regex-based scoring (exact 6-digit word boundary match, no false positives)
- Configurable: --depths, --needles, --cache-types, --server-timeout,
  --query-timeout, --server-bin, --chars-per-token, --verbose
- Server lifecycle: atexit + signal handlers, stderr captured to temp file
- Deterministic: seed=42, positions logged for reproducibility
- No personal paths in defaults, cross-platform (macOS + Linux)

Hardened per Codex + Roast review:
- Scoring: regex r'\b(\d{6})\b' not substring match (Codex critical)
- Positions: 5%-95% spread not 10%-50% (Roast critical)
- 20 cities (was 10), validates --needles <= city count
- Server timeout 120s (was 60), query timeout 300s (was 120)
- --server-bin flag for ROCm/custom builds
- Server stderr always captured for remote debugging
- Token estimation documented + --chars-per-token override

74 tests, all passing. No /Users/tom/ in any file.

Reference: @jtdavies found TQ 3.5-bit drops to 17-45% of bf16 NIAH
at 128K on MLX. This script lets us measure where we stand on Metal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 13:46:21 -05:00
TheTom ce7af8b3f9 docs: add 'plug in charger' warning — battery throttling observed on M5 Max 2026-03-26 12:26:45 -05:00
TheTom f37f639ebd docs: add clone step to README quick start 2026-03-26 12:09:15 -05:00
5bf0aef9d1 fix: 5 Codex blockers — zip safety, exit codes, multi-GPU, PII, skip-ppl
1. Zip failure no longer deletes raw artifacts — preserves data if zip fails
2. main() returns 1 on unhandled exception (was always returning 0)
3. --skip-ppl no longer requires llama-perplexity binary
4. Multi-GPU nvidia-smi: sum memory/util, max temp across all GPUs
5. Model path logged as basename only (was leaking full path with username)
6. Build instructions now platform-aware (Metal vs CUDA)
7. Sharing instructions: GitHub issues + @no_stp_on_snek DM
8. Removed legacy bash diagnostic script (superseded by Python v5)

253 tests, 100% coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 11:58:17 -05:00
69b33b7bf7 feat: 97% coverage (233 tests), SSD detection, comprehensive failure logging
Coverage: 66% → 97% (127 new tests)
Failure logging: 7 → 60 log points — every except block now describes
what it was trying to do and includes the exception detail.

New features:
- detect_storage_type() — SSD/HDD detection (macOS diskutil + Linux rotational flag)
- [STORAGE] tag in diagnostic output
- HDD warning if model is on spinning disk

New test classes: TestDetectStorageType, TestFindModel, TestDiagLogExtended,
TestBackgroundMonitorExtended, TestLiveDisplayExtended, TestAnomalyDetectorExtended,
TestCaptureLoad, TestSectionsExtended, TestBuildJsonProfileExtended,
TestPackageResultsExtended, TestMainFunction, TestRunCmd, TestSubprocessRunner,
TestLinuxHardwareDetection, TestExceptPaths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 11:35:59 -05:00
bb8a04b6a7 fix: Codex review — thread safety, crash paths, signal handling
1. BackgroundMonitor: add threading.Lock for _samples/_sample_count
2. Fix UnboundLocalError: initialize hw={} and gpu_init="" before try block
3. SIGINT handler: use _interrupted flag to prevent writing to closed log
4. Monitor errors tracked instead of silently swallowed
5. Guard finally block against interrupted state

Also added outlandish detection (both directions):
- turbo3 faster than q8_0 → [INVESTIGATE]
- Excellent decode ratio at long context → [NOTABLE]
- Decode improving at deeper context → [INVESTIGATE]
- PPL better than q8_0 → [INVESTIGATE]
- 10 new tests for notable/investigate flags

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 10:47:44 -05:00
8c9d6d4726 feat: Python diagnostic tool v5 + venv launcher + README
turbo_hardware_diag.py (2270 lines, stdlib-only core):
- 13 diagnostic sections matching bash v4 output format
- Cross-platform: macOS (Metal/Apple Silicon) + Linux (NVIDIA/AMD)
- Background monitor thread polling every 10s (CSV output)
- Real-time terminal: rich Live tables or ASCII fallback
- Anomaly detection (bad): decode degradation, thermal throttle, swap growth
- Notable detection (good): excellent ratios, near-parity at long context
- Outlandish detection (investigate): turbo3 faster than q8_0, PPL better
  than baseline, decode improving at deeper context
- Every probe wrapped in try/except — warnings, never crashes
- Output: .txt log, .json profile, .csv monitor, .zip package
- Tag format compatible with hw_replay.py parse_diag_output()
- Full argparse: --help, --model, --skip-ppl, --skip-stress, --verbose

turbo-diag launcher:
- Auto-creates isolated venv (.turbo-diag-venv/)
- Installs rich for terminal UI
- Never pollutes user's Python environment
- Falls back to plain Python if venv creation fails

scripts/README.md:
- Quick start, output format, how-to-read guide
- M5 Max baselines, anomaly flags explained
- Hardware replay system usage
- Troubleshooting, privacy statement

106 tests, 66% line coverage (main() integration path is the gap).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 10:43:12 -05:00
88af7838d0 feat: v4 — continuous background monitoring + GPU/mmap diagnostics
Background monitor (10s polling CSV):
- CPU load, memory pressure %, swap MB, GPU temp, CPU speed limit
- NVIDIA GPU memory used + utilization % (Linux)
- Runs entire duration, included in zip package

New diagnostic sections:
- GPU-using processes (detect Chrome/video interference)
- Model mmap check (SSD detection, size vs free RAM)

Monitor CSV enables post-hoc analysis of thermal throttling,
memory pressure spikes, and GPU contention during benchmarks.

TODO: Rewrite diagnostic in Python (stdlib only) for v5.
Bash is getting fragile with cross-platform edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 10:06:42 -05:00
693a391333 fix: address Codex + Gemini review findings
Codex fixes:
- wall_ms → wall_sec (BSD date doesn't support %3N milliseconds)
- Linux physical cores: use 'core id' count instead of processor count
- Remove unused $JSONFILE variable (caused crash on unset -u)
- Fix Metal shader comment accuracy (signs can mix per element)

Gemini/doc review fixes:
- Add inflection point detection (find_decode_inflection)
- Add 1K context measurement flagging (flag_unreliable_measurements)
- Add has_tensor impact to prediction model (+30% penalty)
- Use exponential cache fraction model (matches real data better)
- 4 new tests: inflection detection, unreliable measurement flagging

255 total tests passing (144 core + 71 diag + 40 replay).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 09:34:29 -05:00
31be9fb167 feat: comprehensive hardware diagnostic script + 71 tests
turbo-hardware-diag.sh v3:
- 13 test sections: hardware inventory, GPU caps, model info, prefill,
  decode, stress test, PPL, memory breakdown, load monitoring
- Cross-platform: macOS (Metal) + Linux (CUDA)
- No PII collected — only hardware specs, load stats, benchmarks
- Machine-parseable tags ([HW], [BENCH_START], [LOAD_SNAPSHOT], etc.)
- Zip packaging with hardware profile JSON for replay testing
- Load snapshots at 7 points to detect thermal throttling

71 Python tests covering:
- Script syntax, permissions, structure
- Full mock-binary integration test
- All 13 sections produce non-empty output
- Tag format validation (key=value, ISO 8601 timestamps)
- Error handling (missing model, missing binaries, missing wikitext)
- No PII verification
- Benchmark coverage (all cache types, all depths)
- Load monitoring at all checkpoint points

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-26 09:03:59 -05:00
c11cd3f8ee ci: real-world PDF benchmark script (Mario's 70-page fitness PDF test)
Tests decode speed at realistic context depths with actual document content.
Compares turbo3 vs q8_0 using llama-server API.

Usage: bash scripts/turbo-realworld-bench.sh [path-to-pdf]
PDF not included in repo — testers provide their own.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-25 22:02:33 -05:00
eed5a6310e ci: quality+speed gate — checks PPL + context scaling before push
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-25 20:22:52 -05:00
445a3dc4c7 docs: move engineering docs here from llama.cpp fork
These belong in our repo, not in a fork of someone else's project.

Added:
- docs/quality-benchmarks.md — perplexity validation, bisection log, top-of-tree table
- docs/turbo-speed-investigation.md — Metal gotchas, fp16 WHT, optimization history
- docs/pre-rotate-queries-investigation.md — WHT/RoPE commutativity issue
- docs/pre-rotate-queries-plan.md — original optimization plan
- scripts/turbo-quality-gate.sh — pre-push perplexity check

README links updated to point locally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: tturney@psyguard.ai
2026-03-25 16:16:58 -05:00