Skip to content

Latest commit

Β 

History

History
104 lines (72 loc) Β· 23.4 KB

File metadata and controls

104 lines (72 loc) Β· 23.4 KB
layout blog_detail
title λ² μ΄μ§€μ•ˆ μ΅œμ ν™”λ‘œ Helion의 μžλ™ νŠœλ‹ κ°€μ†ν•˜κΈ°
author Ethan Che, Oguz Ulgen, Max Balandat, Jongsok Choi, Jason Ansel
ext_author Junghwan Park (λ°•μ •ν™˜)
category
pytorch.org
translation
date 2026-02-24 04:00:00 -0800
org_title Accelerating Autotuning in Helion with Bayesian Optimization
org_link https://pytorch.org/blog/accelerating-autotuning-in-helion/

λ“€μ–΄κ°€λ©° / Introduction

이전 λΈ”λ‘œκ·Έ κΈ€μ—μ„œ μ†Œκ°œν–ˆλ“―μ΄, Helion은 μ΅μˆ™ν•œ PyTorch μŠ€νƒ€μΌμ˜ λ¬Έλ²•μœΌλ‘œ κ³ μ„±λŠ₯ ML 컀널을 μž‘μ„±ν•  수 있게 ν•΄μ£ΌλŠ” κ³ μˆ˜μ€€ DSL이며, λ³΅μž‘ν•œ μ΅œμ ν™” μž‘μ—…μ€ μžλ™ νŠœλ‹(autotuning) 엔진에 μœ„μž„ν•©λ‹ˆλ‹€. 이 μžλ™ νŠœλ„ˆ(autotuner)λŠ” 블둝 크기(block size), 루프 μˆœμ„œ(loop order), λ©”λͺ¨λ¦¬ μ ‘κ·Ό νŒ¨ν„΄ λ“± κ΅¬ν˜„ μ„ νƒμ§€λ‘œ 이루어진 λ°©λŒ€ν•œ 고차원 곡간을 νƒμƒ‰ν•˜μ—¬ λŒ€μƒ ν•˜λ“œμ›¨μ–΄μ—μ„œ μ„±λŠ₯을 κ·ΉλŒ€ν™”ν•˜λŠ” ꡬ성(configuration)을 μ°Ύμ•„λƒ…λ‹ˆλ‹€. κ·Έ κ²°κ³Ό Helion은 torch.compile은 λ¬Όλ‘ , Tritonμ΄λ‚˜ CuTe DSL둜 μ •κ΅ν•˜κ²Œ μ†μœΌλ‘œ μž‘μ„±ν•œ 컀널보닀도 μƒλ‹Ήν•œ 속도 ν–₯상을 달성할 수 μžˆμŠ΅λ‹ˆλ‹€.

As introduced in a previous blog post, Helion is a high-level DSL that empowers developers to write high-performance ML kernels using a familiar PyTorch-like syntax, delegating the complex task of optimization to its autotuning engine. This autotuner explores a vast, high-dimensional space of implementation choicesβ€”block sizes, loop orders, memory access patternsβ€”to discover configurations that maximize performance on the target hardware. As a result, Helion can achieve significant speedups over torch.compile and even highly-optimized, hand-written kernels in Triton or CuTe DSL.

κ·ΈλŸ¬λ‚˜ μžλ™ νŠœλ‹μœΌλ‘œ μ–»λŠ” μ„±λŠ₯ ν–₯μƒμ—λŠ” λŒ€κ°€κ°€ λ”°λ¦…λ‹ˆλ‹€. λ°”λ‘œ κΈ΄ μ‹€μ œ μ†Œμš” μ‹œκ°„(wall-clock time) μž…λ‹ˆλ‹€. 일반적인 μžλ™ νŠœλ‹ μ„Έμ…˜μ€ 수천 개의 후보 ꡬ성을 ν‰κ°€ν•˜λ©΄μ„œ 10λΆ„ 이상이 걸리며, λ³΅μž‘ν•œ μ»€λ„μ˜ 경우 수 μ‹œκ°„ λ‹¨μœ„κΉŒμ§€ λŠ˜μ–΄λ‚˜κΈ°λ„ ν•©λ‹ˆλ‹€. μΆœμ‹œ 이후 κΈ΄ μžλ™ νŠœλ‹ μ‹œκ°„μ€ μ‚¬μš©μž 뢈만으둜 κΎΈμ€€νžˆ μ œκΈ°λ˜μ–΄ μ™”μœΌλ©°, 컀널 개발 μ£ΌκΈ°μ—μ„œ κ°€μž₯ 큰 κ³ μΆ© 쀑 ν•˜λ‚˜μ˜€μŠ΅λ‹ˆλ‹€. Helion은 탐색 단계 수λ₯Ό μ€„μ΄λŠ” λ“± μžλ™ νŠœλ‹ 과정을 단좕할 수 μžˆλŠ” 선택지λ₯Ό μ œκ³΅ν•˜μ§€λ§Œ, μ΄λŠ” 보톡 컀널 μ„±λŠ₯ μ €ν•˜λ‘œ 이어져 λ°”λžŒμ§ν•˜μ§€ μ•Šμ€ μ ˆμΆ©μ„ κ°•μš”ν•©λ‹ˆλ‹€.

However, the performance gains from auto-tuning comes with a cost: long wall-clock times. A typical autotuning session can take 10+ minutes, evaluating thousands of candidate configurations, and can even take on the order of hours for complex kernels. Since its launch, long autotuning times have consistently surfaced as a user complaint and one of the biggest pain points in the kernel development cycle. While Helion provides developers options to shorten the auto-tuning process, e.g. by reducing the number of search steps, this typically leads to a loss in kernel performance, forcing an undesirable trade-off.

이번 κΈ€μ—μ„œλŠ” μžλ™ νŠœλ‹ κ²½ν—˜μ„ κ°œμ„ ν•˜κΈ° μœ„ν•œ μ§„ν–‰ 쀑인 λ…Έλ ₯을 λ‹€λ£Ήλ‹ˆλ‹€. 특히 μ΄λŸ¬ν•œ 문제λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•΄ κ°œλ°œν•œ μƒˆλ‘œμš΄ 탐색 μ•Œκ³ λ¦¬μ¦˜ LFBO Pattern Searchλ₯Ό μ†Œκ°œν•©λ‹ˆλ‹€. 이 μ•Œκ³ λ¦¬μ¦˜μ€ λ¨Έμ‹ λŸ¬λ‹(ML) 기법을 ν™œμš©ν•˜μ—¬ μžλ™ νŠœλ‹ μ—”μ§„μ˜ νš¨μœ¨μ„ λ†’μž…λ‹ˆλ‹€. 탐색 μ•Œκ³ λ¦¬μ¦˜μ΄ ML λͺ¨λΈμ„ ν•™μŠ΅μ‹œμΌœ 후보 ꡬ성을 μ§€λŠ₯적으둜 κ±ΈλŸ¬λƒ„μœΌλ‘œμ¨ ν‰κ°€ν•˜λŠ” ν›„λ³΄μ˜ 수λ₯Ό 크게 μ€„μž…λ‹ˆλ‹€. μ€‘μš”ν•œ 점은, 이 λͺ¨λΈμ΄ 탐색 κ³Όμ •μ—μ„œ μˆ˜μ§‘λœ λ°μ΄ν„°λ§Œ μ‚¬μš©ν•˜λ©° μ‚¬μš©μžκ°€ λ³„λ„μ˜ 데이터λ₯Ό μ œκ³΅ν•  ν•„μš”κ°€ μ—†λ‹€λŠ” κ²ƒμž…λ‹ˆλ‹€.

In this blog post, we discuss our ongoing efforts to improve the autotuning experience. In particular, we discuss a new search algorithm LFBO Pattern Search we developed to address these issues, which employs techniques from machine learning (ML) to improve efficiency of the autotuning engine. The search algorithm trains an ML model to intelligently filter candidate configurations, substantially reducing the number of candidates evaluated. Importantly, the model only uses data collected during the search process, and doesn't need the user to provide any additional data.

ML을 ν™œμš©ν•˜λ©΄ μ„±λŠ₯을 ν¬μƒν•˜μ§€ μ•ŠμœΌλ©΄μ„œλ„ μžλ™ νŠœλ‹ μ‹œκ°„μ„ μƒλ‹Ήνžˆ 쀄일 수 μžˆμŠ΅λ‹ˆλ‹€.

Using ML, we can reduce autotuning time substantially without sacrificing performance:

  • 벀치마크용 NVIDIA B200 컀널 λͺ¨μŒμ—μ„œ, μžλ™ νŠœλ‹ μ‹œκ°„μ„ 36.5% μ€„μ΄λŠ” λ™μ‹œμ— 컀널 μ§€μ—° μ‹œκ°„(latency)을 평균 2.6% κ°œμ„ ν–ˆμŠ΅λ‹ˆλ‹€.
  • AMD MI350 μ»€λ„μ—μ„œλŠ” μžλ™ νŠœλ‹ μ‹œκ°„μ„ 25.9% μ€„μ΄λ©΄μ„œ 컀널 μ§€μ—° μ‹œκ°„μ„ 1.7% κ°œμ„ ν–ˆμŠ΅λ‹ˆλ‹€.
  • On our set of benchmark NVIDIA B200 kernels, we reduce autotuning time by 36.5% while improving kernel latency by 2.6% on average.
  • On AMD MI350 kernels, we reduce autotuning time by 25.9% while improving kernel latency by 1.7%.

NVIDIA B200 μ»€λ„μ—μ„œμ˜ κ²°κ³Ό / Results on NVIDIA B200 kernels{:style="width:100%"}

AMD MI350 μ»€λ„μ—μ„œμ˜ κ²°κ³Ό / Results on AMD MI350 kernels{:style="width:100%"}

일뢀 μ»€λ„μ—μ„œλŠ” κ°œμ„  νš¨κ³Όκ°€ 특히 λ‘λ“œλŸ¬μ§‘λ‹ˆλ‹€. B200 layer-norm μ»€λ„μ—μ„œλŠ” μ‹€μ œ μ†Œμš” μ‹œκ°„μ΄ μ΅œλŒ€ 50% κ°μ†Œν–ˆκ³ , B200 Helion FlashAttention μ»€λ„μ—μ„œλŠ” 컀널 μ§€μ—° μ‹œκ°„μ΄ 15% 이상 κ°œμ„ λ˜κΈ°λ„ ν–ˆμŠ΅λ‹ˆλ‹€. 이처럼 ν–₯μƒλœ μ„±λŠ₯ 덕뢄에, 이 μ•Œκ³ λ¦¬μ¦˜μ€ 이 글을 μ“°λŠ” ν˜„μž¬ κΈ°λ³Έ 탐색 μ•Œκ³ λ¦¬μ¦˜μž…λ‹ˆλ‹€.

For some kernels the improvements are especially significant: we see up to a 50% reduction in wall-clock time for B200 layer-norm kernels, and even a >15% improvement in kernel latency for B200 Helion FlashAttention kernels. Due to its enhanced performance, it is the default search algorithm at the time of writing.

컀널 μžλ™ νŠœλ‹μ˜ 어렀움 / The Challenges of Kernel Autotuning

μžλ™ νŠœλ‹ 엔진은 컀널 ꡬ성듀을 νƒμƒ‰ν•˜λ©΄μ„œ κ·Έ μ§€μ—° μ‹œκ°„μ„ λ²€μΉ˜λ§ˆν¬ν•˜κ³ , κ·Έ κ²°κ³Όλ₯Ό λ°”νƒ•μœΌλ‘œ λ‹€μŒμ— λ²€μΉ˜λ§ˆν¬ν•  ꡬ성 집합을 κ²°μ •ν•©λ‹ˆλ‹€. 단일 ꡬ성을 μ»΄νŒŒμΌν•˜κ³  μ§€μ—° μ‹œκ°„μ„ μΈ‘μ •ν•˜λŠ” λ°λŠ” 수 초 정도가 κ±Έλ¦¬μ§€λ§Œ, μžλ™ νŠœλ‹ 엔진은 κ°€λŠ₯ν•œ 졜고의 μ„±λŠ₯을 μ–»κΈ° μœ„ν•΄ 보톡 수천 개의 ꡬ성을 νƒμƒ‰ν•©λ‹ˆλ‹€. 졜적의 컀널 ꡬ성을 μ°ΎλŠ” 일은 섀계 곡간에 λ‚΄μž¬λœ μ—¬λŸ¬ μš”μΈμœΌλ‘œ 인해 μ–΄λ €μš΄ μ΅œμ ν™” λ¬Έμ œμž…λ‹ˆλ‹€.

The autotuning engine searches through kernel configurations, benchmarking their latency and using the outcomes to determine the next set of configs to benchmark. While compiling and measuring the latency of a single configuration takes on the order of seconds, the autotuning engine typically searches through thousands of configurations to achieve the best possible performance. Finding the optimal kernel configuration is a challenging optimization problem due to several factors inherent to the design space:

  • κ³ μ°¨μ›μ˜ μ‘°ν•© 곡간(High-Dimensional, Combinatorial Space): 블둝 크기, μ–Έλ‘€ νŒ©ν„°(unroll factor) λ“± κ°€λŠ₯ν•œ λͺ¨λ“  μ‘°ν•©μ˜ 곡간은 고차원이며 λ°©λŒ€ν•©λ‹ˆλ‹€. LayerNorm처럼 λ‹¨μˆœν•œ 컀널쑰차 8천쑰(8 quadrillion, 10^16) κ°œκ°€ λ„˜λŠ” ꡬ성을 κ°€μ§ˆ 수 μžˆμŠ΅λ‹ˆλ‹€. λ‹€λ§Œ 탐색 곡간은 κ±°λŒ€ν•˜μ§€λ§Œ, 쒋은 μ„±λŠ₯을 λ‚΄λŠ” ꡬ성은 극히 일뢀에 λΆˆκ³Όν•©λ‹ˆλ‹€.
  • κΈ΄ 컴파일 μ‹œκ°„(Long Compile Times): μ–΄λ–€ 컀널 ꡬ성은 μ»΄νŒŒμΌμ— μƒλ‹Ήν•œ μ‹œκ°„μ΄ κ±Έλ €, μžλ™ νŠœλ‹ κ³Όμ •μ˜ μ‹€μ œ μ†Œμš” μ‹œκ°„μ„ λΆˆν•„μš”ν•˜κ²Œ λŠ˜λ¦½λ‹ˆλ‹€.
  • ꡬ성 였λ₯˜μ™€ νƒ€μž„μ•„μ›ƒ(Config Errors and Timeouts): 탐색 κ³΅κ°„μ—λŠ” 컴파일 였λ₯˜κ°€ λ‚˜κ±°λ‚˜, λΆ€μ •ν™•ν•œ κ²°κ³Όλ₯Ό λ‚΄κ±°λ‚˜, μ»΄νŒŒμΌμ— λ„ˆλ¬΄ 였래 κ±Έλ¦¬λŠ” ꡬ성도 포함될 수 μžˆμŠ΅λ‹ˆλ‹€.
  • High-Dimensional, Combinatorial Space: The space of all possible combinations of block sizes, unroll factors, etc. is high-dimensional and vast. Even a simple kernel like LayerNorm has more than 8 quadrillion (10^16) possible configurations. However, while the search space is large, only a small fraction of configs have good performance.
  • Long Compile Times: Certain kernel configurations can take a significant amount of time to compile, unnecessarily extending the autotuning process's wall-clock time.
  • Config Errors and Timeouts: The search space can also include configs that have compilation errors, produce inaccurate results, or take too long to compile.

μ΄μ „μ˜ κΈ°λ³Έ 탐색 μ „λž΅(Pattern Search)은 μ—¬λŸ¬ 개의 μœ λ§ν•œ ꡬ성('탐색 사본(search copies)')μ—μ„œ μ‹œμž‘ν•˜μ—¬, 단일 λ§€κ°œλ³€μˆ˜λ₯Ό λ³€ν˜•ν•œ λͺ¨λ“  경우λ₯Ό 빠짐없이 ν‰κ°€ν•˜λŠ” λ°©μ‹μœΌλ‘œ 이웃 ꡬ성듀을 νƒμƒ‰ν•©λ‹ˆλ‹€. μ² μ €ν•˜κΈ΄ ν•˜μ§€λ§Œ 이 방식은 λΉ„νš¨μœ¨μ μž…λ‹ˆλ‹€. 이웃 κ΅¬μ„±μ˜ λŒ€λΆ€λΆ„μ€ μ„±λŠ₯을 μ „ν˜€ κ°œμ„ ν•˜μ§€ λͺ»ν•˜λŠ”λ°λ„ ν•˜λ‚˜ν•˜λ‚˜ μ»΄νŒŒμΌν•˜κ³  λ²€μΉ˜λ§ˆν¬ν•˜κΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€. κ²Œλ‹€κ°€ 이동을 단일 λ§€κ°œλ³€μˆ˜ λ³€κ²½μœΌλ‘œ μ œν•œν•˜λ©΄, 고차원 탐색 곡간을 λΉ λ₯΄κ²Œ κ°€λ‘œμ§€λ₯΄λŠ” λŠ₯λ ₯이 λ–¨μ–΄μ§‘λ‹ˆλ‹€.

The previous default search strategy (Pattern Search) starts from multiple promising configurations ('search copies') and explores neighboring configs by exhaustively evaluating all single-parameter perturbations. While thorough, this approach is inefficient: the vast majority of neighbors offer no performance improvement, yet each is compiled and benchmarked. Furthermore, restricting moves to single-parameter changes limits the algorithm's ability to traverse the high-dimensional search space quickly.

κ°€λŠ₯도 μ—†λŠ” λ² μ΄μ§€μ•ˆ μ΅œμ ν™” νŒ¨ν„΄ 탐색 / Likelihood-Free Bayesian Optimization Pattern Search

μ΄λŸ¬ν•œ λΉ„νš¨μœ¨μ„ ν•΄κ²°ν•˜κΈ° μœ„ν•΄, λ‹€μŒμ— 평가할 점을 μ§€λŠ₯적으둜 μ„ νƒν•˜λŠ” ν™•λ₯ μ  λŒ€λ¦¬ λͺ¨λΈ(surrogate model, 예: κ°€μš°μ‹œμ•ˆ ν”„λ‘œμ„ΈμŠ€(Gaussian Process))을 ν™œμš©ν•˜λŠ” λ¨Έμ‹ λŸ¬λ‹μ˜ ν•œ 뢄야인 λ² μ΄μ§€μ•ˆ μ΅œμ ν™”(Bayesian Optimization)μ—μ„œ μ˜κ°μ„ μ–»μ—ˆμŠ΅λ‹ˆλ‹€(botorchλ‚˜ Ax 같은 λΌμ΄λΈŒλŸ¬λ¦¬μ—μ„œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€). μΆ”κ°€λ˜λŠ” μ‹€μ œ μ†Œμš” μ‹œκ°„μ„ μ΅œμ†Œν™”ν•˜κΈ° μœ„ν•΄, 더 κ°€λ²Όμš΄ λΆ„λ₯˜(classification) λͺ¨λΈμ„ λŒ€λ¦¬ λͺ¨λΈλ‘œ μ‚¬μš©ν•˜λŠ” κ°€λŠ₯도 μ—†λŠ” λ² μ΄μ§€μ•ˆ μ΅œμ ν™”(Likelihood-Free Bayesian Optimization)(LFBO)λ₯Ό λ„μž…ν–ˆμŠ΅λ‹ˆλ‹€. Pattern Search의 μ§€μ—­ 탐색 νœ΄λ¦¬μŠ€ν‹±κ³Ό LFBO λΆ„λ₯˜κΈ° λͺ¨λΈμ„ κ²°ν•©ν•˜μ—¬, μ™„μ „ 탐색 λŒ€μ‹  κ°€μž₯ μœ λ§ν•œ ν›„λ³΄λ§Œ κ±ΈλŸ¬μ„œ λ²€μΉ˜λ§ˆν¬ν•©λ‹ˆλ‹€.

To address these inefficiencies, we take inspiration from Bayesian Optimization, a sub-domain of machine learning which utilizes a probabilistic surrogate model (e.g. a Gaussian Process) to intelligently select which points to evaluate next (available in libraries such as botorch and Ax). To minimize additional wall-clock time, we adapt Likelihood-Free Bayesian Optimization (LFBO), which uses a lighter-weight classification model as a surrogate. We combine the local search heuristic of Pattern Search with the LFBO classifier model to filter only the most promising candidates to benchmark, instead of exhaustive search.

LFBOPatternSearch μ•Œκ³ λ¦¬μ¦˜μ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

The LFBOPatternSearch algorithm is as follows:

  1. PatternSearch와 λ§ˆμ°¬κ°€μ§€λ‘œ, λ¨Όμ € λ¬΄μž‘μœ„λ‘œ μƒμ„±ν•œ ꡬ성 집합을 λ²€μΉ˜λ§ˆν¬ν•˜μ—¬ κ°€μž₯ μœ λ§ν•œ μ†Œμˆ˜μ˜ ꡬ성('탐색 사본(search copies)')을 μ‹λ³„ν•©λ‹ˆλ‹€.
  2. 탐색 μ‚¬λ³ΈμœΌλ‘œλΆ€ν„° μ—¬λŸ¬ λ§€κ°œλ³€μˆ˜μ— 걸쳐 λ¬΄μž‘μœ„ λ³€ν˜•μ„ κ°€ν•΄ 후보λ₯Ό μƒμ„±ν•˜λ©°, PatternSearch보닀 더 λ„“κ²Œ νƒμƒ‰ν•©λ‹ˆλ‹€.
  3. μ§€κΈˆκΉŒμ§€ μˆ˜μ§‘ν•œ μ§€μ—° μ‹œκ°„ λ°μ΄ν„°λ‘œ λΆ„λ₯˜ λͺ¨λΈ(랜덀 포레슀트(RandomForest))을 ν•™μŠ΅μ‹œν‚΅λ‹ˆλ‹€. μ§€μ—° μ‹œκ°„μ„ 직접 μ˜ˆμΈ‘ν•˜λŠ” λŒ€μ‹ , ν•΄λ‹Ή ꡬ성이 μ§€μ—° μ‹œκ°„ κΈ°μ€€ μƒμœ„ 10%에 λ“œλŠ”μ§€λ₯Ό λ‚˜νƒ€λ‚΄λŠ” 이진 λ ˆμ΄λΈ”μ„ μ˜ˆμΈ‘ν•©λ‹ˆλ‹€.
  4. ML λͺ¨λΈμ˜ μ˜ˆμΈ‘μ„ λ°”νƒ•μœΌλ‘œ ν›„λ³΄μ˜ μˆœμœ„λ₯Ό λ§€κΉλ‹ˆλ‹€. 일반적인 LFBO와 달리, 탐색을 μž₯λ €ν•˜κΈ° μœ„ν•΄ 이미 μˆœμœ„κ°€ 맀겨진 ν›„λ³΄μ™€μ˜ μœ μ‚¬λ„μ— λŒ€ν•œ νŒ¨λ„ν‹°λ„ μΆ”κ°€ν•©λ‹ˆλ‹€.
  5. 그쀑 μƒμœ„ 10%λ₯Ό 선택해 μ»΄νŒŒμΌν•˜κ³  λ²€μΉ˜λ§ˆν¬ν•©λ‹ˆλ‹€. μ„±λŠ₯이 κ°€μž₯ 쒋은 ꡬ성을 λ°”νƒ•μœΌλ‘œ 탐색 사본을 κ°±μ‹ ν•˜κ³ , μΈ‘μ •λœ μ§€μ—° μ‹œκ°„μ„ 데이터셋에 μΆ”κ°€ν•©λ‹ˆλ‹€.
  1. Similar to PatternSearch, we first benchmark a set of randomly generated configs, and identify a small set of the most promising configurations ('search copies').
  2. We generate candidates from the search copies, by making random perturbations across multiple parameters, exploring more widely than PatternSearch.
  3. We train a classification model (RandomForest) on latency data collected so far. Instead of predicting latency directly, we predict a binary label indicating whether the config is in the top 10% in terms of latency.
  4. We rank the candidates based on ML model predictions. Unlike typical LFBO, we also add a penalty for similarity to previously ranked candidates to encourage exploration.
  5. We select the top 10% of them to compile and benchmark. We update the search copies based on the best performing configs and add the latencies to the dataset.

LFBO Pattern Search μ•Œκ³ λ¦¬μ¦˜ κ°œμš” / Overview of the LFBO Pattern Search algorithm{:style="width:100%"}

κ΄€μ°°λœ μ‹€μ œ μ†Œμš” μ‹œκ°„κ³Ό μ§€μ—° μ‹œκ°„ κ°œμ„ μ„ λ‹¬μ„±ν•˜λŠ” 데 결정적인 역할을 ν•œ λͺ‡ κ°€μ§€ 핡심 섀계 결정을 μ‚΄νŽ΄λ³΄κ² μŠ΅λ‹ˆλ‹€.

We discuss some key design decisions, which are critical for achieving the improvements in wall-clock time and latency we observed:

λΆ„λ₯˜ λŒ€ νšŒκ·€(Classification vs Regression): λͺ¨λΈμ΄ μ§€μ—° μ‹œκ°„μ„ 직접 μ˜ˆμΈ‘ν•˜λ„λ‘ ν•™μŠ΅μ‹œν‚€λŠ” νšŒκ·€(regression) 기반 방법은 μ‹œμŠ€ν…œ/컴파일러 μ—°κ΅¬μ—μ„œ λΉ„μš© λͺ¨λΈλ§(cost modeling)의 사싀상 ν‘œμ€€μž…λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ μ’‹λ“  λ‚˜μ˜λ“  λͺ¨λ“  κ΅¬μ„±μ˜ μ§€μ—° μ‹œκ°„μ„ ν•™μŠ΅ν•˜λ €κ³  μ• μ“°λŠ” λŒ€μ‹ , λΆ„λ₯˜ 기반 접근이 κ°€μž₯ μ„±λŠ₯이 쒋은 ꡬ성에 λͺ¨λΈμ˜ μ—­λŸ‰μ„ 더 잘 μ§‘μ€‘μ‹œν‚¨λ‹€λŠ” 점을 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€. λ‘˜μ§Έλ‘œ, λΆ„λ₯˜ 손싀(classification loss)은 였λ₯˜κ°€ λ‚˜κ±°λ‚˜ 컴파일 νƒ€μž„μ•„μ›ƒμ΄ λ°œμƒν•˜λŠ” ꡬ성(μ΄λ“€μ—λŠ” 음의 λ ˆμ΄λΈ”μ΄ λΆ€μ—¬λ©λ‹ˆλ‹€)을 ν”Όν•˜λ„λ‘ λͺ¨λΈμ΄ ν•™μŠ΅ν•˜κ²Œ ν•΄μ€λ‹ˆλ‹€. 반면 이런 ꡬ성듀은 μœ νš¨ν•œ μ§€μ—° μ‹œκ°„ 데이터가 μ—†μœΌλ―€λ‘œ νšŒκ·€ 기반 접근이 ν•™μŠ΅ν•  거리가 μ—†μŠ΅λ‹ˆλ‹€.

Classification vs Regression: Regression-based methods, i.e. training the model to predict latency directly, is the de-facto approach for cost modeling in systems / compiler research. However, we find that a classification-based approach better focuses model capacity on the most performant configs instead of trying to learn the latency of all configs, good or bad. Second, the classification loss enables the model to learn to avoid configs that error out or suffer compile timeouts (as these are assigned negative labels). However, these points do not have any valid latency data for a regression-based approach to learn from.

λ‹€μ–‘μ„± μž₯λ €(Encouraging Diversity): 보톡 ꡬ성듀은 병렬 사전 컴파일(pre-compilation)을 ν™œμš©ν•˜κΈ° μœ„ν•΄ 배치(batch) λ‹¨μœ„λ‘œ μ»΄νŒŒμΌλ©λ‹ˆλ‹€. 랜덀 포레슀트 λΆ„λ₯˜κΈ°λŠ” μ„œλ‘œ 뭉쳐 μžˆλŠ” μœ μ‚¬ν•œ ꡬ성을 반볡적으둜 선택할 수 μžˆλŠ”λ°, μ΄λŠ” μƒˆλ‘œμš΄ 정보λ₯Ό 거의 μ£Όμ§€ λͺ»ν•˜λŠ” 쀑볡 μƒ˜ν”Œμ— 배치 μ˜ˆμ‚°μ„ λ‚­λΉ„ν•˜κ²Œ λ§Œλ“­λ‹ˆλ‹€. 이λ₯Ό μ™„ν™”ν•˜κΈ° μœ„ν•΄, 랜덀 포레슀트 λͺ¨λΈμ˜ 리프 λ…Έλ“œ λ™μ‹œ μΆœν˜„(leaf node co-occurrence)을 λ°”νƒ•μœΌλ‘œ μœ μ‚¬λ„ 점수λ₯Ό κ³„μ‚°ν•˜κ³ , 이미 μˆœμœ„κ°€ 맀겨진 κ΅¬μ„±κ³Όμ˜ μœ μ‚¬λ„μ— νŒ¨λ„ν‹°λ₯Ό λΆ€μ—¬ν•©λ‹ˆλ‹€.

Encouraging Diversity: Typically configs are compiled in batch, to take advantage of parallelized pre-compilation. The Random Forest classifier may repeatedly select similar configurations that cluster, which can waste the batch budget on redundant samples that provide little new information. To mitigate this, we compute a similarity score based on leaf node co-occurrence from the Random Forest model, and penalize similarity to previously ranked configs.

LFBO Pattern Search의 λ™μž‘μ„ μ‚΄νŽ΄λ³΄λ©΄, μ»€λ„Β·ν•˜λ“œμ›¨μ–΄ μ’…λ₯˜Β·ν˜•상(shape) μ „λ°˜μ— 걸친 μ„±λŠ₯ κ°œμ„ μ΄ 더 적은 평가 횟수둜 더 λ‚˜μ€ λŸ°νƒ€μž„μ„ κ°€μ§„ ꡬ성을 μ°Ύμ•„λ‚΄λŠ” λŠ₯λ ₯μ—μ„œ λΉ„λ‘―λœλ‹€λŠ” 것을 μ‹€μ œλ‘œ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€. μ•„λž˜λŠ” B200 layer-norm 컀널에 λŒ€ν•œ μžλ™ νŠœλ‹ 트레이슀 μ˜ˆμ‹œλ‘œ, μ‹œκ°„ 경과에 따라 μžλ™ νŠœλ„ˆκ°€ 얻은 졜적 κ΅¬μ„±μ˜ μ§€μ—° μ‹œκ°„μ„ λ³΄μ—¬μ€λ‹ˆλ‹€. LFBOκ°€ μžλ™ νŠœλ‹μ„ 더 일찍(μ•½ 9λΆ„ λŒ€μ‹  μ•½ 5λΆ„) μ™„λ£Œν•  뿐만 μ•„λ‹ˆλΌ, Pattern Search에 λΉ„ν•΄ 훨씬 큰 폭의 μ„±λŠ₯ 도약을 이루며 더 λ‚˜μ€ ꡬ성을 더 λΉ λ₯΄κ²Œ μ°Ύμ•„λ‚Έλ‹€λŠ” 것을 λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€.

When we investigate the behavior of LFBO Pattern Search, we see indeed that improvements in performance across kernels, hardware types, and shapes are due its ability to find configurations with better runtime using fewer evaluations. Below is a plot of example auto-tuning traces for a B200 layer-norm kernel, displaying the latency of the best configuration obtained by the autotuner over time. We see not only that LFBO completes auto-tuning earlier (~5 min instead of ~9 min), it finds better configurations faster with much larger jumps in performance compared to Pattern Search.

B200 layer-norm μ»€λ„μ˜ μžλ™ νŠœλ‹ 트레이슀 / Auto-tuning traces for a B200 layer-norm kernel{:style="width:100%"}

LFBOκ°€ 이λ₯Ό λ‹¬μ„±ν•˜λŠ” 방식은 Pattern Search보닀 더 λ„“κ²Œ νƒμƒ‰ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€. μ•„λž˜λŠ” λ™μΌν•œ B200 layer-norm 컀널에 λŒ€ν•΄ LFBO Pattern Search와 Pattern Searchκ°€ μƒ˜ν”Œλ§ν•œ ꡬ성을 λ³΄μ—¬μ£ΌλŠ” κ·Έλž˜ν”„λ‘œ, (ꡬ성이 κ³ μ°¨μ›μ΄λ―€λ‘œ) μ‹œκ°ν™”λ₯Ό μœ„ν•΄ μ£Όμ„±λΆ„ 뢄석(Principal Component Analysis, PCA)을 μ μš©ν–ˆμŠ΅λ‹ˆλ‹€. LFBO Pattern SearchλŠ” ꡬ성을 μ ˆλ°˜λ„ μ•ˆ λ˜λŠ” 수만큼 ν‰κ°€ν•˜λ©΄μ„œλ„, κ·Έ μƒ˜ν”Œλ§ν•œ ꡬ성듀이 Pattern Search의 것보닀 더 λ„“κ²Œ 퍼져 μžˆμŒμ„ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€. Pattern Search의 ꡬ성듀은 단일 λ§€κ°œλ³€μˆ˜ λ³€ν˜•λ§Œ ν•˜κΈ° λ•Œλ¬Έμ— ν•œκ³³μ— μ‹¬ν•˜κ²Œ 뭉쳐 μžˆμŠ΅λ‹ˆλ‹€. λΆ„λ₯˜κΈ°μ˜ μ•ˆλ‚΄λ₯Ό λ°›μ•„ LFBO Pattern SearchλŠ” 더 ν¬λ©΄μ„œλ„ 더 ν‘œμ ν™”λœ 도약을 ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

We see that LFBO accomplishes this by exploring more widely than Pattern Search. Below is a plot of configs sampled by LFBO Pattern Search and Pattern Search for the same B200 layer-norm kernel, where we apply Principal Component Analysis (PCA) for visualization (as configs are high-dimensional). We see that while LFBO Pattern Search evaluates less than half of the number of configs, its sampled configs are more spread out than Pattern Search's which are highly clumped together due to Pattern Search making only single parameter perturbations. Guided by the classifier, the LFBO Pattern Search is able to make larger, but more targeted jumps.

ν‘œμ§‘λœ κ΅¬μ„±μ˜ PCA μ‹œκ°ν™” / PCA visualization of sampled configurations{:style="width:100%"}

λ§ˆμ§€λ§‰μœΌλ‘œ, λ‹€λ₯Έ λŒ€λ¦¬ λͺ¨λΈλ“€, 특히 랜덀 포레슀트, κ·Έλž˜λ””μ–ΈνŠΈ λΆ€μŠ€νŒ… 트리(Gradient-Boosting Tree), λ‹€μΈ΅ νΌμ…‰νŠΈλ‘ (Multi-Layer Perceptron, MLP)을 μ‚¬μš©ν•˜λŠ” νšŒκ·€ 기반 μ ‘κ·Όλ“€κ³Ό ν•¨κ»˜ μ• λΈ”λ ˆμ΄μ…˜(ablation) μ‹€ν—˜μ„ μˆ˜ν–‰ν–ˆμŠ΅λ‹ˆλ‹€. μ΄λ•Œ (PatternSearchμ—μ„œ μˆ˜μ§‘ν•œ) μžλ™ νŠœλ„ˆ 둜그 데이터셋을 μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€. μžλ™ νŠœλ„ˆ μ„±λŠ₯κ³Ό κ°€μž₯ μ§μ ‘μ μœΌλ‘œ μ—°κ΄€λœ μ§€ν‘œμΈ, λŒ€λ¦¬ λͺ¨λΈμ„ μ‚¬μš©ν•΄ λ‹€μŒ 후보 배치λ₯Ό κ±ΈλŸ¬λ‚Ό λ•Œ κΈ°λŒ€λ˜λŠ” 컀널 μ§€μ—° μ‹œκ°„ κ°œμ„ μΉ˜λ₯Ό κ³„μ‚°ν•©λ‹ˆλ‹€. μ•„λž˜μ—μ„œλŠ” λŒ€λ¦¬ λͺ¨λΈμ΄ μ„ νƒν•˜λ„λ‘ ν—ˆμš©λœ 후보 λΉ„μœ¨ λŒ€λΉ„ κΈ°λŒ€ κ°œμ„ μΉ˜(μ§€μ—° μ‹œκ°„μ˜ μƒλŒ€μ  % κ°œμ„ )λ₯Ό κ·Έλž˜ν”„λ‘œ λ‚˜νƒ€λƒˆμŠ΅λ‹ˆλ‹€. LFBO 기반 방법이 κ°€μž₯ 큰 κΈ°λŒ€ κ°œμ„ μΉ˜λ₯Ό μ œκ³΅ν•˜λ©°, 닀양성을 κ³ λ €ν•œ 선택이 의미 μžˆλŠ” κ°œμ„ μ„ λ”ν•œλ‹€λŠ” 것을 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€. 특히 ν›„λ³΄μ˜ 10%만 선택할 수 μžˆμ„ λ•Œ, νšŒκ·€ 기반 방법은 λ‹¨μˆœ λ¬΄μž‘μœ„ 선택과 λ™λ“±ν•˜κ±°λ‚˜ 였히렀 더 λ‚˜μœ μ„±λŠ₯을 λ³΄μ˜€μŠ΅λ‹ˆλ‹€. νšŒκ·€κ°€ 항상 μˆœμœ„ λ§€κΈ°κΈ°(ranking) μ„±λŠ₯κ³Ό μΌμΉ˜ν•˜μ§€λŠ” μ•ŠκΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€.

Finally, we perform an ablation with other surrogate models, in particular regression-based approaches involving a Random Forest, Gradient-Boosting Tree, and Multi-Layer Perceptron (MLP), using a dataset of autotuner logs (collected from PatternSearch). We compute a metric that is most directly correlated with autotuner performance: the expected improvement in kernel latency when using the surrogate to filter the next batch of candidates. Below we plot the expected improvement (in terms of relative % improvements in latency) compared to the percent of candidates the surrogate is allowed to select. We find that the LFBO-based methods deliver the largest expected improvement, with meaningful improvements from diverse selection. Notably, when we only can select 10% of candidates, the regression-based methods perform equivalent or even worse than simple random selection, as regression is not always aligned with ranking performance.

λŒ€λ¦¬ λͺ¨λΈλ³„ κΈ°λŒ€ κ°œμ„ μΉ˜ μ• λΈ”λ ˆμ΄μ…˜ / Ablation of expected improvement across surrogate models{:style="width:100%"}

맺음말 / Conclusion

이번 κΈ€μ—μ„œλŠ” λ¨Έμ‹ λŸ¬λ‹(ML)이 μ–΄λ–»κ²Œ μžλ™ νŠœλ‹ 엔진을 κ°€μ†ν•˜κ³  Helionμ—μ„œμ˜ 컀널 μž‘μ„± κ²½ν—˜μ„ κ°œμ„ ν•  수 μžˆλŠ”μ§€λ₯Ό λ³΄μ—¬μ£Όμ—ˆμŠ΅λ‹ˆλ‹€. 탐색 κ³Όμ •μ—μ„œ μˆ˜μ§‘ν•œ μ§€μ—° μ‹œκ°„ 데이터λ₯Ό ν™œμš©ν•˜λ©΄, μžλ™ νŠœλ„ˆλ₯Ό 더 μœ λ§ν•œ ꡬ성에 μ§‘μ€‘μ‹œμΌœ μ‹œκ°„μ„ μ ˆμ•½ν•˜κ³  더 λΉ λ₯Έ 컀널 ꡬ성을 λ°œκ²¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€. μš°λ¦¬λŠ” κ°•ν™” ν•™μŠ΅(reinforcement learning, RL)κ³Ό λŒ€κ·œλͺ¨ μ–Έμ–΄ λͺ¨λΈ(large language models, LLMs)의 기법을 ν¬ν•¨ν•˜μ—¬, μžλ™ νŠœλ„ˆλ₯Ό κ°•ν™”ν•˜κΈ° μœ„ν•œ 좔가적인 ML 기법을 μ μš©ν•˜λŠ” 데 적극적인 관심을 κ°–κ³  있으며, μ–΄λ–€ ν˜•νƒœμ˜ κΈ°μ—¬λ“  ν™˜μ˜ν•©λ‹ˆλ‹€.

In this blog post, we illustrate how machine learning (ML) can accelerate the autotuning engine and improve the kernel authoring experience in Helion. By using the latency data collected during the search process, we can focus the autotuner on more promising configurations, saving time and discovering faster kernel configs. We are actively interested in applying additional ML techniques to enhance the auto-tuner, including methods from reinforcement learning (RL) and large language models (LLMs), and welcome any contributions.