# Repository Briefing: kongtou20070406/proofline
> Source: https://repoforai.com/repo/kongtou20070406/proofline (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/kongtou20070406/proofline
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: A (82/100 · Maintenance 35/35 · Adoption 7/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v1.7.0 (2026-12-03) — https://github.com/kongtou20070406/proofline/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: CLI, MCP
- **Momentum**: 27 ★ total (+2 24h / +27 7d) · 2 forks
- **Topics**: `formal-verification`, `gpu`, `lean4`, `mlsys`, `pytorch`, `roofline`, `z3`
- **When to Use**: Best for: ML systems teams screening GPU fleets and serving layouts, triaging fusion opportunities, or gating modeled performance regressions in CPU CI before running hardware benchmarks. Skip if: You need measured tail latency, production capacity guarantees, or an inference runtime that executes the model or compiles the proposed kernels.

## Overview
```text
### Architecture & Core Mechanics
Proofline is a static performance-analysis SDK, not an inference runtime. It requires Python 3.10+ and PyTorch 2.2+. For `nn.Module` inputs, it uses FakeTensorMode and zero-VRAM meta tensors to infer shapes and dependencies without running GPU kernels. Hugging Face configurations and safetensors headers, GGUF headers, and ONNX graphs provide metadata or graph inputs when PyTorch tracing is not the entry point.

The analyzer maps accounted FLOPs, memory traffic, and dependency depth onto a hardware profile. It reports an absolute floor set by the maximum of compute, compulsory I/O, and critical-path terms; a stage-wise bound that sums per-stage maxima; and an eager reference that adds per-kernel dispatch overhead. The Python API and CLI expose the analysis directly. `proofline mcp` adds JSON-RPC 2.0 over stdio for agent workflows, while optional Z3 and Lean 4 verification checks lower-bound results under the stated scheduling assumptions.

### Key Capabilities & Differentiators
The 34 built-in hardware presets span NVIDIA, AMD, Huawei Ascend, Google TPU, and Apple Silicon, with multi-device selectors such as `8xb200` and support for calibrated JSON profiles. The serving model separates prefill and decode and accounts for GQA/MQA, compressed MLA KV caches, sliding windows, and hybrid dense/MoE layouts. `fit` checks weight and KV-cache fit, evaluates tensor/data parallel layouts and colocated versus disaggregated prefill/decode, and ranks configurations by modeled output-token goodput and cost under time-to-first-token (TTFT) and time-per-output-token (TPOT) constraints.

The graph tools address a different question: where is there room to improve the implementation? `blueprint` proposes heuristic fusion partitions with shared-memory and register-pressure constraints, as well as FlashAttention and GQA-aware Split-KV FlashDecoding tiles. It emits a Mermaid topology and a D2K-Bench agent prompt, not a compiled kernel. `gap` attributes profiler traces or compares TorchInductor fusion breaks; `diff` turns changes in the modeled latency floor into Markdown or a CI gate.

### Trade-offs & Limitations
Proofline is useful before buying accelerator time: it can narrow hardware choices and catch modeled changes to work, I/O, or serial depth in CPU CI. It does not replace `torch.profiler`, which observes actual operator execution and dispatch, or a vLLM/SGLang load test, which measures latency and throughput under real traffic. A lower floor does not guarantee a faster deployment, and a compiler- or scheduler-only regression need not move the floor at all. Treat emitted batch and concurrency settings as candidates to benchmark, not production capacity targets.

The central risk is model fidelity. Data-dependent control flow or untraced side effects can change the runtime graph; compulsory work and traffic depend on the algorithm, precision, or permitted rewrites. Many presets use spec numbers rather than measurements, so modeled rankings can shift when calibrated compute, bandwidth, or communication costs are substituted. Z3 and Lean 4 check deductions within those assumptions, not compiler passes, drivers, or silicon. Use a calibrated profile and a representative workload before relying on a close ranking or an SLO estimate.

### Hardware & Deployment Guide
The core analyzer can be installed from Git with pip into a CPU-only PyTorch environment. The `formal` extra adds Z3 and SymPy; local Lean verification separately requires Lean 4.34.1 or newer, found on `PATH` or through `PROOFLINE_LEAN_BIN`. Local PyTorch, configuration, GGUF, and ONNX inputs can be analyzed offline; the Hugging Face repository path also offers an explicit `--online` mode. Live CUDA or MPS calibration is a separate step and needs access to the device being measured.

For teams, `.github/actions/proofline-gate/action.yml` runs the modeled regression check on CPU runners and writes a Markdown delta to the job summary. The MCP entry point runs as a local stdio process. v1.6.0 organized the CLI into eight task-oriented commands, and v1.7.0 added the dedicated fusion blueprint command and MCP tool. Commands generated for vLLM, SGLang, or llama.cpp are deployment starting points; those runtimes and model artifacts are separate from the analyzer.
```

## Key Capabilities
```text
- CPU-only ingestion: Uses PyTorch FakeTensor/meta tracing, Hugging Face config and safetensors metadata, GGUF headers, or ONNX graphs rather than running GPU inference.
- Latency model: Separates the global compute, I/O, and critical-path floor from stage-wise bounds and an eager dispatch reference.
- Fleet planning: Compares 34 built-in presets and custom profiles; evaluates TTFT/TPOT-constrained goodput and cost per million output tokens.
- Fusion planning: Partitions traceable PyTorch graphs using shared-memory and register-pressure constraints, with tiled FlashAttention and Split-KV FlashDecoding plans.
- Formal verification: Optional Z3 and Lean 4 checking establishes results under explicit trace, compulsory-work, and hardware assumptions.
- Engineering workflows: `diff` gates modeled regressions in CPU CI; offline HTML and seven stdio MCP tools expose the analysis to humans and coding agents.
```

## Quick Start / Clone
```bash
pip install git+https://github.com/kongtou20070406/proofline.git
```
