Open
Conversation
Summary:
## Motivation
Enables Helion autotuning (both FiniteSearch and LFBOTreeSearch) for layernorm kernels on MTIA. Previously, autotuning was completely broken on MTIA — even FiniteSearch would crash immediately.
## Change Summary
Three changes across 4 files:
1. helion/autotuner/local_cache.py — Adds an elif dev.type == "mtia": branch in _generate_key() so that hardware and runtime_name are populated for MTIA devices. Without this, the method hit assert hardware is not None and runtime_name is not None and crashed.
2. helion/autotuner/base_search.py — Skips setting TRITON_STORE_BINARY_ONLY=1 on MTIA (guarded by supports_mtia_tunables()). The MTIA Triton backend uses binary_ext="bin", which isn't in the upstream hardcoded allowlist ("cubin", "hsaco", "json"), causing a KeyError("Unknown key: 'bin'").
3. ads_mkl/ops/helion/tests/helion_layernorm_autotune_test.py (new) — Adds three test cases:
- test_autotune_finite_search — FiniteSearch with 3 explicit MTIA configs
- test_autotune_full_search — LFBOTreeSearch with autotune_effort="quick"
- test_pointer_indexing — Verifies pointer indexing works on MTIA
4. ads_mkl/ops/helion/tests/BUCK — Adds the python_unittest_athena target for the new test.
## Background
there is currently no test that combines layernorm autotuning via FiniteSearch on MTIA. Here's why:
What exists today
1. FiniteSearch tests (helion/test/test_autotuner.py) -- only use simple add/multiply kernels, no layernorm, no MTIA.
2. Layernorm on MTIA (ads_mkl/ops/helion/) -- bypasses autotuning entirely and uses hardcoded configs:
- layer_norm.py -- get_hardcoded_layernorm_fwd_kernel_mtia() returns a fixed Config(block_sizes=[64], indexing="block_ptr", pid_type="flat")
- layer_norm.py -- get_hardcoded_layernorm_bwd_kernel_mtia() similarly hardcoded
- The test (tests/helion_layernorm_test.py) runs on MTIA Athena but always hits these hardcoded paths.
3. MTIA tunable tests (helion/test/fb/test_mtia_tunables.py) -- test cb_multiplier_strategy / dual_core_strategy with autotune_effort="none", using simple kernels.
The gap: no test exercises the combination of:
- A layernorm kernel
- FiniteSearch (or any real autotuning)
- MTIA hardware/device
FiniteSearch did not work on MTIA. The call chain was:
1. kernel.autotune(args, force=False)
2. -> Backend.autotune() -> creates FiniteSearch
3. -> FiniteSearch wraps in LocalAutotuneCache (via autotuner_fn)
4. -> LocalAutotuneCache.__init__() calls _generate_key()
5. -> AssertionError -- no MTIA branch, runtime_name is None
## Revisions
merged with:
- D99065250, support autotune via FiniteSearch
- D99066221, support full autotuner via LFBOTreeSearch
Differential Revision: D99064834
|
@Hamlin-Li has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99064834. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Motivation
Enables Helion autotuning (both FiniteSearch and LFBOTreeSearch) for layernorm kernels on MTIA. Previously, autotuning was completely broken on MTIA — even FiniteSearch would crash immediately.
Change Summary
Three changes across 4 files:
- test_autotune_finite_search — FiniteSearch with 3 explicit MTIA configs
- test_autotune_full_search — LFBOTreeSearch with autotune_effort="quick"
- test_pointer_indexing — Verifies pointer indexing works on MTIA
Background
there is currently no test that combines layernorm autotuning via FiniteSearch on MTIA. Here's why:
What exists today
- layer_norm.py -- get_hardcoded_layernorm_fwd_kernel_mtia() returns a fixed Config(block_sizes=[64], indexing="block_ptr", pid_type="flat")
- layer_norm.py -- get_hardcoded_layernorm_bwd_kernel_mtia() similarly hardcoded
- The test (tests/helion_layernorm_test.py) runs on MTIA Athena but always hits these hardcoded paths.
The gap: no test exercises the combination of:
FiniteSearch did not work on MTIA. The call chain was:
Revisions
merged with:
Differential Revision: D99064834