2/n PolyBlocks can now compile JAX for Google TPUs via Mosaic/MLIR while reusing the same core transformation infrastructure used for its CPU, GPU, and GPU-CUDA-tile paths! The affine + memref abstractions PolyBlocks uses for its mid-level transformations match smoothly with the tile-level abstractions of Mosaic with its TPU dialect, just like they do for CUDA-tile. Tiling, fusion, mapping to matmul units, and matricization were key pieces that were almost reused as-is.
PolyBlocks-compiled JAX already worked for GPUs with state-of-the-art performance. Preliminary results now show great promise for TPUs -- exposing what the Mosaic compiler delivers to higher-level frameworks effectively! To the best of our knowledge, this is the first path, other than XLA, to compile for TPUs from a high-level framework. It's also the first to rest solely on Mosaic while compiling JAX.
3/n PolyBlocks uses the same MLIR-based pass pipelines for both PyTorch and JAX. Its more powerful approach to tiling, fusion, and other transformations delivers improvements across target backends and high-level programming frameworks.
https://t.co/t3uzSBQZM9
This car's rear will not swing outwards by design (rear/tail swing) when turned sharply left from here. The girl is stuck at the rear door. Turn the steering sharply to the left, go a couple of inches forward, stop, turn sharply to the right, and go a couple of inches; this will create more space in that gap. Repeat this a few times to make more space. The same can be done in reverse, depending on where there is more space.
1/n A single reusable compiler engine that works across frameworks (PyTorch, JAX), from edge to data center accelerators, from CPUs to GPUs and Google TPUs (recently). PolyBlocks is fully MLIR-based, completely code-generating (does not employ libraries/kernels), and highly amenable to AI-driven compiler construction. More recently, allows rapid development of new compilers layered on top of tile-level frameworks (e.g., CUDA Tile for GPUs, Mosaic for TPU).
#aicompiler #mlir
4/n PolyBlocks' modular passes and cost models parameterized on target info allow the single compiler engine to generate high-performance code on accelerator devices from Orin Nano chips to laptop GPUs (e.g., RTX 4080) to big data center GPUs (like the Blackwell Geforce RTX 6000 Pro).
AI for principled compiler construction!
Everyone is talking about AI-generated high-performance kernels, but the real opportunity lies in using AI effectively to build compilers! Why use AI to generate kernels one by one when it can build a kernel generator for infinite reuse?
By pairing solid compiler engineering principles with tools like Claude, we built a CUDA Tile IR backend for PolyBlocks in a few weeks, achieving a level of performance that typically takes multiple human-years!
Our backend now compiles unmodified PyTorch and JAX models to a sequence of fused CUDA tile kernels (all via MLIR) with state-of-the-art performance. By layering on top of the NVIDIA CUDA Tile IR compiler, we offload lower-level optimizations to it. Both NVIDIA GPU backends of PolyBlocks, cuda-tile-based and non-cuda-tile-based (which we had developed over several years), still rest on the same Polyblocks code generation infrastructure for affine fusion, tiling, mapping to MMAs, 2-d tilization, etc., but the cost models they use on both paths are slightly different.
Check out the benchmarks below showing wall-clock and total kernel execution times.
More to come! Compilers are now finally evolving rapidly!
@JeffDean Wishing you the absolute best for all you are pursuing next, and I'm sure it'll change the world again. I also remain incredibly grateful for hosting me as visiting faculty at Brain in 2018-19 -- that led to MLIR.
Dynamic sequence lengths would lead to two recompilations at most with Inductor (I think); it's a one-time cost that shouldn't impact benchmarking. Programmers would ideally try out torch.compile before resorting to developing/using kernels; the cost of trying out torch.compile is nearly zero if it's known which parts to compile if applied to specific parts. So it'd be valuable/interesting to see the gap b/w torch.compile (Inductor) and kernels here.
Nice thread! For completeness, for the result chart above, do you have the performance bar with torch.compile applied to those same functions that were replaced with kernels? (And also with torch.compile on the whole model ideally with CUDA graphs). Or is "No kernels" already with torch.compile?
Finally, here's the paper on PolyBlocks describing how fully code-generating compilers for AI chips can be built! This is the culmination of multiple years of R&D and engineering. There is now enough reusable infrastructure in our toolkit to quickly build high-performing PyTorch/JAX compilers for new chips, no matter how weird or unique their capabilities are, and without relying on any "kernel" libraries or manual model optimization or porting. The paper isn't exhaustive, but it provides details on the key parts, the design choices, and why they are powerful.
https://t.co/PmJ9RTA8BI
Polymage's PolyBlocks engine enables the rapid development of compilers for new AI chips, extracting close-to-peak performance from hardware, and realizing high-performance AI systems for vision, text, generative AI, and more. Highly promising results here from Polymage's collaboration with @tenstorrent --- showing that the right compiler technology can be a leapfrog advance to the programming ecosystem for new chips!
More details: https://t.co/ncvAP1GO12
Polymage Labs Ties Up with Tenstorrent to Build Compiler for AI Hardware
PolyMage Labs, a deep-tech startup incubated at the Indian Institute of Science (IISc), has entered into a strategic collaboration with US-based Tenstorrent Inc to develop an AI compiler for Tenstorrent's AI accelerators.
The partnership brings together Polymage Labs' compiler expertise and Tenstorrent's AI computing platforms, with the aim of improving software support for advanced AI hardware. Both companies said the collaboration focuses on addressing long-standing challenges in making specialised AI chips easier to program and deploy.
Read more: https://t.co/Op5nYuW9tx
#PolymageLabs #Tenstorrent #AIHardware #AICompilers #DeepTech #ArtificialIntelligence #Semiconductors #TechCollaboration #AIInfrastructure #FutureOfAI #MakeInIndia #GlobalTech #StartupIndia
CC is co-located with HPCA, PPoPP, and CGO. Great opportunity to be in sync with a large area of computer systems spanning high-performance computer architecture, compiler systems, parallel programming, HPC, and code optimization! https://t.co/QGarszEbbg
CC is co-located with HPCA, PPoPP, and CGO. Great opportunity to be in sync with a large area of computer systems spanning high-performance computer architecture, compiler systems, parallel programming, HPC, and code optimization! https://t.co/QGarszEbbg
The ACM SIGPLAN International Conference on Compiler Construction (CC) 2026 is inviting papers in areas capturing modern compiler design/construction, and its adjacent areas. For more information: https://t.co/eQj0y6lGMh
CC 2026 will be held in Sydney, Australia, 31-Jan, 1-Feb.
With constant improvements in its optimization passes, PolyBlocks-generated code continues to get better! We compare here against all other state-of-the-art production PyTorch backends on a variety of workloads, including transformer-based and convolution-based ones. The latest round of improvements comes from more/better unroll-and-jam, more fusion across operators, simplifying away invariant computation, and wider use of on-chip memory.
The impact of such compiler technology would be even greater for new hardware that doesn't yet have a well-established library/programming ecosystem.
More info: https://t.co/NeOmZHpbMj
Programming and compiling for AI hardware happen today through multiple approaches, but they broadly fall into low-level, mid-level, and high-level ones. (1) Low-level is based on hand-written kernels (CUDA, CUTLASS, assembly/PTX, similar) on which the default execution engines of AI frameworks (eager-mode) are built; (2) mid-level is mostly OpenAI Triton, Pallas, and cuTile (announced); and (3) high-level ones, which are compilers for PyTorch/JAX/TF functions, e.g. Inductor, XLA, and PolyBlocks. One would stop building low-level libraries/kernels if mid-level ones (e.g. Triton) delivered good/comparable performance; similarly, one would stop relying on hand-written mid-level if high-level compilers delivered comparable performance. Results here compare the high-level fully automatic approach of PyTorch-PolyBlocks against OpenAI Triton and against lower-level kernels (CuBLAS) on an NVIDIA GPU.
While Inductor is an automatic compiler, it still relies on a combination of low-level (e.g. cublas/cutlass kernels) and mid-level frameworks (Triton); for matmul, perhaps exclusively cublas/cutlass (so no code generation).
For Triton, the implementation used was from https://t.co/LKRWAmgsV4
Results here show high performance can be achieved with compact/productive programming if compilers are built right!
Know more: https://t.co/NeOmZHpbMj
Among all the reasons you listed in your nice article on this, I think a key one is missing: the company in context building the chip isn't itself building an MLIR-based AI compiler for higher-order programming frameworks (cuTile was after nearly 20 years, and it's still only "low/mid-level" abstraction). By the time new hardware is out and easily available, hand-tuned highly-optimized cu* libraries are already available (written in CUDA, CUTLASS, and perhaps inline PTX and assembly as well), including composed library methods for common things in LLMs. So "outside" compilers would be catching up forever! Things would have been very different had NVIDIA or similar chip companies built an MLIR-based AI compiler (for, say, PyTorch, JAX, etc.) **concurrently** with their investments in CUDA-like programming models.
I don't think "fragmentation", lack of upstream reference implementations, or governance are the real or important reasons. There is enough freedom to innovate in downstream MLIR projects. The technical approach to compilation that could surpass what's done by hand is actually an important one, though.
An interesting article that, besides the details, shows why AI chip vendors need to open programming doors at multiple levels:
1) high-level Python-based programming framework support (e.g. PyTorch, JAX),
2) compiler support for (1) that could be turned off/on (e.g. torch.compile),
3) mid/low-level programming support (e.g., CUDA, CUTLASS, Triton),
4) low-level MLIR dialects that expose their hardware intrinsics/virtual ISA on top of which both "(2) compilers" and "(3) low-level frameworks" rest, and
5) the ability to use inline virtual ISA if really needed (e.g. PTX).
While (5) isn't strictly necessary, major chip vendors are missing big time on (4) and hence setting themselves up for failure on (1) through (3). Innovations like those by DeepSeek would have otherwise either not been possible or been incredibly slower/harder!
NVIDIA has excelled at all of these, either doing it themselves or enabling others (open-source community, academia, or the industry) to build it for their hardware. An important message for all other chip vendors who have non-existent or poor support at several of those five levels, or worse, are debating and pitting one programming approach/level against the other! Instead, get the lower-level building blocks right to enable (1) through (5).
https://t.co/rkf9W92kP4
@akssri0 Their software execution strategy is pretty poor! See this amazingly detailed article from SemiAnalysis that painstakingly describes all the potholes and provides a detailed list of recommendations to AMD leadership on what to fix and how. https://t.co/taTwYQbN6D
An interesting article that, besides the details, shows why AI chip vendors need to open programming doors at multiple levels:
1) high-level Python-based programming framework support (e.g. PyTorch, JAX),
2) compiler support for (1) that could be turned off/on (e.g. torch.compile),
3) mid/low-level programming support (e.g., CUDA, CUTLASS, Triton),
4) low-level MLIR dialects that expose their hardware intrinsics/virtual ISA on top of which both "(2) compilers" and "(3) low-level frameworks" rest, and
5) the ability to use inline virtual ISA if really needed (e.g. PTX).
While (5) isn't strictly necessary, major chip vendors are missing big time on (4) and hence setting themselves up for failure on (1) through (3). Innovations like those by DeepSeek would have otherwise either not been possible or been incredibly slower/harder!
NVIDIA has excelled at all of these, either doing it themselves or enabling others (open-source community, academia, or the industry) to build it for their hardware. An important message for all other chip vendors who have non-existent or poor support at several of those five levels, or worse, are debating and pitting one programming approach/level against the other! Instead, get the lower-level building blocks right to enable (1) through (5).
https://t.co/rkf9W92kP4