You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supersedes #612 (discussion-only) with an actionable plan, and feeds RFC #749 (downstream libraries — the PoC target is Tri Dao's quack — expect a usable tuning path to consume FlyDSL kernels). #612 established that FlyDSL has an autotune implementation but nothing actually uses it.
disk cache under FLYDSL_AUTOTUNE_CACHE_DIR / ~/.flydsl/autotune,
a _make_key (key args' shapes/dtypes), _prune, and the public @autotune decorator (exported from flydsl.__init__).
But a repo-wide search shows no kernel actually uses @autotune — only the definition plus README / CLAUDE / SKILL docs. No dedicated tests, no real adoption. It is effectively dead code today.
Verified by reading source. Two distinct questions are on this table: how to tune a kernel (Triton / quack / aiter / FlyDSL) vs how an application consumes tuned configs (SGLang). SGLang is listed because it's a real downstream FlyDSL consumer and shows what the "offline path" looks like at scale — it is not itself an autotuner, so it's flagged as a consumer view, not ranked against the autotuners. Triton is the template the others (quack, FlyDSL) imitate, so it's the most important one to understand deeply.
filename: E,N,device_name,dtype + triton-version dir
shape/dtype only
Persisted as
*.autotune.json in cache dir
.o + result cache
CSV in repo
JSON keyed by device+shape, committed
best-config JSON
First-run cost
pays search (mitigated by disk cache)
parallel precompile
none at serving
none at serving (lookup)
pays full search
CI guard
unit tests
test_autotuner.py
check_tuned_op_regression.sh
auto-tune.yml
none
Deep-dive: Triton autotune (the design FlyDSL/quack imitate)
Three mechanisms in triton/runtime/autotuner.py that FlyDSL's port currently lacks and that matter most:
restore_value / reset_to_zero — the correctness soul of autotune. Benchmarking runs the same kernel dozens of times to pick the fastest. If the kernel writes its output in place or accumulates, repeated runs corrupt the data and the timing/selection is made on garbage. Triton snapshots and restores the affected tensors around each bench rep. FlyDSL has nothing equivalent — autotuning any in-place kernel (e.g. fused-add rmsnorm) would currently be incorrect.
@heuristics alongside @autotune. Params that can be computed are derived by a heuristic (zero search); only genuinely-uncertain params are searched. Same idea as quack's two-track get_default + exhaustive.
Thorough cache key.triton_key() (compiler version) + backend target hash + fn.cache_key (kernel source) + cache-invalidating env vars + shape/dtype — far more complete than FlyDSL's shape/dtype-only key.
SGLang shows the consumer end: tuned configs are committed as JSON whose filename encodes E, N, device_name, dtype under a triton-version directory; at runtime get_moe_configs looks up by device+shape and falls back to get_default_config on a miss (incl. AMD gfx configs). This is the shape a FlyDSL tuned-config artifact should take if an engine like SGLang is to consume it.
What to borrow (synthesis of best-of-breed)
Two-track configs (quack get_default + exhaustive, == Triton @heuristics + @autotune): heuristic default for zero-search normal runs, exhaustive space only when explicitly autotuning. Avoids FlyDSL's all-or-nothing.
In-place correctness (Triton restore_value/reset_to_zero): required before autotuning any kernel that mutates its inputs/outputs — otherwise tuning picks a config based on corrupted reruns. Prerequisite, not a nice-to-have.
Context
Supersedes #612 (discussion-only) with an actionable plan, and feeds RFC #749 (downstream libraries — the PoC target is Tri Dao's quack — expect a usable tuning path to consume FlyDSL kernels). #612 established that FlyDSL has an autotune implementation but nothing actually uses it.
Current state of FlyDSL autotune (verified)
python/flydsl/autotune.py(296 lines) already provides:Config(constexpr params +waves_per_eu/maxnregcompiler hints),Autotuner(benchmark configs -> pick fastest -> cache),FLYDSL_AUTOTUNE_CACHE_DIR/~/.flydsl/autotune,_make_key(key args' shapes/dtypes),_prune, and the public@autotunedecorator (exported fromflydsl.__init__).@autotune— only the definition plus README / CLAUDE / SKILL docs. No dedicated tests, no real adoption. It is effectively dead code today.Reference comparison: how others do it
Verified by reading source. Two distinct questions are on this table: how to tune a kernel (Triton / quack / aiter / FlyDSL) vs how an application consumes tuned configs (SGLang). SGLang is listed because it's a real downstream FlyDSL consumer and shows what the "offline path" looks like at scale — it is not itself an autotuner, so it's flagged as a consumer view, not ranked against the autotuners. Triton is the template the others (quack, FlyDSL) imitate, so it's the most important one to understand deeply.
python/triton/runtime/autotuner.py(511 ln)quack/autotuner.py(849 ln)csrc/.../*_tune.py+ CSVsbenchmark/.../tuning_fused_moe_triton.py+get_moe_configspython/flydsl/autotune.py(296 ln)@heuristics(compute params, skip search)get_default+ exhaustiveget_default_configfallback when no JSONrestore_value/reset_to_zero(snapshot/restore between bench reps)triton_key()(compiler ver) + backend.hash +fn.cache_key(src) + invalidating env + shape/dtypeE,N,device_name,dtype+ triton-version dir*.autotune.jsonin cache dir.o+ result cachetest_autotuner.pycheck_tuned_op_regression.shauto-tune.ymlDeep-dive: Triton autotune (the design FlyDSL/quack imitate)
Three mechanisms in
triton/runtime/autotuner.pythat FlyDSL's port currently lacks and that matter most:restore_value/reset_to_zero— the correctness soul of autotune. Benchmarking runs the same kernel dozens of times to pick the fastest. If the kernel writes its output in place or accumulates, repeated runs corrupt the data and the timing/selection is made on garbage. Triton snapshots and restores the affected tensors around each bench rep. FlyDSL has nothing equivalent — autotuning any in-place kernel (e.g. fused-add rmsnorm) would currently be incorrect.@heuristicsalongside@autotune. Params that can be computed are derived by a heuristic (zero search); only genuinely-uncertain params are searched. Same idea as quack's two-trackget_default+ exhaustive.triton_key()(compiler version) + backend target hash +fn.cache_key(kernel source) + cache-invalidating env vars + shape/dtype — far more complete than FlyDSL's shape/dtype-only key.SGLang shows the consumer end: tuned configs are committed as JSON whose filename encodes
E, N, device_name, dtypeunder a triton-version directory; at runtimeget_moe_configslooks up by device+shape and falls back toget_default_configon a miss (incl. AMDgfxconfigs). This is the shape a FlyDSL tuned-config artifact should take if an engine like SGLang is to consume it.What to borrow (synthesis of best-of-breed)
get_default+ exhaustive, == Triton@heuristics+@autotune): heuristic default for zero-search normal runs, exhaustive space only when explicitly autotuning. Avoids FlyDSL's all-or-nothing.restore_value/reset_to_zero): required before autotuning any kernel that mutates its inputs/outputs — otherwise tuning picks a config based on corrupted reruns. Prerequisite, not a nice-to-have.@autotuneJIT for dev; add an offline "tune -> emit config -> load at runtime" path, opt-in via env/marker so normal tests don't pay search cost. (Discussion: make autotune a supported and broadly usable tuning path #612 Q3)auto-tune.yml): GPU-free unit tests forConfig/serialization/pruning; opt-in GPU integration test; a tuned-config regression guard.Deliverables
@autotune(+ a committed tuned config for the offline path). Candidates: softmax / rmsnorm for API validation; a GEMM / MoE variant for perf. (Discussion: make autotune a supported and broadly usable tuning path #612 Q2)Refs
python/flydsl/autotune.py; aiteraiter/configs/*_tuned_gemm.csv,aiter/ops/flydsl/gemm_tune/,.github/scripts/check_tuned_op_regression.sh; quackquack/autotuner.py,quack/rmsnorm_config.py,AI/caching_and_parallel_compilation.md,tests/test_autotuner.py. Tritonpython/triton/runtime/autotuner.py(Autotuner,check_disk_cache,restore_value/reset_to_zero,@heuristics). SGLangbenchmark/kernels/fused_moe_triton/tuning_fused_moe_triton.py,srt/layers/moe/.../fused_moe_triton_config.py(get_moe_configs/get_default_config), committed JSON configs keyed byE,N,device_name,dtype,.github/workflows/auto-tune.yml.