Skip to content

[Perf] Optimize hot path in runtime: Config hashing and cache key gen… - #10205

Closed
yinli-systems wants to merge 1 commit into
triton-lang:mainfrom
yinli-systems:perf/hot-path-optimization
Closed

yinli-systems wants to merge 1 commit into
triton-lang:mainfrom
yinli-systems:perf/hot-path-optimization

Conversation

@yinli-systems

Copy link
Copy Markdown
Contributor

[Perf] Optimize runtime hot paths: Config hashing and cache key generation

Description

This PR optimizes several Python-level hot paths in the Triton runtime to reduce kernel launch latency and autotuning overhead.

Key Changes:

  1. triton.runtime.autotuner.Config Optimization:

    • Pre-calculates and caches the all_kwargs dictionary and the object's hash during __init__.
    • Avoids redundant dictionary merges and string conversions during frequent hashing/equality checks in Autotuner.
    • Benchmark Results: ~6x speedup in __hash__ and ~10x speedup in __eq__.
  2. Autotuner.run Overhead Reduction:

    • Eliminated redundant intermediate dictionary creations (all_args, _args) during cache key generation.
    • Directly performs lookups in nargs and kwargs.
  3. make_so_cache_key Efficiency:

    • Replaced O(N^2) iterative f-string concatenation with a single "-".join() call (O(N)).
    • Simplified signature value processing.

Performance Impact

Isolated benchmarks show significant reduction in Python overhead for operations that are executed on every kernel launch or during exhaustive autotuning cycles.

Verification Results

  • Functional parity confirmed: Hashing and equality logic remain consistent with original intentions.
  • Performance verified via timeit benchmarks (100k iterations).

@yinli-systems
yinli-systems requested a review from ptillet as a code owner May 2, 2026 10:49

@peterbell10 peterbell10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you share the benchmark you used? I'm sceptical that Config.eq is a limiting factor for autotuning compared to benchmarking the actual kernels. Also I can't see where make_so_cache_key comes into this. It seems to only be used in a test at the moment.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants