arXiv:2609.40159cs.DCSep 2026

Manuscript Offprint

arXiv:2609.40159

Reinforcement Learning-Guided Graph Transformations for SpTRSV Optimization

Buse Yılmaz

Abstract

Sparse triangular solve (SpTRSV) is a fundamental kernel in numerous scientific and engineering applications. However, the data dependencies inherent in sparse triangular matrices significantly limit the available parallelism and make efficient workload distribution challenging. Recent graph transformation techniques address these limitations by modifying the dependency graph of the input matrix to improve parallel execution. Existing graph transformation strategies, however, rely on manually designed heuristics, making their development and adaptation to different optimization objectives challenging. This work proposes a reinforcement learning-guided graph transformation framework for SpTRSV, in which graph transformation is formulated as a sequential decision-making problem and an RL agent learns matrix-dependent transformation policies. Experimental results on real-world sparse matrices demonstrate level reductions of up to 94% and reductions of up to 80% in the coefficient of variation of level costs, while modifying only 1.50% of the rows in the highest case. On average, the RL-guided graph transformation achieves a 23% reduction in the number of levels and a 29% reduction in the coefficient of variation of level costs while rewriting only 0.82% of the matrix rows. Although the heuristic strategies generally achieve more aggressive level reduction (between 31% and 46%), the RL-based approach achieves the largest average reduction in the coefficient of variation of level costs, demonstrating its ability to balance competing graph transformation objectives. The results further show that the learned policies can be transferred to previously unseen matrices through curriculum learning and fine-tuning, while zero-shot experiments provide insights into the limitations of generalizing graph transformation policies across different sparsity patterns.

Keywords: Sparse triangular solve, reinforcement learning, parallel computing, performance optimization, graph transformation

1 Introduction

There are several different approaches to optimize the parallel execution of Sparse Triangular Solve (SpTRSV) in the literature. Block diagonal approaches [1–5] partition the graph while keeping the sparsity pattern fixed and map these partitions to appropriate architectures and SpTRSV approaches. Hence, these methods aim to optimize the execution mapping and its scheduling while the equation rewriting method [6] modifies the sparsity pattern to optimize the schedule itself. Graph transformation strategies [7, 8] leverage this method to apply structure-aware schedule optimization of SpTRSV by transforming the directed acyclic graph (DAG) of a sparse matrix into a more homogeneous and balanced graph by heuristic approaches. These strategies reduce the synchronization depth (critical path of the DAG) and improve workload balance to optimize the parallel execution efficiency of SpTRSV. In this sense, graph transformation as an optimization approach can be considered close to compiler optimizations such as IR transformations or loop transformations rather than classical SpTRSV tuning. Graph transformation problem [6] presents a large combinatorial search space, as every rewriting operation changes the graph structure and consequently affects future rewriting opportunities.

In this work, rather than designing increasingly complex hand-crafted heuristics, we formulate graph transformation as a reinforcement learning problem. The goal is not only to obtain high-quality graph transformations but also to provide a framework for systematically observing how local rewriting decisions affect the global structure of the DAG. This enables the learned policy to serve both as an optimization method and as a tool for analyzing the effectiveness of different graph characteristics and transformation criteria, thereby facilitating the development of future heuristic or learning based strategies.

Using the proposed framework, a reinforcement learning (RL) based graph transformation strategy is developed to optimize SpTRSV. A subtle difference of this RL based strategy from the graph transformation strategies in the literature [7, 8] is providing a structure-aware learning policy rather than relying on the hand-crafted heuristics based on sparsity pattern features. The heuristic-based strategies prescribe the desired graph structure, whereas the RL agent learns a sequence of graph transformations that maximizes a long-term objective. Therefore, two approaches are optimizing at different levels of abstraction.

Our contributions are summarized below:

  • We develop an extensible reinforcement learning environment that serves as an automated heuristic discovery framework for graph transformation, enabling systematic evaluation of both learned policies and heuristic-based strategies.

  • We propose a novel graph transformation strategy for SpTRSV by formulating graph transformation as a reinforcement learning problem, replacing manually designed transformation rules with a learned policy.

  • We demonstrate that reinforcement learning can effectively learn graph transformation policies that optimize multiple competing objectives, reducing the need for manual heuristic engineering.

  • We design a multi-objective reward function balancing critical-path reduction, level workload balance, rewriting cost and transformation progress.

  • We evaluate the learned transformation policies on real-world sparse matrices and demonstrate level reductions of up to 94% and up to 80% reduction in the coefficient of variation of level workloads, while requiring graph modifications to only a small fraction of the rows which goes as high as 1.58%. The results demonstrate RL-based graph transformation's ability to balance competing graph transformation objectives. On average, the RL-guided graph transformation achieves a 23% reduction in the number of levels and a 29% reduction in the coefficient of variation of level costs while rewriting only 0.82% of the matrix rows. The heuristic-based strategies [7] achieve average level reduction between 31% and 46% and 19% to 22% reduction in the coefficient of variation while rewriting a percentage of rows between 0.33% and 0.81%.

The organization of the paper is as follows: Section 2 provides the fundamentals of SpTRSV, equation rewriting method and reinforcement learning, Section 3 introduces the problem definition, Section 4 explains the reinforcement learning based graph transformation framework in detail, Section 5 presents the experiment results and Section 6 concludes while introducing the future work and the last section presents the literature work.

References (39)