Skip to content

Conversation

@ethche
Copy link

@ethche ethche commented Nov 11, 2025

Includes the LFBO Pattern Search autotuner, which modifies PatternSearch to search through configs using a learned acquisition function (RandomForestClassifier) according to the likelihood-free bayesian optimization framework [1].

  • Similar to PatternSearch, we generate neighbors from search copies. But instead we generate random neighbors instead of exhaustive set.
  • Filters a fraction of them to evaluate using a fitted RandomForestClassifier. This classifier is trained to learn which configs are the best x% of configs. As a result, the classifier learns which configs are likely to improve upon the best config seen so far.

This improves over PatternSearch in kernel latency and autotuning wall-clock time on B200 for a set of benchmark kernels. DifferentialEvolution can improve further upon this, but takes substantially longer. DESurrogate in #1096, has comparable performance. We also compare to UCBPatternSearch, a previous proposal which uses a Gaussian Process + UCB acquisition function.

Kernel latency:
geomean_latency_ratio_vs_pattern

Autotuning Wall-clock Speedup:
geomean_wallclock_speedup_vs_pattern

Autotuning Convergence Time:
geomean_convergence_speedup_vs_pattern

Some example convergence plots:

int4_gemm_1_1_7168_8192 softmax_4096_640

[1] J. Song, et al. A General Recipe for Likelihood-free Bayesian Optimization

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2025
@ethche ethche requested a review from jansel November 14, 2025 01:03

def encode_dim(self) -> int:
"""
Returns the dimension of the output of encode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this is? What is it encoding?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the dimension of the encoding

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name to be more clear

"""
raise NotImplementedError

def encode(self, value: object) -> list[float]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse encode_scalar here? If not, I'd like to combine this with encode_scalar since they are solving the same problem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jansel This is pretty much identical to encode_scalar for integer and poweroftwo. But the previous encode_scalar did not have any functionality for ListOf or PermutationFragments. How should we handle those two?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to rename everything to encode_scalar, but given ListOf and PermutationFragments, I think we should allow encode to output a list of floats

Comment on lines 75 to 82
self.cat_dims = []
offset = 0
for spec in self.config_gen.flat_spec:
n_dims = spec.encode_dim()
if spec.is_categorical():
# All dimensions of this encoder are categorical
self.cat_dims.extend(range(offset, offset + n_dims))
offset += n_dims
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems kind of error prone, can we have a cleaner way to do it?

@ethche ethche requested a review from jansel November 16, 2025 19:41
# Initialize config encoder
self.frac_selected = frac_selected

# compute offsets from the flat_spec
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this better?

@ethche ethche changed the title Add UCB Pattern Search Add LFBO Pattern Search Nov 18, 2025
@ethche
Copy link
Author

ethche commented Nov 18, 2025

Just for some background, I performed some new experiments and found that a new method, called LFBO Pattern Search, performs just as well as UCBPatternSearch, but doesn't need any new imports.

It's based on a RandomForestClassifier surrogate. It is trained on classifying which configs are among the top x% in performance. As such, it can be trained without having to filter out configs that time-out or have poor accuracy. I've structured the file to be similar to de-surrogate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants