How pablo389/deepbork works
1. What this repo is
- deepbork is a TritonBench-T generation and evaluation pipeline, centered on generating Triton Python candidates, sending them through the TritonBench-T harness, and optionally repairing failures in a local loop.
- The architectural boundary is between local orchestration and remote benchmark execution on Modal.
2. Primary data contract
- predictions.jsonl is the key interchange format.
- Each record contains an instruction and a generated predict string.
- Generation produces this file; evaluation consumes it; the agentic loop regenerates it per attempt.
3. Prompt and benchmark inputs
- The repo reads TritonBench-T Alpaca prompt files from data/:
- TritonBench_T_simp_alpac_v1.json
- TritonBench_T_comp_alpac_v1.json
- TritonBench_T_v1.jsonl is the metadata index used to map prompt instructions back to benchmark operator files and tests.
- The benchmark’s golden reference files are not owned here; they are pulled from the upstream TritonBench repo during remote evaluation.
4. Batch generation subsystem
- main.py is the generator entrypoint.
- It builds prompt messages, calls an LLM endpoint via the OpenAI-compatible client, cleans generated code fences, and writes outputs/predictions.jsonl by default.
- It supports multiple providers, including a local/remote Modal vLLM endpoint and the public OpenAI API.
5. Batch evaluation wrapper
- evaluate.py is a thin local CLI/Python launcher for Modal-based evaluation.
- Its job is orchestration only: select a mode (phase1, phase2, phase3, or all), pass the local JSONL or a Modal Volume path, and invoke the remote app.
- It preserves the separation between local artifact preparation and remote benchmark execution.
6. Remote execution on Modal
- modal_eval_app.py is the execution boundary for TritonBench-T.
- It defines the Modal image, GPU runtime, and Modal Volume storage used for evaluation artifacts.
- The remote app clones/patches the TritonBench harness inside the container, runs Phase 1/2/3, and stores outputs under phase-specific directories in the Modal Volume.
7. Phase-based evaluation pipeline
- The benchmark is intentionally split into independent stages:
- Phase 1: call accuracy
- Phase 2: additional semantic / execution filtering
- Phase 3: performance-oriented benchmarking
- The phases can run together or independently, which is important for both batch workflows and repair loops.
8. Metadata matching helper
- tritonbench_helpers.py provides the crosswalk between prompt rows, benchmark metadata, and operator filenames.
- This is the glue that lets the evaluator recover the correct TritonBench test target from an instruction in predictions.jsonl.
- It is packaged into the Modal container so local and remote matching logic stays consistent.
9. Agentic repair subsystem
- agentic_eval.py implements a one-operator generate/evaluate/repair loop.
- It selects a single benchmark op, generates a candidate, writes per-attempt artifacts, runs evaluation up to a target stage, and if needed asks the model to repair using failures from stdout/stderr.
- The loop always re-enters evaluation from Phase 1 after a repair, because the source code may have changed and earlier results are no longer valid.
10. Curated repair knowledge
- repair_rules/ contains JSON rule sets for Phase 1, Phase 2, and Phase 3 failures.
- These are data-driven prompts, not code: the agentic loop injects only the rules relevant to the stage that failed.
- This creates a feedback boundary between deterministic failure signals and LLM-driven repair.
11. Artifact layout and persistence
- Local generation/evaluation artifacts live under outputs/.
- Agentic attempts are separated by op and attempt number, with per-attempt predictions, generated code, summaries, and repair prompts.
- Remote Modal artifacts are also staged by phase and attempt, making the system traceable across local and cloud execution.
12. Key end-to-end flows
- Batch flow: main.py → outputs/predictions.jsonl → evaluate.py → modal_eval_app.py → Modal Volume results.
- Agentic flow: agentic_eval.py → generate one candidate → remote evaluation → accept or repair → repeat until the target stage passes or attempts are exhausted.
- The repo’s architecture is built around keeping these flows composable while sharing the same prompt, metadata, and benchmark contracts.
Main entry points: agentic_eval.py Agentic loop · modal_eval_app.py Modal runner · evaluate.py Eval launcher · main.py Generator
Components 16
Local orchestration
CLI entrypoints and local repair loop.
- Generator · Batch generation entrypoint that builds prompts, calls an LLM, and writes predictions.
main.py - Eval launcher · Local wrapper that selects evaluation mode and invokes the remote Modal app.
evaluate.py - Agentic loop · Single-operator generate/evaluate/repair workflow with per-attempt artifacts.
agentic_eval.py - Metadata crosswalk · Resolves instructions to TritonBench operator files and tests.
tritonbench_helpers.py
Remote benchmark
Modal-based execution boundary and remote artifact store.
- Modal runner · Defines the Modal image, GPU runtime, harness setup, and phase execution on Modal.
modal_eval_app.py - Modal volume · Remote phase outputs persisted across Modal evaluation runs.
- Phase 1 · Initial correctness and call-accuracy filtering stage.
- Phase 2 · Additional semantic and execution filtering stage.
- Phase 3 · Performance-oriented evaluation stage.
Benchmark data
Prompt inputs, metadata index, and shared prediction contract.
- Predictions · Primary contract containing instruction and predict fields for generation and evaluation.
- Simple prompts · Alpaca-formatted simple TritonBench-T prompts.
data/TritonBench_T_simp_alpac_v1.json - Complex prompts · Alpaca-formatted complex TritonBench-T prompts.
data/TritonBench_T_comp_alpac_v1.json - Benchmark index · Maps prompt instructions back to operator files and tests.
data/TritonBench_T_v1.jsonl
Repair rules
Stage-specific failure guidance for the agentic loop.
- Phase 1 rules · JSON guidance for failures detected in Phase 1.
repair_rules/triton_phase1_rules.json - Phase 2 rules · JSON guidance for failures detected in Phase 2.
repair_rules/triton_phase2_rules.json - Phase 3 rules · JSON guidance for failures detected in Phase 3.
repair_rules/triton_phase3_rules.json
Connections 21
- Simple prompts → Generator: prompt input · Generator reads simple benchmark prompts.
- Complex prompts → Generator: prompt input · Generator reads complex benchmark prompts.
- Generator → Predictions: writes · Batch generation emits the shared predictions contract.
- Predictions → Eval launcher: consumes · Local evaluation launcher passes predictions to remote execution.
- Eval launcher → Modal runner: invokes · Launches the Modal evaluation boundary.
- Modal runner → Metadata crosswalk: resolves targets · Remote app maps instructions to benchmark operators and tests.
- Benchmark index → Metadata crosswalk: lookup data · Metadata index feeds instruction-to-target resolution.
- Predictions → Modal runner: input · Remote evaluation consumes generated predictions.
- Modal runner → Phase 1: runs · Phase 1 is the first evaluation stage.
- Phase 1 → Phase 2: continues · Successful or selected outputs proceed to Phase 2.
- Phase 2 → Phase 3: continues · Phase 3 follows the semantic filter stage.
- Phase 1 → Modal volume: stores results · Phase outputs are persisted in the Modal Volume.
- Phase 2 → Modal volume: stores results · Phase outputs are persisted in the Modal Volume.
- Phase 3 → Modal volume: stores results · Phase outputs are persisted in the Modal Volume.
- Agentic loop → Predictions: writes attempts · Each repair attempt regenerates predictions and related artifacts.
- Agentic loop → Eval launcher: reuses · The repair loop calls the same evaluation launcher.
- Agentic loop → Phase 1 rules: uses · Phase 1 failure guidance is injected on demand.
- Agentic loop → Phase 2 rules: uses · Phase 2 failure guidance is injected on demand.
- Agentic loop → Phase 3 rules: uses · Phase 3 failure guidance is injected on demand.
- Agentic loop → Modal volume: persists · Per-op and per-attempt artifacts are stored remotely when needed.
- Modal volume → Eval launcher: returns artifacts · Remote results are surfaced back to the local orchestration layer.