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.
Figures & tables
Figure 1: Graph Transformation Framework Chainbreaker and the relationship between its modules. DG: dependency graph.
Level-specific features
Global features
Computational cost of each level
Current and reference CV of level costs
Number of nodes in each level
Current and reference CV of level node counts
Source level affinity values
Level count
Target level affinity values
Rewrite ratio
Completion ratio of each level
Thin levels completion ratio
Thin levels
Critical path ratio
Table 1: Global information about the current graph state and local information describing individual levels.
Matrix Name
Kind
# of rows
# of NNZ (L)
# of levels
bcsstk17
Structural Prob.
10,974
219,812
1,332
bcsstk37
Structural Prob.
25,503
58,324
5,030
cfd2
Comp. Fluid Dynamics Prob.
123,440
2,605,669
4,357
gearbox
Structural Prob.
153,746
4,617,075
4,586
lung2
Comp. Fluid Dynamics Prob.
109,460
273,647
479
PR02R
Comp. Fluid Dynamics Prob.
161,070
4,174,236
2,838
Table 2: Matrices from SuiteSparse Matrix Collection Davis and Hu (2011) that are used in experiments. The number of nonzeros (# of NNZ) are for the lower triangular part of the matrix (L).
Individual Model
explained var.
explained var.
approx_kl
entropy_loss
entropy_loss
(avg.)
(max.)
(avg.)
(min.)
(avg.)
lung2
0.127
0.432
0.007
-3.890
-3.467
bcsstk17
0.167
0.470
0.015
-6.610
-5.574
torso2
-8.169E-05
1.980E-04
0.002
-5.820
-5.090
Curriculum Model
Table 3: PPO learning behavior for individually trained models, curriculum model trained using lung2, bcsstk17 and torso2, and fine-tuned models that use the curriculum model.
initial
lung2
bcsstk17
torso2
num. of levels
479
1,332
513
ALC
914
321
2014
ARL
228.518
8.23874
226.057
AIR
1.49997
19.0303
3.95588
CV of level cost
6.72
0.83
0.82
RL transformation
lung2
bcsstk17
torso2
Table 4: Graph transformation results for training results for individual training, transfer learning and individual inference results.
initial
cfd2
gearbox
venkat01
PR02R
bcsstk37
num. of levels
4,357
4,586
4,176
2,838
5,030
ALC
708
1,979
411
2,884
226
ARL
28.33
33.53
14.95
56.75
5.07
AIR
12.01
29.03
13.26
24.92
21.87
CV of level costs
0.57
0.88
0.46
0.37
0.76
RL transformation
cfd2
gearbox
venkat01
PR02R
bcsstk37
Table 5: Graph transformation results for training results using transfer learning and inference results for transfer learning and zero-shot experiments.
Individual Model Inference
lung2
bcsstk17
torso2
avg. reward
1.115
0.043
-1.076
cv level cost
1.3684
0.2833
0.4647
levels
30
1015
420
thin level ratio
0.3
0.018
0.319
move count
2502
2619
6144
Table 6: Inference behavior for individually trained models, the curriculum model and zero-shot learning
Reduction in num. of levels
matrix
num. of levels
three Criteria
3CRI_ THICKENED
3CRI_ AGGRESSIVE
2CRI
RLTrans
bcsstk17
1332
16%
27%
33%
48%
24%
bcsstk37
5030
14%
30%
46%
53%
24%
cfd2
4357
10%
17%
19%
33%
3%
gearbox
4586
21%
37%
38%
45%
16%
lung2
479
46%
90%
90%
90%
94%
Table 7: Comparison of RL-based graph transformation strategy (named RLTrans) with heuristic-based graph transformation strategies from Yılmaz (2026) , namely threeCriteria, 3CRI_THICKENED, 3CRI_AGGRESSIVE and 2CRI.
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 2: Level costs before and after RL graph transformation.
Figure 3: Level costs before and after RL graph transformation.