Skip to content

Conversation

@fulvius31
Copy link
Contributor

@fulvius31 fulvius31 commented Nov 3, 2025

Adds a new HELION_AUTOTUNE_CACHE environment variable to allow
users to select the autotuner cache implementation, similar to how
HELION_AUTOTUNER selects the search algorithm.

  • helion/autotuner/__init__.py:

    • Adds a cache_classes dictionary to register available cache
      implementations (LocalAutotuneCache, StrictLocalAutotuneCache).
  • helion/runtime/settings.py:

    • Adds a new string setting, autotune_cache, which defaults
      to "LocalAutotuneCache" and is controlled by the
      HELION_AUTOTUNE_CACHE environment variable.
    • Updates default_autotuner_fn to use this new setting to
      look up and instantiate the correct cache class from
      autotuner.cache_classes.
  • test_autotuner.py:

    • Adds the TestAutotuneCacheSelection test case.
    • Verifies that the default cache is LocalAutotuneCache.
    • Verifies that HELION_AUTOTUNE_CACHE=StrictLocalAutotuneCache
      correctly selects StrictLocalAutotuneCache.
    • Verifies that an invalid cache name raises a ValueError.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2025
Copy link
Contributor

@jansel jansel left a comment

Choose a reason for hiding this comment

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

Perhaps we should make this more generic (similar to settings.autotuner_fn) so that as we add more classes we the config will still work.

Can you add a test?

@fulvius31 fulvius31 changed the title feat(runtime): Add env var to enable StrictLocalAutotuneCache feat(autotuner): Make autotune cache class configurable via env var Nov 4, 2025
@fulvius31
Copy link
Contributor Author

@jansel Thanks for the review!

Let me know if it looks good now.

@fulvius31 fulvius31 requested a review from jansel November 4, 2025 13:59
@fulvius31
Copy link
Contributor Author

@jansel I don't know if the cpu fail is caused by this PR.

I've added a baseline for the other failed test.

@fulvius31
Copy link
Contributor Author

@jansel it looks like the cpu workflow does not install triton for some reason that does not depend on this PR

Adds a new boolean setting, `use_strict_cache`, to `helion.runtime.Settings`,
controlled by the `HELION_USE_STRICT_CACHE` environment variable.

The `default_autotuner_fn` now reads this setting and selects
`StrictLocalAutotuneCache` if set to true, falling back to
`LocalAutotuneCache` otherwise.

This allows users to easily enable stricter cache validation without
needing to write a custom `autotuner_fn`.

Signed-off-by: Alessandro Sangiorgi <asangior@redhat.com>
Adds a new `HELION_AUTOTUNE_CACHE` environment variable to allow
users to select the autotuner cache implementation, similar to how
`HELION_AUTOTUNER` selects the search algorithm.

- `helion/autotuner/__init__.py`:
  - Adds a `cache_classes` dictionary to register available cache
    implementations (LocalAutotuneCache, StrictLocalAutotuneCache).

- `helion/runtime/settings.py`:
  - Adds a new string setting, `autotune_cache`, which defaults
    to "LocalAutotuneCache" and is controlled by the
    `HELION_AUTOTUNE_CACHE` environment variable.
  - Updates `default_autotuner_fn` to use this new setting to
    look up and instantiate the correct cache class from
    `autotuner.cache_classes`.

- `test_autotuner.py`:
  - Adds the `TestAutotuneCacheSelection` test case.
  - Verifies that the default cache is `LocalAutotuneCache`.
  - Verifies that `HELION_AUTOTUNE_CACHE=StrictLocalAutotuneCache`
    correctly selects `StrictLocalAutotuneCache`.
  - Verifies that an invalid cache name raises a `ValueError`.

Signed-off-by: Alessandro Sangiorgi <asangior@redhat.com>
Signed-off-by: Alessandro Sangiorgi <asangior@redhat.com>
@fulvius31
Copy link
Contributor Author

@jansel I've fixed the issue with the cpu environment and tested locally

@oulgen oulgen merged commit f472e32 into pytorch:main Nov 6, 2025
14 of 15 checks passed
@fulvius31 fulvius31 deleted the strict-cache branch November 10, 2025 18:03
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.

3 participants