Back to Model List

ForgeStencil – The Fully Automated Stencil Research and Deployment System Launched by OpenBMB

AI Tech Editorial
RSS Feed

Executive Summary:

ForgeStencil is a fully automated Stencil research and deployment system launched by OpenBMB in collaboration with OpenBMB open-source community. Based on a dual-agent closed-loop architecture combini...

1. What is ForgeStencil

ForgeStencil is a fully automated Stencil research and deployment system launched by OpenBMB in collaboration with OpenBMB open-source community. Based on a dual-agent closed-loop architecture combining Kernel Agent and App Agent, this system enables the entire optimization process—from strategy discovery to integration into real-world production software—with zero manual intervention. Within a week, ForgeStencil completed end-to-end optimization for over 100 industrial and scientific computing applications, achieving a median acceleration factor of 1.41x, spanning eight major industrial fields and five major scientific fields, including oil and gas exploration, electromagnetic simulation, and medical imaging.

Technical Positioning and Domains: ForgeStencil is positioned at the intersection of high-performance computing (HPC) and AI system optimization, focusing on the automatic optimization and deployment of Stencil computation patterns. Stencil computation is a core pattern in scientific computing and industrial simulation, widely used in solving differential equations and image processing. Unlike traditional manual tuning based on expert experience or automatic tuning using fixed templates, ForgeStencil leverages AI Agent technology to autonomously explore the optimization space, achieving full automation from strategy discovery to engineering deployment. It is one of the earliest systems in this field to realize end-to-end zero-human-in-the-loop optimization.

Development Background: Jointly developed by OpenBMB and the OpenBMB open-source community. OpenBMB has deep expertise in AI system optimization and model compression, having launched several influential open-source projects. OpenBMB is a well-known open-source large model community, dedicated to promoting the openness and sharing of large model technologies. The motivation for this development directly stems from industry pain points, such as the heavy reliance on human HPC experts for Stencil optimization, the long optimization cycle for individual applications (often spanning months), and the difficulty in reusing optimization experience. The team aims to introduce AI Agent technology to increase optimization efficiency by an order of magnitude, enabling non-expert teams to achieve performance close to hardware limits.

Core Value: The core value of ForgeStencil lies in significantly lowering the barrier to entry for Stencil optimization, addressing key issues with traditional methods, such as long optimization cycles, high costs, and poor reusability. Through the automated Agent closed-loop, the optimization cycle for a single application is reduced from months to within a day, allowing over 100 applications to be optimized in just one week, effectively saving approximately 20–30 person-years of research and development investment. Additionally, its auditable measurement protocol ensures the authenticity and reliability of optimization results, directly targeting production-level software optimization, enabling the optimization outcomes to be applied directly to real-world industrial scenarios and bridging the gap between lab performance and actual performance.

2. Key Features

  • Dual-Agent Closed-Loop Optimization: The Kernel Agent autonomously researches and synthesizes high-performance CUDA kernels, approaching the physical limits of hardware through a Plan→Code→Profile cycle. The App Agent performs hot spot localization, operator forging, correctness verification, and application integration. Together, they form a complete closed-loop from theoretical discovery to engineering implementation, achieving full-process automation without requiring human experts to intervene in decision-making.

  • Automatic Strategy Discovery: The Agent autonomously explores optimization strategies such as tiling, fusion, layout, occupancy, and host-side rewrites, rather than searching within a fixed space. This enables the system to discover optimization combinations that human experts might overlook, breaking through the limitations of traditional auto-tuning that relies on pre-defined strategy templates, thereby achieving better performance.

  • Real-World Application Deployment: Directly targets production-level software optimization, performing end-to-end validation using the application's own GPU code as a baseline, rather than simplified benchmarks. This ensures that optimization results can be directly applied to real industrial scenarios, avoiding the gap between lab performance and real-world performance. 42% of the optimization targets are real industrial production software.

  • Auditable Measurement Protocol: By using a single environment switch (USE_OURS), the system alternates between the original path and the optimized path. It utilizes built-in correctness checks and timers within the program, and takes the median after multiple rounds of interleaved execution. This eliminates the possibility of measurement fraud at the system level, ensuring the accuracy and reliability of the speedup data.

  • Cross-Generation GPU Compatibility: Supports runtime architecture distribution for GPUs such as A100, H100, and B200. The same codebase automatically selects the optimal kernel path based on the architecture. When hardware is upgraded, the system automatically re-forges kernels to capture new hardware characteristics, ensuring sustained performance without the need for manual code adjustments.

  • Operator Matrix and Knowledge Base Evolution: During the optimization process, the Kernel Agent continuously builds an operator matrix as a knowledge base, which subsequent App Agents can reuse existing techniques. Multiple parallel Agents share this knowledge base, enabling real-time knowledge sharing and collective evolution, overcoming the bottleneck of scaling human expert experience.

  • Patch Mode and Zero Source Bundling: Does not bundle any third-party source code. Each application only provides upstream source records, acquisition scripts, and integration patches. The vendor.sh script automatically pulls the specified version of upstream code. This ensures license cleanliness and reproducibility of results, which is crucial for both commercial applications and academic research.

3. How to Use

  1. Environment Setup: Clone the GitHub repository (git clone https://github.com/OpenBMB/ForgeStencil), and ensure your system is equipped with an NVIDIA GPU (recommended A100 or higher), CUDA 12.x, a C++17-compatible compiler (such as GCC 9+), and Python 3.9 or higher. Install the required dependencies according to the README in the repository, including PyTorch, OpenAI API libraries, etc. It is recommended to run this in a Linux environment.

  2. Quickly Experience the Operator: Run the command python tools/run.py --stencil star_1 --shape 256 --gpu 0 to measure the performance of a single Stencil operator within about 1 minute and compare it with the Halide baseline. This step is suitable for quickly understanding ForgeStencil's optimization capabilities without needing to configure a full application environment.

  3. End-to-End Reproduction: Enter the target application directory (e.g., one of the applications under apps/), and execute ./vendor.sh to automatically fetch the upstream source code of the specified version. Then integrate the patches into the application and run python ../../harness/run_e2e.py --app <name> --gpu auto to complete the end-to-end verification of the real application. The system will output the speedup ratio and correctness check results, allowing you to reproduce the published speedup data.

  4. Drive Agent Operations: Refer to agents/README.md to configure the Kernel Agent and App Agent. You need to set the OpenAI API key (used for the agent's decision-making and reasoning) and adjust the agent parameters as needed (such as parallelism, search depth, etc.). After starting, the agent will autonomously perform the optimization loop, generating new kernels and integrating them into the application. It is recommended to start testing the agent workflow with simpler applications.

  5. Review the Results Registry: By examining the results/integration_registry.json file, you can obtain the audit speedup data for the 100 verified applications. This file contains specific speedup ratios, hardware platforms, verification status, and other information for each application, which can serve as a reference for selecting applications of interest for reproduction or further development.

4. Pros and Cons Analysis

Pros
End-to-end automation: From application analysis, hot spot identification, to Kernel forging and integration verification, the entire process requires no involvement from HPC experts, significantly reducing labor costs and improving R&D efficiency.
Real-world scenario validation: End-to-end optimization is performed directly using the production-level software's own GPU code as a baseline, ensuring that the optimization results have real industrial value and avoiding biases caused by simplified benchmark tests.
Significant improvement in R&D efficiency: Optimization for a single application is reduced from months to within a day, with over 100 applications completed in a week, saving approximately 20-30 person-years of R&D investment. The acceleration data has been strictly audited.
Noticeable performance acceleration: The end-to-end median acceleration is 1.41x, with 43% of applications achieving over 1.5x acceleration. The geometric mean at the operator level is 2.16x, surpassing the best open-source baseline, demonstrating significant optimization effectiveness.

5. Comparative Analysis with Similar Tools

Dimension ForgeStencil Halide
Optimization Strategy Source Agent autonomously discovers new strategies, not limited to fixed search spaces Human-designed DSL and scheduling strategies, automation is constrained by predefined rules
Deployment Scope Supports end-to-end integration and validation in real-world applications Primarily targets single operators/image processing pipelines, lacks application-level auto-deployment
Baseline Comparison Uses the application's own generated GPU code as the baseline Typically uses simplified reference implementations or CPU versions as the baseline
Correctness Verification Uses built-in program checks and interleaved measurements to ensure reliability Relies on framework-internal tests, no system-level anti-fraud protocols
Knowledge Accumulation Multiple agents share a knowledge base of operator matrices, enabling reusable experience Optimization experience is scattered among experts, making systematic reuse difficult

For industrial users requiring end-to-end automated optimization and real-world application acceleration, ForgeStencil is a more suitable choice. It can directly optimize production-level software without the need to manually write kernels or scheduling strategies, and the acceleration data has been strictly audited, ensuring high reliability. However, it is important to note its hardware dependency (NVIDIA GPU) and external API dependency (OpenAI).

For developers who wish to flexibly control operator scheduling and conduct algorithm research, Halide provides a powerful DSL and scheduling primitives, allowing for fine-grained optimization. However, Halide lacks application-level automatic deployment capabilities, and optimization results must be manually integrated into the target application. Additionally, optimization experience is difficult to systematically reuse.

For researchers accustomed to writing GPU operators in Python, Triton offers a concise programming model and automatic tuning capabilities, making it suitable for rapid prototyping. However, Triton also requires manual integration into applications, and its ability to discover optimization strategies is inferior to ForgeStencil's agent system. Its knowledge accumulation mechanism is also relatively weak.

6. Editor's Summary

ForgeStencil demonstrates strong innovation in technology, introducing AI decision-making into the traditional HPC optimization domain through its dual-Agent collaborative architecture. This enables full automation from strategy discovery to engineering deployment. Compared to existing tools such as Halide and Triton, ForgeStencil's greatest breakthrough lies in "zero human intervention" and "real-world application validation," directly addressing the long-standing efficiency bottleneck in industrial optimization. The design of the auditable measurement protocol also reflects a strong emphasis on result credibility, which holds significant importance in both academic research and industrial applications, effectively preventing issues of performance data fabrication.

In terms of practical value, ForgeStencil has already validated its effectiveness across eight major industrial fields and five major scientific fields. The median acceleration of 1.41x, with 43% of applications achieving over 1.5x speedup, demonstrates its solid optimization capabilities. The optimization cycle for a single application has been reduced from months to within a day, significantly lowering the barrier to entry for high-performance computing optimization and enabling non-expert teams to achieve performance close to hardware limits. For compute-intensive industries such as oil and gas exploration, electromagnetic simulation, and medical imaging, ForgeStencil can significantly shorten the R&D cycle and reduce computational costs. Additionally, its open-source Apache 2.0 license and Patch mode ensure compliance for commercial use.

ForgeStencil is primarily suitable for the following groups: industrial software engineers optimizing Stencil-intensive applications, scientific computing researchers, HPC system administrators, and machine learning engineers interested in AI-driven automatic optimization. Its open-source nature also allows academic researchers to perform secondary development or comparative experiments based on it. For teams aiming to quickly enhance application performance but lacking HPC experts, ForgeStencil provides a practical and feasible automated path.

In terms of future development potential, ForgeStencil currently focuses on the Stencil computation pattern, but its dual-Agent architecture and knowledge base mechanism provide a foundation for expansion into more computation patterns (such as sparse matrices, convolutions, etc.). Moreover, support for non-NVIDIA GPUs and reduced reliance on external APIs will be important directions for future evolution, further broadening its applicability. As the Agent system continues to evolve and the knowledge base accumulates, its optimization efficiency is expected to improve further. Overall, ForgeStencil represents an important practice at the intersection of AI and HPC, opening up new directions for automated performance optimization.

7. Application Scenarios

  • Oil and Gas Seismic Exploration: Optimize core algorithms such as reverse time migration (RTM) to accelerate the data processing workflow in oil exploration. ForgeStencil can automatically optimize Stencil computations in seismic wave propagation simulations, improving imaging efficiency, shortening exploration cycles, and reducing computational costs.

  • Electromagnetic Simulation Design: Enhance the efficiency of solving Maxwell's equations using Yee grid-based tools like gprMax/FDTD, supporting electromagnetic analysis for radar and chip design. Through automated Kernel optimization, simulation time can be reduced by over 40%, enabling more detailed electromagnetic model computations.

  • Medical Image Reconstruction: Accelerate medical imaging computational workloads such as non-Cartesian MRI reconstruction and digital breast tomosynthesis backprojection. ForgeStencil can significantly reduce reconstruction time without compromising accuracy, supporting real-time clinical diagnostic processes.

  • Climate and Astrophysics: Optimize Stencil-intensive scientific computing applications such as atmospheric dynamics and cosmological simulations. These fields typically require large-scale parallel computing, and ForgeStencil's automatic optimization can improve simulation resolution and speed, advancing scientific research.

  • Quantitative Finance Computing: Provide automatic Stencil hot spot optimization for pricing libraries used in financial institutions, such as QuantLib, to reduce transaction computation latency. Pricing financial derivatives involves solving a large number of partial differential equations, and ForgeStencil can significantly enhance computational efficiency, supporting higher-frequency trading strategies.

8. FAQ

Q: Does ForgeStencil only support NVIDIA GPUs?
A: Currently, ForgeStencil is primarily validated and optimized for NVIDIA GPUs (A100/H100/B200) and requires a CUDA 12.x environment. Support for AMD GPUs or hardware from other vendors is not officially available yet. Platform compatibility may be expanded in the future based on community feedback and subsequent iterations.

Q: Is HPC expertise required to use ForgeStencil?
A: No. ForgeStencil is designed to be fully automated, requiring no manual intervention. Users do not need to understand low-level hardware details or optimization strategies. Simply provide the application code, and the system will automatically complete hot-spot detection, Kernel synthesis, and integration verification.

Q: Are the acceleration ratio results from ForgeStencil reliable?
A: ForgeStencil includes an auditable measurement protocol that alternates between the original path and the optimized path using a single environmental switch. It utilizes built-in program checks and timers to ensure the accuracy and reliability of the acceleration ratio. All results can be reproduced in the same environment, and the open-source code is available for verification.

Q: What is the difference between ForgeStencil and Triton?
A: Triton is a programming language and compiler used for writing GPU operators, requiring developers to manually write Kernels and integrate them. ForgeStencil, on the other hand, is a fully automated optimization system that can automatically discover optimization strategies and complete end-to-end deployment without requiring manual coding. The two tools have different purposes and can be used complementarily.

Q: Does ForgeStencil support custom Stencil patterns?
A: Yes. Users can define new Stencil patterns through configuration files, and ForgeStencil's Agent system can automatically explore optimization strategies based on these patterns. The operator matrix knowledge base will continue to expand to cover more patterns, but some configuration work is required.

Q: What is the open-source license for ForgeStencil?
A: ForgeStencil is licensed under the Apache 2.0 license. The code is fully open-source and supports both commercial and academic use. However, note that external services such as the OpenAI API it depends on require separate authorization, and some datasets may be subject to different licenses.

9. Project Links

Related AI Model Articles

© All Rights Reserved. Some content on this site is partially generated by AI with human review.