#!/usr/bin/env python3 """ scripts/run_reasoning_benchmark.py Executes multi-step reasoning token complexity evaluation across mathematical, algorithmic, and logical sequences. Dumps JSON telemetry to results/raw/. """ import sys import json from pathlib import Path from dataclasses import asdict ROOT_DIR = Path(__file__).resolve().parent.parent if str(ROOT_DIR) not in sys.path: sys.path.insert(0, str(ROOT_DIR)) from src.reasoning_benchmark import ReasoningComplexityAnalyzer def main(): print("=" * 70) print("Q-TensorFormer: Real-World Reasoning Token Complexity Benchmark") print("=" * 70) analyzer = ReasoningComplexityAnalyzer() results = analyzer.run_all_benchmarks() output_data = [] for r in results: print(f"\n[Problem]: {r.problem_name}") print(f" Prompt Length: {r.total_tokens} tokens") print(f" Mean TT-Rank: {r.mean_allocated_rank} (High: {r.high_rank_tokens_count}, Low: {r.low_rank_tokens_count})") print(f" DRAM Memory Saved: {r.dram_savings_pct:.2f}%") print(f" Accuracy Retention: {r.accuracy_retention_pct:.2f}%") output_data.append(asdict(r)) out_path = ROOT_DIR / "results" / "raw" / "reasoning_token_complexity.json" out_path.parent.mkdir(parents=True, exist_ok=True) with open(out_path, "w", encoding="utf-8") as f: json.dump(output_data, f, indent=2) print(f"\n[SUCCESS] Dumped reasoning benchmark telemetry to: {out_path}") print("=" * 70) if __name__ == "__main__": main()