Skip to main content

MegMind's ForgeStencil: AI That Optimizes 100+ Industrial Apps in a Week

In the world of modern industry and cutting-edge research, there's a silent workhorse: high-performance computing software. At its core often lies a computational pattern called stencil computation. Think weather forecasting, seismic exploration, electromagnetic simulations, or material science—they all rely on repeatedly updating grids using weighted combinations of neighboring points. This memory-intensive process can hog a significant chunk of an application's runtime, and its speed can make or break a nation's industrial and scientific efficiency.

Traditionally, optimizing stencil computations to the physical limits of hardware required the rare expertise of HPC specialists. Compilers, code generators, and auto-tuning systems could generate code and search parameters, but the optimization algorithms themselves still needed manual design and integration. Whenever scenarios, shapes, or hardware changed, experts had to step in again—a bottleneck that prevented scalability.

Now, that's changing. Mianbi Intelligence, in collaboration with the OpenBMB open-source community, has released ForgeStencil—the world's first AI optimization system for stencil computations. It's open-sourced and designed to automate the entire optimization process, from analysis to deployment.

Image

According to the team, ForgeStencil completed automatic optimization of over 100 real industrial and scientific computing software within just one week. Each application's optimization time dropped to hours, boosting R&D efficiency by about 100 times. This scalability means stencil optimization is no longer bound by human availability.

The most disruptive aspect is its dual-agent, zero-human-intervention approach. You simply feed it the source code of the application you want to optimize. From automatic analysis and hotspot localization to kernel forging, operator replacement, correctness verification, and integration back into the original app—no human experts are involved in the decision-making. The system comprises two parts: the Kernel Agent, which acts as a scientist, researching and synthesizing high-performance kernels, building a specialized operator matrix for various stencil types, shapes, and precision requirements, and translating mathematical expressions into elegant code that approaches hardware limits. The App Agent, on the other hand, is the pragmatic engineer, crafting tailored solutions for each real application, identifying hotspots, establishing GPU baselines, verifying integrations, and finally conducting end-to-end evaluation using the application's own test cases.

In head-to-head comparisons with well-known frameworks like Halide, Devito, EBISU, DRStencil, and FlashFFTStencil, ForgeStencil achieved a geometric mean speedup of 2.35x under the same fp32 precision. With mixed fp16 precision, it gained an additional 1.95x speedup. Even on the notoriously difficult variable-coefficient stencils with all shapes, it still managed a 1.34x geometric mean acceleration over the best baseline.

Image

But ForgeStencil isn't just about benchmarks—it tackles real industrial scenarios. About 42% of its optimizations directly correspond to real production loads. For instance, the hypre structured multigrid solver library was accelerated by 3.86x, minisweep nuclear reactor neutron transport by 5.78x, gprMax and FDTD electromagnetic simulations by 2.47x, RTM reverse time migration for oil and gas seismic imaging by 1.81x, Total's minimod seismic mini-app by 1.22x, QuantLib bond pricing by 1.82x, non-Cartesian MRI reconstruction by 2.45x, and digital breast tomosynthesis back-projection by 1.63x. These are real production loads from oil companies, medical equipment, and meteorological departments.

Compared to human experts who keep their knowledge locked in their minds, ForgeStencil allows a large number of parallel agents to share a common knowledge base, enabling real-time exchange of experience and achieving intelligent collective synchronization and evolution. This is another achievement from Mianbi Intelligence based on the Forge Engineering software engineering paradigm, following the ForgeTrain release in May. It moves from self-generated code to automatic research and optimization, and from local operator acceleration to real application deployment.

In the short term, the automatic optimization of existing industrial software can achieve near-hardware-limit results within hours, directly reducing costs and improving efficiency through computing cost savings and R&D compression. In the long term, when the digital foundation of high-end equipment, energy exploration, and chip design—such as CAE simulation, seismic imaging, electromagnetism, and fluid dynamics—is automatically optimized, the acceleration of domestic manufacturing upgrading will be stepped on. Currently, ForgeStencil is open-sourced on GitHub, and Mianbi Intelligence has issued an invitation to HPC scholars, industrial software professionals, and open-source developers to join in building it.

Key Points

  • ForgeStencil is an AI-driven system for automatic stencil optimization, open-sourced by Mianbi Intelligence and OpenBMB.
  • It uses a dual-agent approach (Kernel Agent and App Agent) to achieve zero-human-intervention optimization.
  • In one week, it optimized over 100 industrial software, with speedups up to 5.78x in real applications.
  • It outperforms existing frameworks like Halide and Devito, achieving 2.35x geometric mean speedup in fp32.
  • The system is designed to scale with computing power, enabling collective intelligence among agents.