What is ForgeStencil
ForgeStencil is the world's first AI optimization system supporting Stencil automated research and automated deployment, launched by ModelBest in collaboration with the OpenBMB open-source community. Based on a dual-agent closed loop of Kernel Agent and App Agent, it achieves zero human intervention throughout the entire process from optimization strategy discovery to real production software integration. The system completed end-to-end optimization of over 100 industrial and scientific computing software applications within one week, with a median speedup of 1.41x, covering 8 major industrial domains including oil and gas exploration, electromagnetic simulation, and medical imaging, as well as 5 major scientific domains.
Main Features of ForgeStencil
-
Dual-Agent Closed-Loop Optimization: Kernel Agent autonomously researches and synthesizes high-performance CUDA Kernels, while App Agent completes hotspot localization, operator forging, correctness verification, and application integration.
-
Automatic Strategy Discovery: Agents autonomously explore optimization strategies such as tiling, fusion, layout, occupancy, and host-side refactoring, rather than searching within a fixed space.
-
Real Application Deployment: Directly targets production-grade software optimization, performing end-to-end verification with the application's own GPU code as the baseline, rather than simplified benchmarks.
-
Auditable Measurement Protocol: Alternates between the original path and the optimized path through a single environment switch, using the program's built-in checks and timers to ensure the speedup is authentic and trustworthy.
-
Cross-Generation GPU Adaptation: Supports runtime architecture dispatch for A100/H100/B200, automatically selecting the optimal Kernel path per architecture from the same codebase.
Technical Principles of ForgeStencil
- Dual-Agent Collaborative Architecture: The system forms a closed loop consisting of Kernel Agent and App Agent. Kernel Agent is responsible for theoretical discovery, autonomously researching and synthesizing Stencil operators approaching hardware physical limits through a Plan→Code→Profile loop; App Agent is responsible for engineering implementation, locating application performance hotspots, establishing GPU baselines, invoking the operator matrix knowledge base built by Kernel Agent to forge application-specific optimizations, and completing correctness verification and integration with the original application.
- Operator Matrix and Knowledge Base Evolution: Kernel Agent continuously builds a dedicated operator matrix as a knowledge base during optimization, which subsequent App Agents can reuse for existing techniques; multiple parallel Agents share this knowledge base, achieving real-time experience sharing and collective synchronous evolution, breaking through the bottleneck that human expert experience is difficult to transfer at scale.
- Auditable End-to-End Protocol: Measurement uses the application's own production-grade GPU implementation as the sole baseline, with the original path and optimized path distinguished only by a single
USE_OURSswitch, and the original path is byte-identical to upstream; using the program's built-in correctness checks and timers, taking the median over multiple interleaved runs, and finally reporting the geometric mean speedup across all standard test cases, eliminating any room for falsification at the system level. - Patch Mode and Zero Source Code Bundling: No third-party source code is bundled; each application provides only upstream provenance records, fetch scripts, and integration patches, automatically pulling the specified upstream version via
vendor.sh, ensuring license cleanliness and reproducible results.
Follow WeChat and reply "open source" to join theAI Open Source Project Communication Group
How to Use ForgeStencil
-
Environment Preparation: Clone the repository and ensure you have an NVIDIA GPU (verified on A100), CUDA 12.x, a C++17 compiler, and a Python 3.9+ environment.
-
Quick Start with an Operator: Run
python tools/run.py --stencil star_1 --shape 256 --gpu 0to measure single-operator performance within 1 minute and compare it against the Halide baseline. -
End-to-End Reproduction: Enter the target application directory and run
./vendor.shto pull the upstream source code, apply the integration patch, and then runpython ../../harness/run_e2e.py --app <name> --gpu autoto complete real-application validation. -
Drive Agents to Work: Refer to
agents/README.mdto configure and start the autonomous optimization loop of the Kernel Agent and the App Agent. -
Consult the Results Registry: Use
results/integration_registry.jsonto view audited speedup data for 100 validated applications.
Core Advantages of ForgeStencil
-
Zero Manual Intervention: The entire workflow—from application analysis, hotspot localization, and Kernel forging to integration validation—is automated, with no HPC experts needed to make decisions.
-
Real-World Scenario Oriented: Directly optimizes production-grade industrial software; 42% is real industrial production software, and the baseline is the application's own GPU code.
-
Leap in R&D Efficiency: Single-application optimization is shortened from months to within one day, with 100+ applications completed in one week, equivalent to saving about 20–30 person-years of R&D investment.
-
Strong Performance: End-to-end median speedup of 1.41x, 43% of applications at ≥1.5x, and an operator-level geometric mean of 2.16x, leading the best open-source baseline.
-
Cross-Architecture Sustainability: Supports runtime dispatch across multiple generations of NVIDIA GPUs, and can automatically reforge Kernels during architecture upgrades to capture new hardware features.
ForgeStencil Project Address
- GitHub Repository:https://github.com/OpenBMB/ForgeStencil
Comparison of ForgeStencil with Similar Competitors
| Dimension | ForgeStencil | Halide |
|---|---|---|
| Source of Optimization Strategy | Agents autonomously discover new strategies rather than searching a fixed space | Humans design DSLs and scheduling strategies, and automation is limited to preset rules |
| Deployment Scope | Supports end-to-end integration and validation for real applications | Mainly oriented toward single operators/image-processing pipelines, lacking application-level automated deployment |
| Baseline Comparison | Uses the application's own production GPU code as the baseline | Usually uses simplified reference implementations or CPU versions as the baseline |
| Correctness Validation | Uses the program's built-in checks, with interleaved measurement to ensure credibility | Relies on framework built-in tests, with no system-level anti-fraud protocol |
| Knowledge Accumulation | Multiple Agents share an operator-matrix knowledge base, and experience can be reused | Optimization experience is scattered among individual experts and difficult to transfer at scale |
Application Scenarios of ForgeStencil
-
Oil and Gas Seismic Exploration: Optimizes core algorithms such as RTM reverse time migration and TotalEnergies mini-app, accelerating petroleum exploration data processing workflows.
-
Electromagnetic Simulation Design: Improves the efficiency of solving Yee-grid Maxwell equations such as gprMax/FDTD, serving radar and chip electromagnetic analysis.
-
Medical Image Reconstruction: Accelerates medical imaging workloads such as non-Cartesian MRI reconstruction and digital breast tomosynthesis backprojection.
-
Climate and Astrophysics: Optimizes Stencil-intensive scientific computing applications such as atmospheric dynamics and cosmological simulations.
-
Quantitative Financial Computing: Provides automatic Stencil hotspot optimization for financial institution pricing libraries such as QuantLib, reducing transaction calculation latency.