Compiler optimization methods and systems via large language model reasoning for efficient model serving
By integrating LLMs with MCTS for compiler optimizations, the approach addresses the inefficiencies in neural workload transformations, achieving faster and more efficient compiler optimizations for machine learning model serving.
Patent Information
- Application Number
- PCT/US2026/029793
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-05-23
- Filing Date
- 2026-05-26
- Publication Date
- 2026-11-26
AI Technical Summary
Existing compilers struggle with neural workloads due to the exponentially large and interdependent space of possible transformations, leading to inefficiencies in compiler optimizations, particularly in machine learning model serving, which is crucial for real-time applications and high-throughput workloads.
Integrating large language models (LLMs) with Monte Carlo tree search (MCTS) to guide compiler optimizations, leveraging contextual reasoning to propose transformations that are aware of the current program state and historical performance, thus improving sample efficiency.
The LLM-guided MCTS approach achieves significant performance gains with fewer samples compared to traditional methods, demonstrating improved sample efficiency and faster convergence to optimized code.
Smart Images

Figure US2026029793_26112026_PF_FP_ABST
Abstract
Description
International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTCOMPILER OPTIMIZATION METHODS AND SYSTEMS VIA LARGE LANGUAGE MODEL REASONING FOR EFFICIENT MODEL SERVINGCROSS-REFERENCE TO RELATED APPLICATION
[0001] This patent document claims priority to and benefits of U.S. Patent Application No. 63 / 811.190, entitled “REASONING COMPILER SYSTEM” and filed on May 23. 2025. The entire content of the before-mentioned patent application is incorporated by reference as part of the disclosure of this patent document.STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH
[0002] This invention was made with government support under CCF2107598 awarded by the National Science Foundation. The U.S. government has certain rights in the invention.TECHNICAL FIELD
[0003] The present disclosure relates to machine learning, and more particularly to compiler optimization for machine learning models.BACKGROUND
[0004] Machine learning models have become increasingly prevalent across a wide range of applications, including natural language processing, computer vision, speech recognition, recommendation systems, autonomous systems, and scientific computing. The proliferation of machine learning models across consumer products, enterprise software, cloud-based services, and embedded systems has made the performance characteristics of these models a matter of significant practical importance. As machine learning models have grown in capability, they have also grown substantially in complexity and size. Contemporary models routinely comprise billions or even hundreds of billions of parameters, employ deep architectures with many layers, and rely on computationally intensive operations such as large matrix multiplications, multi-head attention mechanisms, convolutional operations, and mixture-of-expert routing. The arithmetic intensity, memory footprint, and data-movement requirements associated with executing such models on modern hardware are correspondingly large, and the computational demands for serving these models efficiently have escalated accordingly. These demands manifest not only in raw compute requirements but also in memory bandwidth utilization, cache behavior, inter-International Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCTdevice communication, and energy consumption, each of which can become a bottleneck depending on the workload and the underlying hardware platform.
[0005] Efficient serving of machine learning models is crucial for a number of practical reasons. Real-time and interactive applications — such as conversational interfaces, on-device inference, low-latency search and recommendation, and safety-critical control systems — impose strict latency requirements that cannot be met without careful optimization of the underlying computations. High-throughput batch workloads, in turn, require efficient utilization of available hardware in order to meet service-level objectives at reasonable cost. The operational cost of serving large machine learning models at scale can be substantial, encompassing hardware acquisition and amortization, electrical power, cooling, data-center footprint, and ongoing maintenance, and even modest improvements in serving efficiency can translate into significant cost savings when aggregated across large deployments.SUMMARY
[0006] While model serving has unlocked unprecedented capabilities, the high cost of serving large-scale models continues to be a significant barrier to widespread accessibility and rapid innovation. Compiler optimizations have long driven substantial performance improvements, but existing compilers struggle with neural workloads due to the exponentially large and highly interdependent space of possible transformations. Although existing stochastic search techniques can be effective, they are often sample-inefficient and fail to leverage the structural context underlying compilation decisions. The described embodiments provide implementations where reasoning with large language models (LLMs), without any retraining, leverages the context-aware decision space of compiler optimizations to significantly improve sample efficiency. To that end, the Reasoning Compiler formulates optimization as a sequential, context-aware decision process guided by a large language model and structured Monte Carlo tree search (MCTS). The LLM acts as a proposal mechanism, suggesting hardware-informed transformations that reflect the current program state and accumulated performance feedback. MCTS incorporates the LLM-generated proposals to balance exploration and exploitation, facilitating a structured, context-sensitive traversal of the expansive compiler optimization space. By achieving substantial speedups with markedly fewer samples than leading neural compilers,International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTour approach demonstrates the potential of LLM-guided reasoning to transform the landscape of compiler optimization.
[0007] Different from existing approaches, integrating LLM-based reasoning with MCTS enables contextual and history-aware transformation planning, as opposed to traditional blackbox search techniques or manually crafted heuristics. The LLM is not retrained for this purpose; rather, it is used as a plug-in reasoning engine. The disclosed technology achieves significant performance gains while requiring far fewer samples than traditional evolutionary algorithms.
[0008] In an example aspect, the disclosed technology performs one or more of the following operations. Compiler optimization is modeled as a Markov decision process (MDP). Monte Carlo tree search (MCTS) is used to explore sequences of valid program transformations. At each step, a large language model (LLM) is prompted with contextual data, including the source code, cost information, and transformation history. The LLM then proposes the next set of transformations using chain-of-thought (CoT) reasoning. These transformations are subsequently validated, applied to the program, and evaluated using a cost model. The process proceeds iteratively until an optimized version of the program is obtained. The described LLM-guided MCTS method achieves up to a 2.5x speedup over unoptimized code using only 36 samples, whereas evolutionary search techniques may take up to 16 times more samples to achieve comparable performance improvements. Ablation studies further indicate that stronger LLMs and the inclusion of deeper historical context contribute to improved sample efficiency and higher-quality optimization results.
[0009] In another example aspect, the disclosed technology may be integrated with Apache TVM, an open-source machine learning compiler stack. Herein, examples of applications include machine learning infrastructure for serving large models, cloud-based machine learning optimization services, and deployment on embedded and edge Al devices that need efficient inference. The described embodiments can function like a smart assistant for compilers. It helps speed up machine learning programs by choosing a best way to rewrite the code. It uses an Al to understand the code and suggest improvements, then checks which one(s) actually make the program run faster. This helps save time, money, and electricity when deploying Al models.
[0010] In yet another example aspect, a method for improving a configuration of a compiler is disclosed. The method comprises receiving an input program representing a computational workload, and applying, to the input program, at least one transformation selected from a set ofInternational Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCTvalid transformations to generate a current program corresponding to a node of a search tree, wherein the at least one transformation is determined based on estimated costs of the current program. The method further includes using a large language model to generate a candidate transformation sequence for the current program in response to a prompt that is based on the estimated costs and the set of valid transformations, generating a new program variant based on applying the candidate transformation sequence to the current program, generating an updated search tree by adding a new node corresponding to the new program variant to the search tree, and generating an output program based on performing a sequential decision process over the updated search tree.
[0011] In yet another example aspect, a method for improving a performance of a program is disclosed. The method comprises receiving an input program representing a computational workload. Herein, the input program corresponds to an input state in a plurality of states, and the plurality of states is associated with search policy over a set of valid transformations. The method further includes selecting, based on estimated performances corresponding to at least one of the plurality of states, at least one transformation from the set of valid transformations, generating, based on applying the at least one transformation to the input program, a current state corresponding to a current program, and using at least one large language model (LLM) to generate a candidate transformation sequence for the current program in response to a prompt that is based on the estimated performances and the search policy over the set of valid transformations. The method finally includes generating an updated plurality of states by adding a new state corresponding to a new program variant to the plurality of states, and generating, based on the updated plurality of states, an output program. In this example method, the new program variant is generated based on applying the candidate transformation sequence to the current program.
[0012] In yet another example aspect, an apparatus comprising a memory and a processor that implements the above-described methods is disclosed.
[0013] In yet another example aspect, the above-described methods may be embodied as processor-executable code and may be stored on a non-transitory computer-readable program medium.
[0014] The above and other aspects and features of the disclosed technology are described in greater detail in the drawings, the description, and the claims.International Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCTBRIEF DESCRIPTION OF DRAWINGS
[0015] FIG. 1 illustrates a schematic diagram of a workflow for optimizing a computer program using a large language model (LLM) guided tree search.
[0016] FIG. 2A illustrates an example of code to be optimized.
[0017] FIG. 2B illustrates an example of an LLM prompt for optimizing the code in FIG. 2A.
[0018] FIG. 2C illustrates an example of an LLM response to the LLM prompt in FIG. 2B.
[0019] FIG. 3A is a schematic diagram of an expansion stage of a Monte Carlo tree search.
[0020] FIG. 3B illustrates a schematic diagram of a simulation (or rollout) stage of the Monte Carlo tree search of FIG. 3A.
[0021] FIG. 3C illustrates a schematic diagram of a backpropagation stage of the Monte Carlo tree search of FIGS. 3 A and 3B.
[0022] FIG. 4 illustrates plots of relative speedup over a pre-optimized program as a function of evaluated transformation proposals.
[0023] FIG. 5 is a table summarizing, for each of a plurality of computational kernels, the relative speedup of FIG. 4 as a function of the number of evaluated transformation proposals.
[0024] FIG. 6 illustrates a table summarizing layer-wise sample efficiency of the disclosed LLM-guided tree search relative to an evolutionary search baseline, across a plurality of computational kernels and hardware platforms.
[0025] FIG. 7 illustrates a table summarizing end-to-end sample efficiency of the disclosed LLM-guided tree search relative to an evolutionary search baseline, evaluated on an end-to-end large language model workload across a plurality of hardware platforms.
[0026] FIG. 8A illustrates a plot of relative speedup as a function of evaluated transformation proposals for a plurality of candidate LLMs used as a proposal engine, evaluated on a selfattention layer.
[0027] FIG. 8B illustrates a plot of relative speedup as a function of evaluated transformation proposals for a plurality of historical-context depths used in the LLM prompt, evaluated on the self-attention layer of FIG. 8A.
[0028] FIG. 9 is a table summarizing, for each of a plurality of computational kernels, relative speedup as a function of evaluated transformation proposals for the candidate LLMs of FIG. 8A.
[0029] FIG. 10 illustrates a table summarizing relative speedup as a function of evaluated transformation proposals for a plurality of historical-context depths.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT
[0030] FIG. 11 illustrates a table summarizing relative speedup as a function of evaluated transformation proposals for a plurality of Monte Carlo tree search branching factors.
[0031] FIG. 12 illustrates a table summarizing the cost of different LLM APIs per entire experiment across layer-wise and end-to-end benchmarks.
[0032] FIG. 13 illustrates a table summarizing, for each of a plurality of candidate LLMs used as a proposal engine, a fallback rate corresponding to a fraction of tree-search expansions in which all LLM-proposed transformation sequences are determined to be invalid.
[0033] FIG. 14 is a flowchart of an example method for improving a compiler configuration.
[0034] FIG. 15 is a flowchart of an example method of improving program performance.DETAILED DESCRIPTION
[0035] Methods, systems, and devices for compiler optimization via large language model (LLM) reasoning for efficient model serving are described. Section headings are used in the present document to improve readability of the description and do not in any way limit the discussion or the embodiments (and / or implementations) to the respective sections only.
[0036] 1 Introduction
[0037] The rise of model serving for LLMs, diffusion models, and other neural models has enabled a new class of intelligent systems, driving transformative applications in healthcare, education, and scientific discovery. These models incur significant computational demands during inference, which proportionally translate into substantial monetary costs. Driving down the cost of model serving is critical, not merely to broaden access and democratize inference, but to catalyze faster cycles of innovation in model design and deployment. Achieving this goal demands reducing inference runtime on computational infrastructure, resources that are not only expensive but also increasingly limited in availability. Compiler optimizations are a critical enabler, not only for cost-efficient inferencing across diverse applications but also for empowering rapid research iteration.
[0038] Existing compilers struggle with neural models due to the exponentially large space of valid program transformations (e.g., tiling, fusion, and layout changes). Each decision, such as selecting a tiling factor or a parallelization strategy, introduces dependencies and constraints that influence the feasibility and performance benefits of subsequent transformations. Rule-based optimizations also often rely on hand-tuned heuristics that can overfit to a specific workload orInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCThardware target. While existing methods have shown promise in discovering performant configurations, they are fundamentally sample-inefficient. They overlook synergistic transformations that emerge only when decisions are made with contextual awareness. These techniques also often explore redundant subspaces or invalid configurations.
[0039] In contrast, we set out to investigate the research question of whether reasoning with large language models (LLMs), without any retraining, can leverage the context-aware decision space of compiler optimizations to significantly improve sample efficiency. To that end. we introduce a novel compilation framework that couples LLM reasoning with Monte Carlo tree search (MCTS) to guide compiler optimization. Hence, in our approach, compiler optimization is cast as a sequential decision-making process, in which each transformation, such as tiling, fusion, or vectorization, is selected with awareness of the current program state, while also assimilating downstream information and propagating its implications upstream to guide future decisions. Our approach avoids the prohibitive cost of fine-tuning LLMs as compilation policies, nor does it require additional training or task- specific adaptation. In this formulation, the LLM evaluates partial transformation sequences and proposes contextually appropriate next steps, drawing upon hardware-informed cost models and the historical trajectory of optimization decisions to inform its proposal. The LLM serves as a context-aware proposal engine: given the current schedule and its observed performance, it generates candidate transformations that are likely to be effective in the context of the traversed trajectory. These LLM-guided reasoning choices are integrated into an MCTS framework that provides a structured mechanism for balancing exploration and exploitation by evaluating LLM-suggested transformations, expanding promising branches, and leveraging rollout feedback to adaptively steer the search toward high-performing regions of the exponentially large optimization space.
[0040] This integration of LLM-based chain-of-thought (CoT) guidance with tree search combines contextual reasoning and adaptability with principled, structured decision-making, enabling the compiler to navigate the complexity of the search space with significantly improved sample efficiency. We evaluate the Reasoning Compiler and compare its improvements and sample efficiency with TVM, which employs evolutionary search. Results show that the Reasoning Compiler consistently achieves significantly higher speedups than what TVM achieves using significantly fewer samples. On five representative benchmarks (Llama-3-8B Attention Layer, DeepSeek-Rl MoE Layer, FLUX Attention Layer, FLUX Convolution Layer,International Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCTand Llama-4-Scout MLP Layer) and across five hardware platforms (Amazon Graviton2, AMD EPYC 7R13. Apple M2 Pro, Intel Core i9. and Intel Xeon E3), the Reasoning Compiler achieves 5.0 x average speedup using 5.8 x fewer samples, resulting in an average of 10.8 x improvement over TVM in sample efficiency. For the end-to-end Llama-3-8B benchmark across five hardware platforms, the Reasoning Compiler uses 3.9 x fewer samples to achieve a 4.0 x speedup, yielding a 5.6 x sample efficiency improvement. These results underscore the promise of LLM-guided reasoning in neural compilation for efficient and scalable model serving.
[0041] 2 Example Embodiments of LLM-Guided ReasoningSopt. = argmax f((k' o ... o0;)(Po))S'£O*,|S'|<T
[0042] We consider the problem of optimizing an input program p0E P representing a layer from a neural network for some objective function f P ■-> R > 0. This objective function represents an evaluation of the program on the target platform for some figure of merit (e.g., latency, power, utilization). Any program p E P can be transformed through the application of some transformation / optimization (used interchangeably from here on out) o E O, where each optimization is a function o: P P that performs a targeted transformation to the program, thus introducing a new variant of the program that is semantically equivalent to the original program but may perform better or worse on a target hardware platform. In this way, successive application of transformations to a program can yield significant performance differences from the original. Therefore, given some maximum transformation sequence length T, the goal is to find a sequence of transformations Sopt= (oj, o2, ... , on) such that n < T and f(pop[) — max f((ok' o ° Oi)(Po)) where popt. = (on° on-1o o oJCPo) and O* is the Kleene s'£o*,|s'|<rstar of O. Herein, the Kleene star operator, denoted with an asterisk (*), represents the set of all finite-length sequences, including the empty sequence, formed from elements of a given set. These constraints collectively define the optimization objective given in Equation (1).
[0043] To facilitate an efficient search over the space of valid program transformation sequences, we cast the optimization problem as a finite-horizon Markov decision process (MDP) defined by the tuple M = (S,A,P,R). This formulation provides a structured approach for sequential decisionmaking in the transformation space, allowing the search process to account for how individual transformations compound over time to affect final program performance.International Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCTCompared to unstructured methods such as exhaustive or purely stochastic search, which often require a large number of expensive program evaluations, casting the problem as an MDP enables more deliberate exploration, offering the potential for improved sample efficiency. Each state stE S corresponds to a program ptE P obtained by applying a sequence of transformations to the original program p0, i.e., st= pt= oto ... o o1)(p0). An action atE A corresponds to selecting a transformation o E 0 to apply at step t, transitioning the current program to a new variant. Since the application of a transformation is deterministic, the transition function P(st+1| st, at~) is 1 if st+1= at(st)and 0 otherwise. The reward function is defined as the objective value caused by the optimization sequence, i.e., R(st, at~) — s ■ f(at(pt) where s E {+1, —1} is chosen so that larger rewards are always better.
[0044] By formulating the problem as an MDP, we enable the use of planning algorithms such as Monte Carlo tree search (MCTS) to explore program transformation sequences. Under standard assumptions, such as finite branching, bounded rewards, and a tree policy (e.g., UCT) that guarantees persistent exploration, MCTS is consistent on finite-horizon problems: as the number of simulations tends to infinity, it converges (with probability 1) to the optimal root action / sequence Soptthat maximizes the objective. With any finite simulation budget, it returns a high-quality but approximate solution. Consequently, our framework (see §3) yields a sequence Sptthat approximately maximizes the objective in practice while enjoying asymptotic optimality in theory.
[0045] 3 Examples of Integrating LLM-Guided Reasoning with MCTS
[0046] We present the Reasoning Compiler, a novel compilation framework that unifies the structured exploration capabilities of Monte Carlo tree search (MCTS) with the contextual, history-aware reasoning of large language models (LLMs). While MCTS provides a principled approach to exploring sequences of program transformations, compiler optimization introduces a unique challenge: the successive application of transformations can exhibit complex, non-local interactions that are difficult to capture through purely stochastic or myopic policies. To address this, we employ an LLM to model program transformation context, tracking which transformations have been applied, how they impact performance, and what directions remain promising. This contextualization is essential to enabling effective and sample-efficient search in compiler optimization.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT
[0047] Optimization interactions are complex, making efficient search challenging. Unlike tasks where actions are relatively independent, program transformations compose in subtle and complex ways. For example, the profitability of applying loop tiling may depend on the prior application of loop fusion or unrolling. Additionally, transformations can introduce new, unforeseen opportunities / constraints for future transformations. These dependencies make the space of valid and useful transformation sequences both combinatorial and deeply contextual.
[0048] While black-box methods such as evolutionary search and some implementations of reinforcement learning have achieved notable success in compiler autotuning, they often do not explicitly model the nuanced structural and temporal dependencies between transformations. This can limit their ability to generalize across contexts, as optimization efficacy depends on transformation histories. Even when guided by local reward signals, they may struggle to capture the interplay between past decisions and future opportunities, limiting their effectiveness in deeply contextual optimization landscapes. Our insight is that efficient search in this space benefits from an agent that reasons over transformation history, structural code changes, and observed performance dynamics to choose the next step.
[0049] 3.1 LLM-Guided Contextual Reasoning for Program Transformation
[0050] Contextual reasoning via LLMs. To address these challenges, the Reasoning Compiler leverages a large language model (LLM) as a contextual reasoning engine. The LLM is tasked with synthesizing program transformations that are not only syntactically valid but also informed by the program's full history and structure. By prompting the LLM with a rich, structured representation of the current optimization state, we enable it to reason over the cumulative effects of prior transformations, analyze performance trends, and identify differential improvements over prior programs.
[0051] FIG. 1 illustrates the optimization workflow. From the root program, the Reasoning Compiler traverses the tree by computing the UCT score, selecting a promising leaf node (i.e., program) for expansion by balancing exploitation of high-reward paths and exploration of under-sampled branches based on visit statistics and empirical mean rewards (see §3.2).
[0052] Prompt construction. At each expansion step in the search, the LLM receives a prompt that includes the source code and predicted performance for the current program pt, its parent Pi-i, and its grandparent Pi-2. It also includes the ordered sequences of transformations that were applied to reach each of these program variants, denoted St, Si-1. and Sj_2. Finally, the fullInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTset of available transformation operations 0 is included. Given this context, the LLM is explicitly instructed to: (1) analyze the differences between program variants and their associated performance scores, identifying which transformations contributed to observed performance changes; (2) reason about potential interactions between previously applied and candidate future transformations, including both synergistic and antagonistic effects; (3) synthesize a new sequence of transformations that is justified in the context of the current program structure and transformation history; and (4) provide a rationale for the proposed sequence, referencing specific code features and transformation interactions. This structured prompt is designed to elicit chain-of-thought (CoT) reasoning, encouraging the LLM to perform deep, multi-step analysis and move beyond surface-level edits, instead generating proposals that are both semantically meaningful and tailored to the evolving optimization trajectory.
[0053] Transformation proposal and validation. The LLM proposes a candidate transformation oi+1G O in the form of a string. Given the generative nature of the LLM, the output may include an invalid or unrecognized transformation even though it is guided by a predefined set of valid transformations. To ensure correctness, the output string is first parsed and filtered to retain only a transformation that matches known valid names and transformation parameters. If no valid transformation is found, the Reasoning Compiler samples a random transformation from the valid set. The successfully validated and applied transformation yields a new program variant Pi+1, with its transformation history updated as Sj+1= SL® where ® denotes sequence concatenation. This new program variant is scored using a hardware cost model and used to update the MCTS tree (see §3.2).
[0054] For the LLM-guided MCTS framework shown in FIG. 1, an example of code to be optimized in shown in FIG. 2A. The LLM prompt used to optimize the code is shown in FIG. 2B and the LLM response is shown in FIG. 2C.
[0055] It is important to emphasize that the LLM is not the centerpiece of our contribution, but a necessary enabler of effective search in this domain. Compiler optimization poses a uniquely challenging setting due to the non-local, compositional nature of transformation interactions. Traditional black box search or heuristic-guided methods struggle to navigate such spaces efficiently. The Reasoning Compiler uses structured search (via MCTS) with learned contextual reasoning (via LLM + CoT) to overcome these challenges. The result is a sample-efficientInternational Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCToptimization algorithm capable of discovering performant transformation sequences in highdimensional, high-interaction spaces.
[0056] 3.2 Structured Optimization via Monte Carlo Tree Search (MCTS)
[0057] MCTS as a sample-efficient planner. As described in §2, we cast program optimization as a finitehorizon decision process over the space of transformation sequences. Framing the problem as an MDP allows the Reasoning Compiler to consider long-term optimization effects and leverage planning algorithms such as Monte Carlo tree search (MCTS) to explore this space efficiently.
[0058] MCTS operates over a tree T = (V, E) where V = P and E = O such that each node p e P is a program from the state space S and each edge o E O corresponds to a transformation from the action space A. This tree structure naturally supports the reuse of common transformation prefixes and allows the planner to backpropagate value estimates from downstream program variants to upstream decisions. Such reuse is critical in compiler optimization, where transformation sequences exhibit both compounding effects and long-range interactions.
[0059] Selection via UCT. During the selection phase, MCTS traverses T from the root, recursively selecting child programs ptto maximize the UCT (Upper Confidence bounds applied to Trees) criterion:W(Pt)cUCT(PON(Pt) J WD
[0060] In the above, W (pz) is the cumulative reward of Pi,N(pt) is the visit count of node (i.e., program) p and c governs the exploration-exploitation tradeoff.
[0061] LLM-guided expansion. As shown in FIG. 3A, once a promising leaf node pt is selected, an LLM is queried to propose a transformation conditioned on ptand its ancestors (see §3.1). The model generates a candidate transformation oi+1E O, which is applied to ptto produce a new program pi+1= oi+1(pi). This results in a new node pi+1added to T corresponding to the updated program and extended transformation path. To ensure T remains acyclic, if pi+1already exists in the tree, it is not added. By leveraging the LLM's contextual reasoning, the system proposes globally informed transformations that extend beyond myopic heuristics.International Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCT
[0062] Rollout for local reward estimation. As shown in FIG. 3B, once a new node pi+1is added to the tree, the Reasoning Compiler performs a lightweight MCTS rollout to estimate the longterm impact of the transformation sequence that produced it. This is done by sampling a randomized sequence of legal transformations o1, ... , oqand applying them to obtain a terminal program psim= (oq° ••• ° o1)(pi+1). Directly measuring hardware-level performance requires compiling and running on real hardware, which is too expensive for the inner loop of a planning algorithm. Following standard practice in compiler autotuning, the Reasoning Compiler uses a learned, hardwareinformed surrogate f for f that is cheap to evaluate and accelerates search while preserving final quality. We convert this prediction into a rollout reward W(pi+1= s • f(pSim), where s E {+1, —1} is chosen so that larger values indicate better performance (e.g., s = — 1 for latency). This noisy but informative proxy lets MCTS trade off immediate and downstream effects without real-hardware runs.
[0063] Backpropagation. As shown in FIG. 3C, the estimated reward W (pl+1) is then backpropagated to all ancestors along the path to the root according to the update step W (p4) «-W(pA) + W(pz+1) where pAis some ancestor program. The visit counts are also updated according to the update step N (pA) «- N (pA) + 1. These updates refine the empirical estimates that guide future selections.
[0064] 4 Example Evaluation and Simulation Results
[0065] We implement the Reasoning Compiler as an extension to MetaSchedule. The framework introduces three modular components: (1) a prompt generator that serializes the current scheduling state, including the IRModule, transformation trace (i.e., the applied schedule history), and hardware cost model outputs, into structured prompts that capture the textual difference from the base IRModule and reflect the current schedule's performance; (2) an LLM interface that queries an external API (e.g., OpenAI) and parses the LLM's output into candidate transformation sequences: and (3) a tree manager that performs MCTS with selection based on UCT score, expansion using LLM suggested transformations, simulation with a hardware-informed cost model, and backpropagation for tree statistics updates.International Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCT
[0066] 4.1 Methodology
[0067] We evaluate the Reasoning Compiler on five representative computational kernels drawn from production- scale models: (1) a self-attention layer from Llama-3-8B, (2) a mixture-of-experts (MoE) layer from DeepSeek-Rl, (3) a self-attention layer from FLUX (stable diffusion), (4) a convolution layer from FLUX, and (5) an MLP layer from Llama-4- Scout. In addition, we perform an end-to-end evaluation of Llama-3-8B. Compiler optimization is framed as a sequential decision process and guided by MCTS using the Upper Confidence bounds applied to Trees (UCT) criterion with exploration parameter c = V2 and branching factor B = 2 following prior work. During search, the LLM (OpenAI GPT-4o mini) is queried using hierarchical context-specifically, the parent and grandparent schedules and their transformations-to enable informed proposal generation. We compare three optimization strategies: (1) TVM MetaSchedule, which uses Evolutionary Search; (2) MCTS without LLM guidance (MCTS); and (3) the Reasoning Compiler that uses prompt-based proposal generation (LLM-Guided MCTS). All experiments are conducted using Apache TVM v0.20.0. Our experimental environment is a dedicated Intel Core i9 workstation under a fixed software and hardware stack to isolate scheduling effects. This environment covers all five kernels above and is the ablation environment. To show portability and scalability across consumer and datacenter processors, we evaluate each of the five kernels on five hardware platforms: Amazon Graviton2, AMD EPYC 7R13, Apple M2 Pro, Intel Core i9, and Intel Xeon E3. Each experiment is repeated 20 times, and we report the mean performance to ensure statistical stability. Additionally, we leverage OpenAI and HuggingFace model serving APIs to access the respective models. The implementation is open-sourced.
[0068] 4.2 Experimental Results
[0069] We assess the sample efficiency of the Reasoning Compiler by analyzing how code quality evolves with increasing search budget, quantified in terms of evaluated transformation proposals. FIG. 4 presents results across five representative workloads, encompassing both transformer-style attention layers and convolution-heavy architectures. Across all benchmarks, our method achieves competitive or superior code performance with significantly fewer samples than state-of-the-art black-box autotuners such as TVM with Evolutionary Search. These resultsInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTdirectly support the central hypothesis of our work: leveraging LLM-driven, context-aware reasoning enables more efficient and effective exploration of the compiler optimization space.
[0070] FIG. 5 presents the relative speedup of three methods-Evolutionary Search, MCTS, and the Reasoning Compiler-evaluated across the different benchmarks. Speedup is measured as the ratio of execution time for the unoptimized code to that of the optimized code after applying a given number of transformation proposals. The table captures performance as a function of the number of samples explored. Higher values indicate more effective optimization. For instance, the Reasoning Compiler consistently achieves higher speedups with fewer samples, demonstrating superior sample efficiency and faster convergence compared to MCTS and Evolutionary Search
[0071] Rapid convergence in low-sample regimes. A consistent trend across all benchmarks is the rapid ascent of code quality in the initial stages of search. This early-stage performance is critical in practice, as real-world compiler pipelines often operate under strict tuning time budgets. FIG. 4 shows Relative Speedup over Pre-Optimized Code on the y-axis, with the number of evaluated transformation proposals on the x-axis. Speedup is defined as the ratio of the execution time of the unoptimized code to that of the optimized code after tuning. Higher values indicate more efficient and optimized code. For instance, on the Elama-3-8B self-attention layer, the Reasoning Compiler achieves a 7.08 x speedup over the untuned baseline with just 36 samples, whereas TVM with Evolutionary Search requires 72 samples, which is twice the budget to achieve comparable gains. On the Elama-4-Scout MEP layer, the gap is even more pronounced: the Reasoning Compiler achieves 12.7 x speedup at 20 samples, while TVM falls short of this mark even after 3000 samples.
[0072] Quantitative sample efficiency. To formally quantify sample efficiency, we compare the number of samples required by each method to reach target speedups. On the FEUX selfattention layer, the Reasoning Compiler attains a 2 x speedup using only 36 samples, while TVM with Evolutionary Search requires more than 600 samples, a 16 x reduction in tuning cost. On the FLUX convolution layer, the Reasoning Compiler consistently outperforms TVM across nearly all budget levels and reaches TVM's final performance after evaluating just 400 samples.
[0073] Speedup relative to baselines. The Reasoning Compiler not only produces better code, but does so more aggressively and earlier in the search process. For example, on theInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTDeepSeekRl MoE Layer, the Reasoning Compiler achieves a 3.3 x speedup over TVM with Evolutionary Search at 36 samples: on the Llama-4-Scout MLP layer, the Reasoning Compiler achieves a 9.3 x speedup over TVM at 20 samples. This trend, which shows strong initial gains followed by convergence, demonstrates that the Reasoning Compiler quickly identifies high-performing regions of the search space, while TVM's uninformed search requires substantial exploration to reach similar quality.
[0074] Operator-specific trends. We observe that certain operator types, such as matrix multiplication operations extracted from attention layers and MLP layers, exhibit sharper performance improvements. This is likely due to recurring structural patterns such as loop fusion, tiling, and vectorization, which pretrained LLMs can more readily recognize and exploit. Convolutional operators, by contrast, expose a broader and less regular transformation space. Nonetheless, the Reasoning COMPILER consistently matches or exceeds baseline performance with fewer samples, underscoring its effectiveness across diverse operator characteristics.
[0075] Sample efficiency across hardware platforms. As shown in FIG. 6, the Reasoning Compiler demonstrates superior sample efficiency compared to TVM with Evolutionary Search across five hardware platforms on five benchmarks. We define sample efficiency as the speedup achieved per sample ( — - - ). On average, across all 25 platform-operator pairs, theReasoning ComPILER achieves a 5.0 x speedup using 5.8 x fewer samples, resulting in a 10.8 x improvement in sample efficiency. The performance gains are particularly significant for compute-intensive workloads. For instance, for the Llama-3-8B self-attention layer on AMD EPYC 7R13, the Reasoning Compiler achieved a 12.1 x speedup in just 200 samples, while TVM required 1,400 samples to reach a 2.1 x speedup. This represents a 7.0 x sample reduction and a 40.3 x sample efficiency gain. On Intel Core i9, the Reasoning Compiler often matches or exceeds TVM's peak with fewer trials: on the Llama-4-Scout MLP layer, the Reasoning Compiler used 11.5 x fewer samples for a 26.1 x efficiency gain.
[0076] End-to-end sample efficiency. For end-to-end Llama-3-8B across the five hardware platforms in FIG. 7, the Reasoning Compiler's sample efficiency improvement over TVM ranges from 3.2 x on AMD EPYC to 11.8 x on Intel Core i9. End-to-end speedups range from 2.2 x on AMD EPYC to 5.1 x on Amazon Graviton2. The Reasoning Compiler consistently achievesInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTsignificantly higher speedups: using 3.9 x fewer samples, it achieves a 4.0 x speedup and yields a 5.6 x geometric-mean sample efficiency improvement over TVM with Evolutionary Search.
[0077] Implications. These findings reinforce our core thesis: compiler optimization should be cast as a structured decision process, enriched by prior knowledge and contextual reasoning. Our integration of LLMs into Monte Carlo tree search results in a strategically guided and sampleefficient search, particularly valuable in scenarios with constrained tuning budgets. By generating performant code with orders-of-magnitude fewer samples, our framework offers both practical deployment advantages and a compelling alternative to conventional, sample-inefficient compilation pipelines.
[0078] 4.3 Ablation Studies
[0079] 4.3.1 Impact of LLM Choice and Reasoning Strategy
[0080] To better understand the contributions of different components in our approach, we conduct an ablation study focused on the effects of LLM selection and reasoning modality. FIG.8A shows the relative speedup over unoptimized code as a function of the number of schedule samples evaluated by the Reasoning Compiler on the Llama-3-8B self-attention layer using a range of LLM models for API calls. The x -axis indicates the cumulative number of schedules explored, while the y -axis shows the best speedup achieved so far. This setup enables us to directly compare how effectively various LLMs leverage contextual information to guide the search. The general trend of the results supports our central claim: compiler optimization benefits from goal-directed, context-aware reasoning in terms of sample efficiency.
[0081] As a continuation of FIG. 8A, FIG. 9 reports speedup over unoptimized code on the Llama-3-8B self-attention layer as well as three additional benchmarks: DeepSeek-Rl MoE Layer, FLUX Attention Layer, and FLUX Convolution Layer. Each block of the table corresponds to a different benchmark and shows the best speedup achieved by the Reasoning Compiler as a function of the number of schedules sampled using the reasoning model listed in the table. Rows compare different reasoning models used for API call generation, including both proprietary (e.g., GPT-4o mini, OpenAI ol-mini) and open-source models (e.g., Llama3.3-Instruct, DeepSeek-Distill). Across all benchmarks, the results show that more capable models-those that are larger or instruction-tuned-consistently achieve higher speedups with fewer samples. For example, Llama3.3-Instruct (70B) and DeepSeek-Distill (32B) achieve near-maximal speedup within the first 72-150 samples, while smaller models such as DeepSeek-International Patent ApplicationAttorney Docket No.: 009062.8604.WD00; SD2025-370-2PCTDistill (7B) or Llama3.1 -Instruct (8B) reach similar performance more gradually. These results validate the generality of our findings: the use of context-aware LLMs accelerates convergence of the Reasoning COMPILER across diverse code domains. Moreover, the performance of open-source models is competitive with proprietary alternatives, further supporting the accessibility and reproducibility of our method.
[0082] Large instruction-tuned Llama3.3 (70B) achieves exceptional sample efficiency. The instruction-tuned Llama3.3-70B model rapidly attains near-optimal performance, reaching a 9.69 x speedup after only 36 samples, roughly 86% of the GPT-4o mini's maximum speedup but with less than 6% of its sampling budget. This corresponds to an approximately 15 x improvement in sample efficiency. Instruction tuning also significantly improves the ability of LLMs to generate domain-specific, context-aware transformation proposals. The consistent performance advantage of instruction-tuned models over untuned counterparts of comparable size confirms that semantic task alignment, combined with sufficient model capacity, synergistically enhances the effectiveness of sequential context reasoning in guiding compiler optimizations.
[0083] DeepSeek-Rl-Distill-Qwen (32B) excels in long-horizon optimization. The DeepSeek-Rl-Distill-Qwen-32B model, employing a mixture-of-experts (MoE) architecture, exhibits a more gradual improvement, starting with a 7.07 x speedup at 18 samples and reaching 9.98 x after 579 samples. The sparse expert routing inherent in MoE architectures likely facilitates exploration of complex transformation sequences over extended horizons, complementing context-aware reasoning by enabling specialized and conditional decision-making.
[0084] Lower-parameter models also achieve high sample efficiency. Despite their reduced scale, smaller models still produce notable speedups relative to the untuned baseline. For example, Llama3.1 -Instruct ( 8 B ) reaches a 5.87 x speedup, and DeepSeek-Rl-Distill-Qwen ( 7 B ) achieves a 4.86 x speedup at just 36 samples. When compared to the widely used Evolutionary Search strategy, which requires around 72 samples to achieve a 7.0 x speedup and fails to reach comparable performance for tuning the DeepSeek-Rl MoE layer. Even after 3000 samples, these smaller models consistently outperform. The Reasoning Compiler with lower-parameter models achieves at least twice the sample efficiency of TVM with EvolutionaryInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTSearch, making them well-suited for efficient compiler optimization in local or edge deployments.
[0085] Open- source models match proprietary models in performance. Our results demonstrate that open-source LLMs, when adequately scaled and instruction-tuned, match or exceed the performance of proprietary baselines such as GPT-4o mini. This underscores the broad applicability of our approach and its independence from proprietary data or architectures, enabling widespread adoption of context-aware, LLM-guided compiler optimization.
[0086] 4.3.2 Impact of Historical Trace Depth on Optimization Efficiency
[0087] FIG. 8B presents the relative speedup over unoptimized code as a function of the number of schedule samples evaluated by the Reasoning Compiler on the Llama-3-8B selfattention layer. Using a deeper historical trace (see FIG. 1) in the prompt (parent + grandparent + great-grandparent) leads to faster convergence compared to the shallower trace (parent + grandparent). For example, at 36 samples, the deeper trace achieves a speedup of approximately 7.13 x, slightly surpassing the 7.08 x of the shallower trace. However, by 72 samples, the deeper trace saturates at 11.36 x speedup, while the shallower trace reaches only 8.38 x, requiring many more samples (around 579) to approach 11.3 x performance. This demonstrates that including longer historical context enables the LLM to better capture dependencies and synergies in transformation sequences, resulting in more sample-efficient and goal-directed exploration, validating the advantage of context-aware reasoning.As a continuation of FIG. 8B, FIG. 10 presents the data for the ablation study on the depth of historical trace included in the prompt sent to the LLM. Specifically, we compare two configurations: the "Parent + Grandparent" setting, where the prompt contains information from the current node and its two immediate ancestors, and the "Parent + Grandparent + Great-Grandparent" setting, where the prompt additionally includes the great-grandparent node. These variations allow us to assess the impact of deeper context windows on the effectiveness of the Reasoning Compiler.
[0088] Results show that increasing the historical context generally improves sample efficiency across all benchmarks. For example, on DeepSeek-Rl MoE Layer, adding one more ancestral node boosts early performance significantly, achieving a 9.39 x speedup at just 18 samples compared to 6.14 x for the shallower context. Similarly, on Llama-3-8B AttentionInternational Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCTLayer, the extended context leads to a higher final speedup ( 11.87 x vs. 11.33 x ) and earlier convergence. The performance gains, while smaller, are also consistent on FLUX Attention Layer and FLUX Convolution Layer, with improvements observed across all sample budgets. These findings confirm that providing richer historical context enables the LLM to make more informed decisions at each step of the search, ultimately enhancing the sample efficiency of the Reasoning Compiler.
[0089] 4.3.3 Branching-Factor Embodiments
[0090] In some embodiments, to determine the value of MCTS branching factor ( B ), we ablate on B = 2 and B = 4. In FIG. 11 . results show that when branching factor B = 2, the Reasoning Compiler is more sample-efficient than when B = 4. Our choice of B = 2 aligns with prior works. If a higher branching factor is chosen, then there are more possible next steps, which require more sampling effort (i.e.. more simulations) to cover these expanded possibilities at the same level of thoroughness.
[0091] 4.4 Example Costs of LLMs Used in Evaluation and Simulation Results
[0092] In FIG. 12, for each benchmark, we report the API cost of running a full experiment with every LLM used to generate transformation proposals. We run a high number of samples to understand the boundary of performance improvements and allow the algorithm to saturate. For OpenAI, our main results used GPT-4o mini, the lowest-cost model available at submission time. For open-source models, we used Hugging Face APIs through the Nscale hyperscaler provider. Across benchmarks, these open-source models achieved competitive speedups and sample efficiency relative to GPT4o mini, indicating that open- source models are a viable alternative when commercial APIs are impractical. Costs of open-source models could be further reduced by local deployment.
[0093] 4.5 Validity and Fallback Behavior
[0094] LLM-generated transformations can occasionally be syntactically valid but semantically redundant or performance-regressive. During any single MCTS expansion, proposals that fail basic validity checks (e.g., naming or use-context non-compliance) are simply discarded while the remaining valid proposals proceed, and no fallback is triggered. A fallback occurs only when all LLM-generated proposals in that expansion are invalid, in which case the search reverts to the default, non-LLM expansion policy and continues without interruption. InInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTFIG. 13, we report the fallback rate as the average fraction of expansions that trigger this non-LLM path (i.e., expansions in which all LLM proposals are invalid). To prevent downstream harm from poor but valid transformations, the cost model evaluates all proposed transformations before they are added to the tree; proposals with low estimated values are naturally pruned. Because the transformation space is a known, finite set of legal rewrites, most correctness issues reduce to naming compliance and use-context, which modern instruction-tuned LLMs typically handle well. Empirically, commercial models (GPT-4o mini and OpenAI ol-mini) show 0% fallback rates, larger open-source models perform similarly (Llama3.3-Instruct 70B at 0.08% and DeepSeek-Distill 32B at 0.17%), whereas smaller models exhibit higher fallback rates (Llama3.1 -Instruct 8B at 10.50% and DeepSeek-Distill 7B at 17.20%).
[0095] 5 Examples of Existing Implementations for Program Optimization
[0096] Superoptimization. While our high-level goal of discovering highly efficient program variants shares motivation with the superoptimization literature, our formulation and tractability differ substantially. Superoptimization aims to find the globally optimal instruction-level program, typically via enumerative, symbolic, or stochastic search over low-level assembly variants; hybrid and neural approaches have also been explored. STOKE showed that highquality programs often reside in low-probability regions and made the leap to use randomized search (MCMC). Neural compilers followed suit and relied on evolutionary search or simulated annealing algorithms. In contrast, the Reasoning Compiler treats optimization as a planning problem that leverages MCTS to reason contextually about dependencies among transformations over structured intermediate representations.
[0097] ML-Based Autotuning. Autotuning frameworks optimize performance-critical parameters (e.g., loop tile sizes, phase orderings, memory layouts) using a variety of ML-based techniques, including linear models, tree-based methods. Bayesian networks, evolutionary algorithms, clustering, and reinforcement learning. The Reasoning Compiler shares the same goal of performance-driven parameter selection, but distinguishes itself by combining LLM-based contextual reasoning with structured search (via MCTS) to explore transformation sequences in a history- and structure-aware manner.
[0098] Techniques for Neural Compilation. A large body of work targets the optimization of neural network inference pipelines, spanning graph-level transformations and scheduling and lowlevel code generation. Many modern systems incorporate learned components (e.g., costInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTmodels) and search strategies to navigate large configuration spaces; for example, TVM / Ansor and FlexTensor use learned performance models and evolutionary strategies for tuning. While highly effective for tensor-program tuning, these approaches often emphasize local parameter optimization or rely on domain-specific heuristics. The Reasoning Compiler moves beyond these works by introducing LLM-based contextual reasoning over transformation history, structural changes, and performance trends, enabling history- and structure-aware exploration not addressed in prior neural compilation work.
[0099] LLMs for Code Reasoning and Optimization. LLMs have demonstrated capabilities in code generation, fuzzing, bug repair, and even high-level optimization. Recent work has explored the use of LLMs to generate phase orderings or perform disassembly. The Reasoning Compiler advances these approaches by embedding an LLM in a structured decision loop, leveraging it for context-aware reasoning within a grounded search process.
[0100] 6 Select Example Embodiments of the Disclosed Technology
[0101] Compiling neural workloads remains a bottleneck for scalable model serving: traditional compilers struggle with combinatorial transformation spaces, and the state-of-the-art neural compilers rely on stochastic search, lacking sample efficiency and contextual awareness. This paper introduced the Reasoning Compiler, a novel framework that formulates compiler optimization as a sequential, context-aware decision process, pairing LLM-generated proposals with MCTS and performance feedback to reason and navigate through the optimization space efficiently. By enabling LLM reasoning in the compiler optimization process, we achieve a leap from randomized search to informed and guided compilation. Results show that the Reasoning Compiler consistently yields faster runtimes with markedly fewer evaluations without any retraining. These gains directly translate to reduced operational cost of LLM services, lower energy usage per query, improved system responsiveness, more agile model deployment, faster model training, and accelerated innovation cycles, among other benefits. Looking ahead, the same LLM that guides compilation can accelerate its own inferencing, creating a virtuous, selfoptimizing cycle in which sped-up LLMs enable more efficient transformations and progressively better models and services.
[0102] The following solutions may be preferably implemented by the described embodiments.
[0103] SL A method (e.g., method 1400 in FIG. 14) of improving a configuration of a compiler, comprising: receiving (1410) an input program representing a computationalInternational Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCTworkload; applying (1420), to the input program, at least one transformation selected from a set of valid transformations to generate a current program corresponding to a node of a search tree, wherein the at least one transformation is determined based on estimated costs of the current program; using (1430) a large language model to generate a candidate transformation sequence for the current program in response to a prompt that is based on the estimated costs and the set of valid transformations; generating (1440) a new program variant based on applying the candidate transformation sequence to the current program; generating (1450) an updated search tree by adding a new node corresponding to the new program variant to the search tree; and generating (1460) an output program based on performing a sequential decision process over the updated search tree.
[0104] S2. The method of solution SI, wherein a metric associated with evaluating the output program on a target platform is improved compared to evaluating the input program on the target platform, and wherein the metric comprises at least one of a latency, a power, or a utilization associated with the target platform or the compiler.
[0105] S3. The method of solution S2, wherein the target platform comprises a neural processing unit (NPU), and wherein the set of valid transformations comprises one or more of loop tiling, loop fusion, loop unrolling, vectorization, parallelization, or memory layout changes.
[0106] S4. The method of any one of solutions SI to S3, wherein the node corresponding to the current program is selected based on an upper confidence bound that balances an explorationexploitation tradeoff when traversing the search tree.
[0107] S5. The method of solution S4. wherein the upper confidence bound is determined based on the estimated costs, a visit count for the node, and a parameter that controls the exploration-exploitation tradeoff.
[0108] S6. The method of any one of solutions SI to S3, wherein the prompt is further based on the estimated costs for programs corresponding to at least one ancestor node of the node corresponding to the current program.
[0109] S7. The method of solution S6, wherein the at least one ancestor node corresponds to at least one of a parent program or a grandparent program of the current program.
[0110] S8. The method of solution S6. further comprising: backpropagating the estimated costs to each of the at least one ancestor node, thereby updating statistics to enable a selection of a subsequent node.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT
[0111] S9. The method of solution S8, wherein backpropagating the estimated costs comprises: updating a cumulative cost of each of the at least one ancestor node by adding the estimated costs thereto; and incrementing a visit count of each of the at least one ancestor node.
[0112] S10. The method of any one of solutions SI to S3, wherein the large language model generates the candidate transformation sequence using chain-of-thought reasoning that analyzes differences between program variants and their associated costs.
[0113] Sil. The method of any one of solutions SI to S3, further comprising: validating the candidate transformation sequence by parsing and filtering the candidate transformation sequence to retain transformations that match any transformation in the set of valid transformations.
[0114] S12. The method of solution Sil, further comprising: in response to determining that no valid transformations remain after filtering, sampling a random transformation from the set of valid transformations to determine the candidate transformation sequence.
[0115] S13. The method of any one of solutions SI to S3, wherein the large language model is an instruction-tuned language model.
[0116] S14. The method of any one of solutions SI to S3, wherein the input program represents a layer from a neural network, and wherein the layer comprises one of a self-attention layer, a mixture-of-experts layer, or a convolution layer.
[0117] S15. The method of any one of solutions SI to S3, wherein the sequential decision process is formulated as a finite-horizon Markov decision process defined based on states, actions, and a reward function.
[0118] S16. The method of solution S15, wherein each state corresponds to a program variant, wherein each action corresponds to selecting a transformation to apply, and wherein the reward function is configured to evaluate the program variant on a target platform for a metric.
[0119] S17. The method of solution S16, wherein the metric comprises at least one of a latency, a power, or a utilization associated with the target platform or the compiler.
[0120] SI 8. The method of any one of solutions SI to S3, wherein the prompt instructs the large language model to: analyze differences between program variants and their associated costs; reason about interactions between previously applied transformations and candidate future transformations; and provide a rationale for a proposed transformation sequence.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT
[0121] S 19. The method of any one of solutions SI to S3, wherein the estimated costs are determined by evaluating the current program using a cost model comprising a learned hardware- aware cost model trained to approximate hardware performance.
[0122] S20. A method (e.g., method 1500 in FIG. 15) of improving a performance of a program, comprising: receiving (1510) an input program representing a computational workload, wherein the input program corresponds to an input state in a plurality of states, wherein the plurality of states is associated with search policy over a set of valid transformations; selecting (1520), based on estimated performances corresponding to at least one of the plurality of states, at least one transformation from the set of valid transformations; generating (1530), based on applying the at least one transformation to the input program, a current state corresponding to a current program; using (1540) at least one large language model (LLM) to generate a candidate transformation sequence for the current program in response to a prompt that is based on the estimated performances and the search policy over the set of valid transformations; generating (1550) an updated plurality of states by adding a new state corresponding to a new program variant to the plurality of states, wherein the new program variant is generated based on applying the candidate transformation sequence to the current program; and generating (1560), based on the updated plurality of states, an output program.
[0123] S21. The method of solution S20, wherein generating the updated plurality of states is associated with using computing resources that are less than a computing resource budget, wherein the method further comprises: continuing to add, while not exceeding the computing resource budget, additional new states corresponding to additional program variants to the updated plurality of states, wherein adding each additional new state uses additional computing resources; and outputting, when the computing resource budget has been exceeded, the output program corresponding to a output state in the updated plurality of states, wherein an estimated performance of the output program is better than the estimated performance of a program associated with any other state in the updated plurality of states.
[0124] S22. The method of solution S20 or S21, wherein each of the plurality of states is further associated with metadata associated with the at least one LLM.
[0125] S23. The method of any one of solutions S20 to S22, wherein the program comprises database query plans and the set of valid transformations comprises at least one of join reordering, predicate pushdown, index selection, or materialization choices.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT
[0126] S24. The method of any one of solutions S20 to S22, wherein the program comprises a compiler for the program, and wherein the set of valid transformations comprises loop tiling, loop fusion, loop unrolling, vectorization, parallelization, memory layout changes, reduction restructuring, graph-level rewrites, parallelism and distribution, layout and precision transformations, or memory-hierarchy transformations.
[0127] S25. The method of any one of solutions S20 to S22, wherein the program comprises a hardware or Register-Transfer Level (RTL) design, and wherein the set of valid transformations comprises pipelining or design logic simplifications that include transformations for optimizing a power consumption associated with processing the computational workload or transformations for optimizing an area associated with the hardware or RTL design.
[0128] S26. The method of any one of solutions S20 to S22, wherein the program comprises a numerical or symbolic rewriting, and wherein the set of valid transformations comprises polynomial simplification, floating-point expression rewriting, or theorem-proving tactic selection.
[0129] S27. The method of any one of solutions S20 to S22, wherein the program comprises a software refactoring or a program repair, and wherein the set of valid transformations comprises applying a refactoring from a library of refactorings optimized for readability, test coverage, or fault-localization signals.
[0130] S28. The method of any one of solutions S20 to S22, wherein the program comprises a machine-learning (ML) model architecture or a training-pipeline search, and wherein the set of valid transformations comprises Neural Architecture Search (NAS) operators, data-augmentation pipeline rewrites, or hyperparameter rewrites.
[0131] S29. The method of any one of solutions S20 to S22, wherein the program comprises a combinatorial design or an operations research model, and wherein the set of valid transformations comprises route plans, scheduling, layout, or protocol synthesis.
[0132] S30. The method of any of solutions S20 to S29, wherein the search policy is implemented using at least one of a directed acyclic graph (DAG), a general graph with cycles, a Markov chain tree search (MCTS), a table of state values and transformation values, a hierarchical planner, a genetic or evolutionary population, a beam search over transformation sequences, or a best-first search guided by an LLM heuristic.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT
[0133] S31. A system for improving a configuration of a compiler, comprising: at least one processor; and one or more memories coupled to the at least one processor, wherein the at least one processor is configured to implement the method of any one of solutions SI to SI 9.
[0134] S32. A system for improving a performance of a program, comprising: one or more processors; and at least one memory coupled to the one or more processors, wherein the one or more processors is configured to implement the method of any one of solutions S20 to S30.
[0135] S33. A non-transitory computer-readable storage medium having instructions stored thereupon, the instructions being configured to implement the method in solutions SI to S30.
[0136] The following additional solutions may be preferably implemented by some of the described embodiments.
[0137] Pl. A method for compiler optimization of computer program code, comprising: using an artificial intelligence model as a reasoning engine to propose program transformations based on contextual analysis of program state and transformation history; employing tree-based search to navigate a space of transformation sequences, wherein the tree-based search is guided by the artificial intelligence model's proposals; iteratively applying proposed transformations to generate optimized program variants; and evaluating performance of the program variants to guide further optimization decisions.
[0138] P2. The method of solution Pl, wherein the artificial intelligence model comprises a large language model (LLM) that is used as a plug-in reasoning engine without retraining.
[0139] P3. The method of solution Pl, wherein the contextual analysis comprises chain-of-thought reasoning about program transformations.
[0140] P4. The method of solution Pl, wherein: the method comprises: modeling the compiler optimization as a Markov Decision Process; and the employing tree-based search comprises implementing Monte Carlo Tree Search (MCTS) as the tree-based search to explore sequences of valid program transformations within the Markov Decision Process.
[0141] P5. The method of solution Pl, wherein the contextual analysis of program state and transformation history includes program source code, performance estimates, and transformation sequences applied to reach current and prior program variants.
[0142] P6. The method of solution Pl, wherein the computer program code comprises code sequences for neural networks, and wherein the program transformations include operations selected from tiling, fusion, parallelization, and memory layout optimization.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT
[0143] P7. The method of solution Pl, wherein the optimized program variants are configured for deployment in one or more of: ML infrastructure, cloud-based ML optimization, or an embedded and Edge Al device.
[0144] P8. A compiler system for optimizing computer program code, comprising: an artificial intelligence interface configured to function as a reasoning engine for proposing program transformations based on contextual analysis of program state and transformation history; a search module implementing tree-based navigation of transformation sequence spaces, wherein the search module is configured to be guided by the artificial intelligence interface's proposals; a transformation engine configured to apply proposed transformations and generate optimized program variants; and a performance evaluation module configured to assess program variants and provide feedback to guide optimization decisions.
[0145] P9. A system for secure multi-party computation inference on encrypted data in untrusted environments as substantially shown and described herein.
[0146] PIO. A method for secure multi-party computation inference on encrypted data in untrusted environments as substantially shown and described herein.
[0147] 7 Concluding Remarks
[0148] As evinced in the solutions above, it will be appreciated by those of skill in the art that the present document discloses methods and systems that provide various improvements to the field of program optimization, e.g., optimizing compilers for neural network layers. It will be further appreciated that the described embodiments may be used to provide a compilation framework that achieves substantially improved sample efficiency in neural network compiler optimization by leveraging large language model reasoning integrated with Monte Carlo tree search, enabling the discovery of high-performing transformation sequences using significantly fewer evaluated samples — on average 5.8x fewer — than conventional stochastic search methods. By casting compiler optimization as a sequential, context-aware decision process in which the LLM reasons over transformation history, program structure, and accumulated performance feedback, the framework rapidly converges to superior code quality in low- sample regimes, directly translating to reduced operational costs for model serving, lower energy consumption per inference query, and accelerated innovation cycles in model deployment. Additionally, because the framework requires no retraining or task-specific LLM adaptation, it generalizesInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTacross diverse hardware platforms and neural network architectures without additional development overhead. Further improvements are described throughout this patent document.
[0149] Implementations of the subject matter and the functional operations described in this patent document can be implemented in various systems, digital electronic circuitry, or in computer software, firmware, or hardware, including the structures disclosed in this specification and their structural equivalents, or in combinations of one or more of them. Implementations of the subject matter described in this specification can be implemented as one or more computer program products, i.e., one or more modules of computer program instructions encoded on a tangible and non-transitory computer readable medium for execution by, or to control the operation of, data processing apparatus. The computer readable medium can be a machine-readable storage device, a machine-readable storage substrate, a memory device, a composition of matter effecting a machine-read->->able propagated signal, or a combination of one or more of them. The term “data processing unit” or “data processing apparatus” encompasses all apparatus, devices, and machines for processing data, including by way of example a programmable processor, a computer, or multiple processors or computers. The apparatus can include, in addition to hardware, code that creates an execution environment for the computer program in question, e.g., code that constitutes processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of them.
[0150] A computer program (also known as a program, software, software application, script, or code) can be written in any form of programming language, including compiled or interpreted languages, and it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment. A computer program does not necessarily correspond to a file in a file system. A program can be stored in a portion of a file that holds other programs or data (e.g.. one or more scripts stored in a markup language document), in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub programs, or portions of code). A computer program can be deployed to be executed on one computer or on multiple computers that are located at one site or distributed across multiple sites and interconnected by a communication network.
[0151] The processes and logic flows described in this specification can be performed by one or more programmable processors executing one or more computer programs to performInternational Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTfunctions by operating on input data and generating output. The processes and logic flows can also be performed by, and apparatus can also be implemented as, special purpose logic circuitry, e.g., FPGA (field programmable gate array) or ASIC (application specific integrated circuit).
[0152] Processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer. Generally, a processor will receive instructions and data from a read only memory or a random access memory or both. The essential elements of a computer are a processor for performing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto optical disks, or optical disks. However, a computer need not have such devices.Computer readable media suitable for storing computer program instructions and data include all forms of nonvolatile memory, media and memory devices, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices. The processor and the memory can be supplemented by. or incorporated in, special purpose logic circuitry.
[0153] While this patent document contains many specifics, these should not be construed as limitations on the scope of any invention or of what may be claimed, but rather as descriptions of features that may be specific to particular embodiments of particular inventions. Certain features that are described in this patent document in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination. Moreover, although features may be described above as acting in certain combinations and even initially claimed as such, one or more features from a claimed combination can in some cases be excised from the combination, and the claimed combination may be directed to a subcombination or variation of a subcombination.
[0154] Similarly, while operations are depicted in the drawings in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. Moreover, the separation of various system components in the embodiments described in this patent document should not be understood as requiring such separation in all embodiments.International Patent ApplicationAttorney Docket No.: 009062.8604.WO00; SD2025-370-2PCT
[0155] Only a few implementations and examples are described and other implementations, enhancements and variations can be made based on what is described and illustrated in this patent document.
Claims
International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTWHAT IS CLAIMED IS:
1. A method of improving a configuration of a compiler, comprising:receiving an input program representing a computational workload;applying, to the input program, at least one transformation selected from a set of valid transformations to generate a current program corresponding to a node of a search tree, wherein the at least one transformation is determined based on estimated costs of the current program;using a large language model to generate a candidate transformation sequence for the current program in response to a prompt that is based on the estimated costs and the set of valid transformations;generating a new program variant based on applying the candidate transformation sequence to the current program;generating an updated search tree by adding a new node corresponding to the new program variant to the search tree; andgenerating an output program based on performing a sequential decision process over the updated search tree.
2. The method of claim 1, wherein a metric associated with evaluating the output program on a target platform is improved compared to evaluating the input program on the target platform, and wherein the metric comprises at least one of a latency, a power, or a utilization associated with the target platform or the compiler.
3. The method of claim 2, wherein the target platform comprises a neural processing unit (NPU), and wherein the set of valid transformations comprises one or more of loop tiling, loop fusion, loop unrolling, vectorization, parallelization, or memory layout changes.
4. The method of any one of claims 1 to 3, wherein the node corresponding to the current program is selected based on an upper confidence bound that balances an explorationexploitation tradeoff when traversing the search tree.
5. The method of claim 4, wherein the upper confidence bound is determined based on the estimated costs, a visit count for the node, and a parameter that controls the explorationexploitation tradeoff.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT6. The method of any one of claims 1 to 3, wherein the prompt is further based on the estimated costs for programs corresponding to at least one ancestor node of the node corresponding to the current program.
7. The method of claim 6, wherein the at least one ancestor node corresponds to at least one of a parent program or a grandparent program of the current program.
8. The method of claim 6, further comprising:backpropagating the estimated costs to each of the at least one ancestor node, thereby updating statistics to enable a selection of a subsequent node.
9. The method of claim 8, wherein backpropagating the estimated costs comprises:updating a cumulative cost of each of the at least one ancestor node by adding the estimated costs thereto; andincrementing a visit count of each of the at least one ancestor node.
10. The method of any one of claims 1 to 3, wherein the large language model generates the candidate transformation sequence using chain-of-thought reasoning that analyzes differences between program variants and their associated costs.
11. The method of any one of claims 1 to 3, further comprising:validating the candidate transformation sequence by parsing and filtering the candidate transformation sequence to retain transformations that match any transformation in the set of valid transformations.
12. The method of claim 11, further comprising:in response to determining that no valid transformations remain after filtering, sampling a random transformation from the set of valid transformations to determine the candidate transformation sequence.
13. The method of any one of claims 1 to 3, wherein the large language model is an instruction-tuned language model.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT14. The method of any one of claims 1 to 3, wherein the input program represents a layer from a neural network, and wherein the layer comprises one of a self- attention layer, a mixture-of-experts layer, or a convolution layer.
15. The method of any one of claims 1 to 3, wherein the sequential decision process is formulated as a finite-horizon Markov decision process defined based on states, actions, and a reward function.
16. The method of claim 15, wherein each state corresponds to a program variant, wherein each action corresponds to selecting a transformation to apply, and wherein the reward function is configured to evaluate the program variant on a target platform for a metric.
17. The method of claim 16, wherein the metric comprises at least one of a latency, a power, or a utilization associated with the target platform or the compiler.
18. The method of any one of claims 1 to 3, wherein the prompt instructs the large language model to:analyze differences between program variants and their associated costs;reason about interactions between previously applied transformations and candidate future transformations; andprovide a rationale for a proposed transformation sequence.
19. The method of any one of claims 1 to 3, wherein the estimated costs are determined by evaluating the current program using a cost model comprising a learned hardware-aware cost model trained to approximate hardware performance.
20. A method of improving a performance of a program, comprising:receiving an input program representing a computational workload, wherein the input program corresponds to an input state in a plurality of states, wherein the plurality of states is associated with search policy over a set of valid transformations;selecting, based on estimated performances corresponding to at least one of the plurality of states, at least one transformation from the set of valid transformations;International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTgenerating, based on applying the at least one transformation to the input program, a current state corresponding to a current program;using at least one large language model (LLM) to generate a candidate transformation sequence for the current program in response to a prompt that is based on the estimated performances and the search policy over the set of valid transformations;generating an updated plurality of states by adding a new state corresponding to a new program variant to the plurality of states, wherein the new program variant is generated based on applying the candidate transformation sequence to the current program; andgenerating, based on the updated plurality of states, an output program.
21. The method of claim 20, wherein generating the updated plurality of states is associated with using computing resources that are less than a computing resource budget, wherein the method further comprises:continuing to add, while not exceeding the computing resource budget, additional new states corresponding to additional program variants to the updated plurality of states, wherein adding each additional new state uses additional computing resources; andoutputting, when the computing resource budget has been exceeded, the output program corresponding to a output state in the updated plurality of states, wherein an estimated performance of the output program is better than the estimated performance of a program associated with any other state in the updated plurality of states.
22. The method of claim 20 or 21, wherein each of the plurality of states is further associated with metadata associated with the at least one LLM.
23. The method of any one of claims 20 to 22, wherein the program comprises database query plans and the set of valid transformations comprises at least one of join reordering, predicate pushdown, index selection, or materialization choices.
24. The method of any one of claims 20 to 22, wherein the program comprises a compiler for the program, and wherein the set of valid transformations comprises loop tiling, loop fusion, loop unrolling, vectorization, parallelization, memory layout changes, reduction restructuring, graph-International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCTlevel rewrites, parallelism and distribution, layout and precision transformations, or memoryhierarchy transformations.
25. The method of any one of claims 20 to 22, wherein the program comprises a hardware or Register-Transfer Level (RTL) design, and wherein the set of valid transformations comprises pipelining or design logic simplifications that include transformations for optimizing a power consumption associated with processing the computational workload or transformations for optimizing an area associated with the hardware or RTL design.
26. The method of any one of claims 20 to 22, wherein the program comprises a numerical or symbolic rewriting, and wherein the set of valid transformations comprises polynomial simplification, floating-point expression rewriting, or theorem-proving tactic selection.
27. The method of any one of claims 20 to 22, wherein the program comprises a software refactoring or a program repair, and wherein the set of valid transformations comprises applying a refactoring from a library of refactorings optimized for readability, test coverage, or faultlocalization signals.
28. The method of any one of claims 20 to 22, wherein the program comprises a machinelearning (ML) model architecture or a training-pipeline search, and wherein the set of valid transformations comprises Neural Architecture Search (NAS) operators, data-augmentation pipeline rewrites, or hyperparameter rewrites.
29. The method of any one of claims 20 to 22, wherein the program comprises a combinatorial design or an operations research model, and wherein the set of valid transformations comprises route plans, scheduling, layout, or protocol synthesis.
30. The method of any of claims 20 to 29, wherein the search policy is implemented using at least one of a directed acyclic graph (DAG), a general graph with cycles, a Markov chain tree search (MCTS), a table of state values and transformation values, a hierarchical planner, a genetic or evolutionary population, a beam search over transformation sequences, or a best-first search guided by an LLM heuristic.International Patent ApplicationAttorney Docket No.: 009062.8604.WQ00; SD2025-370-2PCT31. A system for improving a configuration of a compiler, comprising:at least one processor; andone or more memories coupled to the at least one processor,wherein the at least one processor is configured to implement the method of any one of claims 1 to 19.
32. A system for improving a performance of a program, comprising;one or more processors; andat least one memory coupled to the one or more processors,wherein the one or more processors is configured to implement the method of any one of claims 20 to 30.
33. A non-transitory computer-readable storage medium having instructions stored thereupon, the instructions being configured to implement the method in claims 1 to 30.
