Commit Graph

5 Commits

Author SHA1 Message Date
Cao Ying 0a9bf1e40a
[Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764)
Closes #1763

## Summary

- Remove dead helpers, redundant elementwise benchmark drivers,
decorative banners, and stale compatibility aliases.
- Consolidate duplicated tests and private benchmark wrappers onto
shared parametrized fixtures and `ManifestBenchmark`.
- Merge fragmented workload, reduction-op, MHC, and normalization
benchmark modules; retarget imports and manifest source paths.
- Preserve canonical runtime behavior while reducing the repository by
roughly 4.3k net lines.

## Test plan

- [x] pre-commit passed
- [x] `python scripts/validate_manifest.py --strict` passed
- [x] Repository-wide pytest collection completed: 5,178 tests, 0
collection errors
- [x] Touched test and benchmark modules collect cleanly

---------

Co-authored-by: Ibuki 🍃 — a wind born from GPTs <Ibuki-wind@users.noreply.github.com>
2026-07-26 12:59:48 +08:00
stelladuyx 55fc21c92b
[Fix][TileLang] Fix autotune do_not_specialize for mamba, softmax, logsumexp kernels under TileLang 0.1.11 (#1627)
## Summary

Fixes autotune failures under TileLang 0.1.11 for three kernel families
that were not covered by PR #1619.

### Root cause

TileLang 0.1.11 changed its autotuner: when
`autotuned_kernel_fn(**initial_kwargs)` is called with the tunable JIT
parameters already bound, it records those params in the cache key and —
on a cache hit — treats them as "already tuned," skipping the
benchmarking sweep entirely and returning `config=None`.

PR #1619 added `_call_autotuned_kernel()` to seed required JIT params
(fixing the `TypeError: missing N required positional arguments`), but
this inadvertently triggered the new 0.1.11 skip behavior, causing:
- `SSDStatePassingFwdKernel` / `SSDChunkScanFwdKernel` /
`SSDDecodeKernel`: `Best config: None`
- `SoftmaxKernel` / `LogSumExpKernel`: `TypeError: '<' not supported
between instances of 'NoneType' and 'float'`

### Fix

Pass `do_not_specialize=tunable_params` to TileLang's `autotune()`
decorator. This tells 0.1.11 to exclude those parameter names from the
cache key, so the seeded initial values no longer trigger the skip path
— the full benchmarking sweep runs as expected.

## Changes

- **`tileops/kernels/kernel_base.py`** (`Kernel.autotune()`): extract
tunable param names from the JIT signature and pass as
`do_not_specialize`. Fixes `SSDStatePassingFwdKernel`,
`SSDChunkScanFwdKernel`, `SSDDecodeKernel`, and any future kernel that
uses the base `autotune()`.

- **`tileops/kernels/reduction/softmax.py`**
(`SoftmaxKernel.autotune()`): same pattern for the custom per-tile_n
autotune loop.

- **`tileops/kernels/reduction/logsumexp.py`**
(`LogSumExpKernel.autotune()`): same pattern for the custom per-tile_n
autotune loop.

## Validation

Tested against real TileLang 0.1.11 (`0.1.11+cuda.gitcd37ed5f`) in
`flashmlaenv`:

**Mamba kernels** — all run full sweeps and return valid configs:
- `SSDStatePassingFwdKernel` → `{'block_d': 64, 'threads': 128,
'vectorize': False}`
- `SSDChunkScanFwdKernel` → `{'block_l': 64, 'block_p': 64, 'block_n':
64, 'block_s': 64, 'threads': 128}`
- `SSDDecodeKernel` → `{'block_p': 4, 'block_n': 32, 'threads': 128}`

**Softmax/logsumexp** — `tests/ops/test_softmax.py`: **135 passed**
(previously 3 failed with `TypeError`)

**Autotune binding unit tests** —
`tests/kernels/test_kernel_autotune_binding.py`: **3 passed**

**deepseek_dsa_decode** —
`tests/ops/attention/test_deepseek_dsa_decode.py`: **1 passed**

**Ruff** — all PR #1619 validation files pass cleanly.
2026-06-26 20:34:12 +08:00
Ang Gao 4ec4646da1
[Fix][TileLang] seed autotune JIT parameters (#1619)
## Summary

Fixes #1613.

TileLang 0.1.11 validates/binds autotuned JIT signatures before
candidate configs are applied. Several TileOPs kernels expose tunable
JIT parameters such as `block_m`, `block_n`, and `bdim` as required
arguments, so calling the autotuned wrapper with no kwargs can fail
before autotuning starts.

This seeds the autotuned wrapper call with bindable config values while
preserving the existing autotune search space.

## Changes

- Add shared `Kernel._call_autotuned_kernel()` /
`_autotune_initial_kwargs()` helpers.
- Seed base `Kernel.autotune()` with `default_config`, filtered to the
JIT signature.
- Support common JIT parameter aliases such as `threads_arg` and
`npt_arg`.
- Update custom autotune overrides that previously called autotuned
wrappers with no kwargs:
  - `SoftmaxKernel`
  - `LogSumExpKernel`
  - `SparseMlaKernel`
  - `FP8LightingIndexerKernel`
  - DeltaNet / GatedDeltaNet sub-kernel autotune paths
- Add unit coverage for required tunable binding, signature filtering,
and alias mapping.

## Validation

- `python3 -m pytest -q tests/kernels/test_kernel_autotune_binding.py`
- `python3 -m ruff check tileops/kernels/kernel_base.py
tileops/kernels/reduction/softmax.py
tileops/kernels/reduction/logsumexp.py
tileops/kernels/attention/deepseek_dsa_decode.py
tileops/kernels/fp8_lighting_indexer.py
tileops/kernels/deltanet/deltanet_fwd.py
tileops/kernels/deltanet/deltanet_bwd.py
tileops/kernels/gated_deltanet/gated_deltanet_fwd.py
tests/kernels/test_kernel_autotune_binding.py`
- `python3 -m compileall -q ...` on changed Python files
- commit hooks / pre-commit checks

Note: local environment has TileLang 0.1.9, so the regression test mocks
the TileLang 0.1.11-style binding requirement instead of running the
exact 0.1.11 autotuner.
2026-06-26 14:47:08 +08:00
stelladuyx 63f30226d7
[Bench][Mamba] Fix ssd_state_passing baseline dtype and autotune stability (#1524)
## Summary

Two fixes to make `test_ssd_state_passing_fwd_bench` produce stable,
apples-to-apples numbers.

## Change 1 — `benchmarks/ops/bench_mamba.py`

### out_dtype=torch.float32 on Triton baseline

TileOPs always outputs `float32`. Without this fix, the Triton baseline
defaults to `out_dtype=states.dtype` (fp16), writing half as many bytes.
This makes TileOPs appear artificially fast on write-bandwidth-bound
shapes.

### Triton autotuner pre-warm

`@triton.autotune` runs all 6 `BLOCK_SIZE` candidates on the first call.
In a fresh nightly process, this fires inside `bench_kernel`'s first
CUPTI active step, polluting the sum with 5 extra kernel launches. The
result is inflated and non-reproducible.

**Nightly evidence:** N108 showed 10/20 Triton configs with anomalous
values (e.g. 0.1878ms, 0.1985ms = 6 candidates × ~0.03ms each). N109
happened to have a warm cache and showed correct 0.013ms values for the
same configs.

Fix: call `mamba_fwd(); torch.cuda.synchronize()` once before
`bm.profile(mamba_fwd)`.

## Change 2 — `tileops/kernels/kernel_base.py`

### autotune warmup 10→25, rep 10→50

With `rep=10` the autotuner measured each candidate with 10 CUPTI
samples. For 2–20µs kernels this produces ~50% measurement noise, making
the winning config non-deterministic across runs.

**Nightly evidence:** longctx shapes in `SSDStatePassingFwdOp` flipped
between configs across consecutive nightly runs, causing 3–10x latency
swings (e.g. 0.2093ms vs 0.0753ms for `longctx-370m-32k`). With `rep=50`
the same config is selected consistently.

This affects **all kernels using `tune=True`**, not just
ssd_state_passing.

## Testing

- 20/20 `test_ssd_state_passing_fwd_bench` pass
- 5 consecutive runs: 20/20 stable within ±2% (verified on H200 at 1830
MHz)
- Nightly Triton baseline: 19/20 stable (1 remaining case is GPU clock
noise at ~3µs floor)
2026-05-23 19:32:37 +08:00
Cao Ying bdbd7a8324
[Refactor] Rename base modules to <module>_base.py convention (#950)
## Summary

Unify base module file naming to `<module>_base.py` convention across
four modules:

- `workloads/base.py` -> `workloads/workload_base.py`
- `tileops/ops/op.py` -> `tileops/ops/op_base.py`
- `tileops/kernels/kernel.py` -> `tileops/kernels/kernel_base.py`
- `benchmarks/benchmark.py` -> `benchmarks/benchmark_base.py`

All imports, string references, and doc paths updated. No logic changes
— pure rename + import propagation.

Closes #947

## Test plan

- [x] **AC-1**: All four files renamed to <module>_base.py -- pass
- [x] **AC-2**: All imports updated, no broken references -- pass
- [x] **AC-3**: docs/testing.md path references updated -- pass
- [x] **AC-4**: Pre-commit and existing tests pass -- pass

**Test results**: 2368/2368 tests passed, 0 failed

---------

Co-authored-by: Ibuki 🍃 — a wind born from Claude Opus <Ibuki-wind@users.noreply.github.com>
2026-04-13 18:13:32 +08:00