Table of Contents
Fetching ...

Code Optimization in FORM

J. Kuipers, T. Ueda, J. A. M. Vermaseren

TL;DR

The paper tackles the challenge of speeding up numerical evaluation of large symbolic expressions by optimizing output code in FORM. It introduces a generic optimization pipeline that combines Monte Carlo tree search for multivariate Horner schemes with classical techniques like common subexpression elimination, greedy optimizations, partial factorization, and recycling of temporaries. Empirical results on physics formulas and large resultants show substantial reductions in operation counts and improved compiled performance, with the caveat that tuning parameters such as $C_p$ and Horner direction is important and problem-dependent. The work demonstrates the viability of generic, domain-agnostic optimization in symbolic computation and outlines avenues for automatic parameter tuning and domain-specific pre-processing in future versions of FORM.

Abstract

We describe the implementation of output code optimization in the open source computer algebra system FORM. This implementation is based on recently discovered techniques of Monte Carlo tree search to find efficient multivariate Horner schemes, in combination with other optimization algorithms, such as common subexpression elimination. For systems for which no specific knowledge is provided it performs significantly better than other methods we could compare with. Because the method has a number of free parameters, we also show some methods by which to tune them to different types of problems.

Code Optimization in FORM

TL;DR

The paper tackles the challenge of speeding up numerical evaluation of large symbolic expressions by optimizing output code in FORM. It introduces a generic optimization pipeline that combines Monte Carlo tree search for multivariate Horner schemes with classical techniques like common subexpression elimination, greedy optimizations, partial factorization, and recycling of temporaries. Empirical results on physics formulas and large resultants show substantial reductions in operation counts and improved compiled performance, with the caveat that tuning parameters such as and Horner direction is important and problem-dependent. The work demonstrates the viability of generic, domain-agnostic optimization in symbolic computation and outlines avenues for automatic parameter tuning and domain-specific pre-processing in future versions of FORM.

Abstract

We describe the implementation of output code optimization in the open source computer algebra system FORM. This implementation is based on recently discovered techniques of Monte Carlo tree search to find efficient multivariate Horner schemes, in combination with other optimization algorithms, such as common subexpression elimination. For systems for which no specific knowledge is provided it performs significantly better than other methods we could compare with. Because the method has a number of free parameters, we also show some methods by which to tune them to different types of problems.

Paper Structure

This paper contains 26 sections, 10 equations, 11 figures, 6 tables.

Figures (11)

  • Figure 1: The traversed part of an MCTS tree in the search for a good Horner scheme.
  • Figure 2: A binary expression tree for the polynomial $w^2y + w^2z + wx + wy + wz$ and the labeling of the nodes after CSE.
  • Figure 3: Two different binary expression trees for representing the polynomial $w^2y + w^2z + wx + wy + wz$. Only in the left one, CSE detects the common subexpression $y+z$.
  • Figure 4: An expression tree of $w^2y + w^2z + wx + wy + wz$ before (left) and after (right) merging operators.
  • Figure 5: Scatter plots for 300, 1000, 3000, 10000 points per MCTS run. Each plot has 4000 runs. The formula optimized is one obtained from a physics program (HEP($\sigma$)) as explained in the text.
  • ...and 6 more figures