Code-Aware Cross-Program Transfer Hyperparameter Optimization

Zijia Wang, Xiangyu He, Kehan Chen, Chen Lin, Jinsong Su

Introduction

Hyperparameter optimization (HPO) is a critical yet computationally expensive phase in machine learning and systems tuning. While Bayesian Optimization (BO) is a standard approach, it typically suffers from a "cold-start" problem, requiring numerous evaluations for every new task. Transfer HPO aims to mitigate this by leveraging historical data from previous tasks. However, traditional methods often overlook the program's source code, relying instead on dataset meta-features or performance similarities. This paper introduces CaTHPO, a framework that incorporates code-awareness to enhance cross-program transfer by "reading" the logic of the application being tuned.

Methodology: The CaTHPO Framework

CaTHPO integrates program logic directly into the BO loop through four primary components designed to make the optimization process aware of the underlying software structure:

  1. Code-Aware Program Representation: The system parses source code into Abstract Syntax Trees (ASTs). It employs a hybrid architecture—a Transformer for semantic context and an LSTM for syntactic structure—to generate a vectorized program "fingerprint." This module is trained via self-supervised learning to predict code tokens and node types.
  2. Code-Sensitive Surrogate: The Gaussian Process surrogate model, which predicts hyperparameter performance, is adjusted to weight historical data based on the code similarity between the source and target programs.
  3. Neural Acquisition Function: An RL-based policy network selects the next hyperparameter candidates. By utilizing the program's code representation, it can tailor its search strategy to the specific logic of the application.
  4. Safe Controller: To improve efficiency, a controller prunes the search space by avoiding regions that yielded poor results in similar programs, preventing the system from wasting resources on known sub-optimal configurations.
The CaTHPO framework architecture, featuring code-aware representation and a code-sensitive Bayesian Optimization loop.

Experimental Setup

The authors evaluated CaTHPO across two distinct, high-demand tuning scenarios:

  • Spark Tuning: Optimizing 15 configuration parameters (knobs) for eight Spark applications (e.g., PageRank, K-Means) to minimize execution time.
  • Recommender System (RS) Tuning: Tuning hyperparameters for eight different recommendation models (e.g., LightGCN, VAE-CF) to maximize accuracy measured by NDCG@10.

Results and Discussion

CaTHPO consistently outperformed state-of-the-art baselines in both speed and final performance. In Spark applications, it achieved an average reduction in execution time of 24% compared to standard BO. In RS tuning, accuracy improvements were even more pronounced, ranging from 10% to 96% over various competitors.

Performance comparison over iterations on Recommender System tuning, showing CaTHPO's superior convergence and final accuracy.

Key insights from the results include:

  • Code as a Meta-Feature: Program logic proved to be a more robust indicator for transferability than traditional dataset statistics. Traditional meta-features often fail to capture how an algorithm reacts to specific resource limits or architectural changes.
  • Efficiency and Robustness: The framework demonstrates faster convergence and lower variance across runs, indicating a more reliable and stable search process.
  • Generalization: CaTHPO maintains a performance lead even on "never-seen" programs, validating the effectiveness of its self-supervised code representation in bridging the gap between different software tasks.

Conclusion

CaTHPO represents a significant advancement in "intelligent" HPO by enabling models to understand the software they optimize. While the current implementation handles ASTs through random segmentation and focuses on specific languages, future work may address the complexity of enterprise-scale codebases and expand to a more language-agnostic pre-training approach.

Summary updated

BibTeX
@inproceedings{wang2023code,
  author = {Zijia Wang and Xiangyu He and Kehan Chen and Chen Lin and Jinsong Su},
  title = {{Code-Aware Cross-Program Transfer Hyperparameter Optimization}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i9.26226},
}
Figure