kernel-fun 0.2.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,347 @@
1
+ Metadata-Version: 2.5
2
+ Name: kernel-fun
3
+ Version: 0.2.0.dev1
4
+ Summary: CuTe/Triton kernels for linear-attention ops (KDA chunk kernel, KDA short conv), as drop-in replacements for flash-linear-attention, on Blackwell
5
+ Project-URL: Source, https://github.com/allenai/kernel-fun
6
+ Project-URL: Research ladder, https://github.com/allenai/kernel-fun-dev
7
+ Author: Allen Institute for AI
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ License-File: NOTICE
11
+ License-File: THIRD_PARTY_NOTICES.md
12
+ Keywords: blackwell,cuda,cute,cutlass,flash-linear-attention,kda,linear-attention,triton
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: GPU :: NVIDIA CUDA :: 13
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: fla-core<0.6,>=0.5.2
24
+ Requires-Dist: torch>=2.7
25
+ Requires-Dist: triton>=3.3
26
+ Provides-Extra: cu12
27
+ Requires-Dist: cuda-python<13,>=12.8; extra == 'cu12'
28
+ Requires-Dist: nvidia-cutlass-dsl>=4.2.1; extra == 'cu12'
29
+ Provides-Extra: cu13
30
+ Requires-Dist: cuda-python>=13; extra == 'cu13'
31
+ Requires-Dist: nvidia-cutlass-dsl[cu13]>=4.4; extra == 'cu13'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # kernel-fun
35
+
36
+ > **Experimental, in development.** These kernels have only been tested on B300 GPUs, for
37
+ > the specific model configurations our training runs use. They exist to make those runs
38
+ > faster and are not tested for general use — outside that hardware and those shapes, treat
39
+ > both the correctness and the speed as unknown.
40
+
41
+ Drop-in replacements for flash-linear-attention's linear-attention ops, on Blackwell.
42
+
43
+ ```python
44
+ from kernel_fun.kda import chunk_kda # instead of: from fla.ops.kda import chunk_kda
45
+ from kernel_fun.cconv import causal_conv1d # instead of: from fla.modules.convolution import causal_conv1d
46
+ ```
47
+
48
+ Same signature, same returns. Any call this package does not implement — wrong
49
+ architecture, wrong shape, a flag it has never seen, a CUDA graph capture of a shape that
50
+ has not run eagerly yet — is forwarded to fla verbatim. Installing it can change how fast a
51
+ model trains, not what it computes beyond kernel-level rounding.
52
+
53
+ ## Two repos — where to ship changes
54
+
55
+ Split out of the research ladder on 2026-09-09. Two repos, one direction of flow:
56
+
57
+ | | | |
58
+ |---|---|---|
59
+ | **`allenai/kernel-fun-dev`** | the research ladder | `loop/` + `kernels/<family>/ideas/*` — forks, falsifications, recorded bench rows and their `history/`. Nothing there is installable. |
60
+ | **`allenai/kernel-fun`** | this repo | the release artifact: the winning chain only, knobs frozen, dead branches gone. The only thing that builds a wheel, and the only route into OLMo-core. |
61
+
62
+ ```
63
+ kernels/kda/ideas/005-*/ --(tools/vendor.py)--> src/kernel_fun/kda/_kernels/ --(INTEGRATION.md §1)--> OLMo-core
64
+ ladder repo this repo
65
+ ```
66
+
67
+ - **A new kernel idea, or a change to one that is still being falsified:** the ladder. It
68
+ owns the bench, the oracle and the `code_sha` that makes `code_unchanged_since` mean
69
+ something.
70
+ - **A change to what ships** — a released stage, the fallback gate, the call cache, the
71
+ public signatures, the tests, the version: **here**. Never by editing OLMo-core's copy.
72
+ - **A won ladder row that should ship:** `python tools/vendor.py --family <f> --from-commit
73
+ <ladder sha>` here, then its checklist by hand, then a release ("Releasing" below).
74
+ `tools/vendor.py` and `tools/drift.py` need a ladder checkout: they default to
75
+ `../kernel-fun-dev` beside this repo, and take `--ladder PATH` or `$KERNEL_FUN_LADDER`.
76
+ - Version tags (`v0.2.0`, …) live **here**. `_provenance.py`'s `SOURCE_COMMIT` is a sha in
77
+ the *ladder*; `VENDORED_FROM` in OLMo-core is a sha in *this* repo.
78
+
79
+ **On the names — `allenai/kernel-fun` means THIS repo, and only since 2026-09-09.** Before
80
+ that date it was the research ladder, which was renamed `kernel-fun-dev` to hand the name
81
+ over. Three consequences worth knowing:
82
+
83
+ - The pip/import name has been `kernel-fun` / `kernel_fun` throughout and did not change, so
84
+ nothing downstream — OLMo-core's extra, `caleb/cute-kda-vendored`, the wheel — moved
85
+ because of any of this.
86
+ - **`kernel-fun` in anything written before 2026-09-09 means the ladder, not this repo.**
87
+ That includes commit messages, `git log` subjects, lockfiles, `VENDORED_FROM` shas and
88
+ image tags. Check the date before chasing a path or resolving a sha; a pre-split
89
+ `kernel-fun` sha will not exist in this repo's history, which starts at the split.
90
+ - The old redirect is gone. `allenai/kernel-fun` used to redirect to the renamed ladder;
91
+ creating this repo under that name retired the redirect, which is exactly why it was done
92
+ this way. Anything still pointing at that URL for the *ladder* now silently reaches the
93
+ *package* — repoint it at `kernel-fun-dev`. A Beaker image named `kernel-fun-<date>` is
94
+ the ladder's image and deliberately keeps that name (its `scripts/image.sh` explains why).
95
+
96
+ ## Status and numbers
97
+
98
+ | family | status | production shape, B300 |
99
+ |---|---|---|
100
+ | `kda` | shipping | fwd+bwd **23.74 ms vs fla 36.56 = 1.540x** (gate + q/k norm in-op; B16 T8192 H=HV16 K128 V256) |
101
+ | `cconv` | shipping | isolated bwd **0.344 ms vs fla 1.597 = 4.65x**, fwd 0.190 vs 0.307 = 1.62x (B16 T8192 D2048 W4) |
102
+ | `gdn`, `gnorm` | to follow | — |
103
+
104
+ The kda numbers, measured 2026-09-02 on holmes-cs-aus-515 (the ladder's kda/005 record 001):
105
+
106
+ | row | fla | kernel-fun | |
107
+ |---|---|---|---|
108
+ | fwd+bwd, gate and norm in-op (the production call) | 36.56 ms | 23.74 ms | **1.540x** |
109
+ | fwd+bwd, pre-computed gate | 34.90 ms | 21.80 ms | 1.601x |
110
+ | fwd only | 7.50 ms | 5.95 ms | 1.260x |
111
+ | fwd+bwd at B=8 (the 1.4b ladder's real microbatch) | 17.80 ms | 11.30 ms | 1.575x |
112
+
113
+ (The previous release quoted 1.545x on the production row from a different node and day;
114
+ the fla baseline moved more than our chain did. Same-run, the transposed wy stage this
115
+ release adds is worth +0.03x on every prod row over the previous chain.)
116
+
117
+ The cconv numbers, measured 2026-09-01 on B300 (the ladder's cconv/001 record 002), one
118
+ call, isolated with CUDA events — the number a training step feels, since the bench's
119
+ fwd+bwd rows at this size are pinned by the harness's own per-iteration floor:
120
+
121
+ | call (B=16, T=8192, W=4, bf16 x, fp32 weight) | fla | kernel-fun | |
122
+ |---|---|---|---|
123
+ | backward, D=2048 (q/k) — dx and dw, no forward re-run | 1.597 ms | 0.344 ms | **4.65x** |
124
+ | forward, D=2048 (q/k) — silu fused | 0.307 ms | 0.190 ms | 1.62x |
125
+ | D=1024 and D=4096 | | | same ratios |
126
+
127
+ Both families re-measured from the installed package on 2026-09-02 (`tools/prodtime.py`,
128
+ holmes-cs-aus-515, same B300 under a live session so absolute ms run higher than the
129
+ records): kda **1.541x**, cconv fwd 1.62x / 1.63x and isolated bwd **4.25x** (D=2048) /
130
+ **4.60x** (D=4096). The ratios are the records'; the package runs the ladder's kernels.
131
+
132
+ At the 810m step (12 KDA layers, B=8) the trace put the three conv calls at ~50 ms of a
133
+ ~520 ms step; these ratios predict ~13 ms, i.e. roughly **7% of the step** — larger than
134
+ the kda increment in this release. And 1.54x on kda at ~16% of step time predicts about
135
+ +6% tokens/sec. Confirm both on a real step before believing either; an op-level ratio is
136
+ not a training result.
137
+
138
+ ## Install
139
+
140
+ ```
141
+ pip install "kernel-fun @ git+ssh://git@github.com/allenai/kernel-fun.git@v0.2.0"
142
+ ```
143
+
144
+ (Tags live in this repo; before the first one exists, pin a sha instead of `@v0.2.0`. The
145
+ URL no longer carries `#subdirectory=packages/kernel-fun` — that was the path inside the
146
+ ladder repo, before the 2026-09-09 split.)
147
+
148
+ The base install declares torch, triton and `fla-core` only, with loose floors, so it never
149
+ replaces the torch/triton a training image was built against. The CuTe DSL and cuda-python
150
+ are **not** dependencies: they ride in with the training image, and when they are missing
151
+ the kda family logs a reason and runs fla. An environment that needs them installed picks
152
+ the extra for its CUDA major — the CuTe DSL ships separate CUDA 12 and CUDA 13 library
153
+ wheels, and the bare `nvidia-cutlass-dsl` requirement is the CUDA 12 one:
154
+
155
+ ```
156
+ pip install "kernel-fun[cu13] @ git+ssh://..." # CUDA 13 torch (the production image)
157
+ pip install "kernel-fun[cu12] @ git+ssh://..." # a cu128 torch; untested since the image moved
158
+ ```
159
+
160
+ **Tested against** — the only stack these kernels have run on. Everything else is where the
161
+ version floors say it should work, not where anyone has checked:
162
+
163
+ | | |
164
+ |---|---|
165
+ | GPU | B300 (sm_103; `arch_ok` admits any sm_10x, so B200 too) |
166
+ | CUDA | 13.0 (torch `2.11.0+cu130`) |
167
+ | torch / triton | 2.11.0 / 3.6.0 |
168
+ | CuTe DSL | `nvidia-cutlass-dsl` 4.6.0.dev0, CUDA 13 libs |
169
+ | flash-linear-attention | 0.5.2 (`fla-core`; `TESTED_FLA` in `_common/compat.py`, warns on anything else) |
170
+ | Python | 3.12 |
171
+
172
+ The cconv family is Triton-only and gated at sm90, so an H100 runs it — at a speed nobody
173
+ has measured.
174
+
175
+ Prefer that over `pip install -e`, which writes a `.pth` pointing back into a checkout and
176
+ reintroduces "which copy am I running".
177
+
178
+ **Inside the kernel-tuning image** the ladder is baked at `/work` but this repo is not, so
179
+ clone it beside the ladder and put its `src/` on the path (`/work` is writable, and the
180
+ image has `openssh-client`):
181
+
182
+ ```sh
183
+ git clone git@github.com:allenai/kernel-fun.git /work/kernel-fun
184
+ export PYTHONPATH=/work:/work/kernel-fun/src
185
+ ```
186
+
187
+ In a session the ladder is `/work` itself — the tools' sibling default would look for
188
+ `/work/kernel-fun-dev`, which does not exist — so `export KERNEL_FUN_LADDER=/work` (or pass
189
+ `--ladder /work`) before running `tools/vendor.py` or `tools/drift.py` there.
190
+
191
+ `torch`, `triton` and `fla-core` are required. The CuTe DSL (`nvidia-cutlass-dsl`) and
192
+ `cuda-python` are deliberately **not** hard requirements: they arrive with the training
193
+ base image, and letting pip resolve them risks swapping that build out. Without them the
194
+ package still imports and still computes correctly — it just falls back to fla everywhere.
195
+ Install the `cute` extra if you need them.
196
+
197
+ ## Using it
198
+
199
+ ```python
200
+ import logging
201
+ import kernel_fun
202
+ from kernel_fun import kda, cconv
203
+
204
+ logging.getLogger("kernel_fun").setLevel(logging.INFO) # one line per process per family
205
+ # `versions()` is logged for you the first time a family engages, from inside the
206
+ # torch.compiler.disable'd entry point. Call it yourself only OUTSIDE a compiled region.
207
+
208
+ kda.warmup(K=128, V=256, HV=16) # compile before step 1, not during it
209
+ cconv.warmup(B=microbatch, T=seq_len, D=(2048, 4096)) # autotune at the REAL B, T, D
210
+
211
+ q, _ = cconv.causal_conv1d(x=w_q(x), weight=conv_w, activation="silu")
212
+ o, ht = kda.chunk_kda(q, k, v, g, beta, A_log=A_log, dt_bias=dt_bias,
213
+ use_qk_l2norm_in_kernel=True, use_gate_in_kernel=True)
214
+ ```
215
+
216
+ `warmup()` matters. Four `cute.compile` calls plus fla's Triton autotuning is tens of
217
+ seconds; paid inside step 1 it looks exactly like a regression — which is what a previous
218
+ port's reported "−3% tokens/sec" turned out to be. It also runs the fla compatibility probe,
219
+ so a version mismatch raises before the run rather than at step 40,000.
220
+
221
+ Both families have an `is_supported(...)` returning `(ok, reason)`. The reason string is
222
+ meant for a training log: a silent fallback reads as a correct 1.00x, and "did the kernels
223
+ actually run?" is the most expensive question a port can leave open. The package logs it
224
+ once per process.
225
+
226
+ ### Supported — kda
227
+
228
+ `chunk_size=64`, `T % 64 == 0`, `K ∈ {64, 128}`, `V % 64 == 0`, bf16/fp16, sm100
229
+ (B200/B300), a grid of at least 256 CTAs (`B * HV * (V//64)`; `KERNEL_FUN_KDA_MIN_CTAS`
230
+ moves that one number and nothing else — see Switches). Under CUDA graph capture the shape must already
231
+ have run eagerly (fwd, and bwd if grads are needed): compile and autotune cannot be
232
+ captured, but a warm shape captures and replays bit-identically, on any stream. Within that:
233
+ `use_qk_l2norm_in_kernel`, `use_gate_in_kernel` (with `A_log`/`dt_bias`, fused into the
234
+ cumsum), `use_beta_sigmoid_in_kernel`, `allow_neg_eigval`, GVA (`HV > H`),
235
+ `initial_state=None`, `output_final_state=False`, fp32 `beta` (cast to q's dtype — the one
236
+ numerics deviation, covered by a test).
237
+
238
+ Stages also fall back individually below their own floors — most notably the MMA intra
239
+ backward, which needs `B * (T/64) * HV >= 1024` and otherwise uses a Triton kernel that is
240
+ faster at that size. `is_supported` reports the chain-level gate; the per-stage ones are
241
+ performance choices, and the launch-witness test is what pins them down. They do not
242
+ follow the chain-level gate down: at a configured 128 CTAs the b1 scan and dhu backwards
243
+ are still fla's, and what the opt-in buys is the forward scan, the transposed WY backward
244
+ and the intra backward.
245
+
246
+ Everything else goes to fla: `cu_seqlens` and packed documents, context parallel,
247
+ `safe_gate`, `state_v_first`, `disable_recompute`, `return_intermediate_states`,
248
+ `chunk_size=32`, and any argument the package does not recognize — a new fla flag degrades
249
+ to fla rather than being silently ignored.
250
+
251
+ ### Supported — cconv
252
+
253
+ Exactly the KDA layer's mainline call: `activation` silu/swish, no bias, no residual, no
254
+ initial/final state, no `cu_seqlens`, `backend="triton"`, `W <= 4`, bf16/fp16 `x` of shape
255
+ `[B, T, D]` with any strides (production hands over a projection output and fla does not
256
+ force it contiguous either), a `[D, W]` weight in any float dtype, `dw` back in the weight's
257
+ dtype. Both kernels are Triton, so the arch floor is **sm90**, not sm100 — but they have
258
+ only been *timed* on B300; an H100 computes the same numbers at an unmeasured speed.
259
+
260
+ Everything else — bias, residual, conv state, packed documents, `activation=None`, an
261
+ explicit `backend="cuda"`/`"mix"`, any unrecognized flag — goes to fla verbatim.
262
+
263
+ ### Switches
264
+
265
+ | variable | effect |
266
+ |---|---|
267
+ | `KERNEL_FUN_DISABLE=1` | forward everything to fla. The 2am switch. |
268
+ | `KERNEL_FUN_KDA_DISABLE=1`, `KERNEL_FUN_CCONV_DISABLE=1` | same, one family |
269
+ | `KERNEL_FUN_DEBUG=1` | log the fallback reason |
270
+ | `KERNEL_FUN_FALLBACK=1` | downgrade an fla-drift error to a warning + fallback |
271
+ | `KERNEL_FUN_KDA_MIN_CTAS=<n>` | move the kda chain-level CTA floor off 256. Per workload, per measurement |
272
+
273
+ All read per call, and a value that is not a positive integer is a warning and the default,
274
+ not an exception — a launcher typo should cost throughput, not the run. There are
275
+ deliberately no per-stage knobs: `MIN_CTAS` is the dispatch gate, not a stage, and bisecting
276
+ a stage means reaching for the research ladder, which keeps all of them.
277
+
278
+ `KERNEL_FUN_KDA_MIN_CTAS` is the one knob that can make things *slower*: 256 is where the
279
+ CuTe scans stop underfilling the GPU on the shapes measured so far, and lowering it is a
280
+ claim about one model on one box. The small OLMoE3 candidate (B4/T8192/HV8/K128/V256 — 128
281
+ CTAs) is the shape it exists for. Time it against the default before believing it, and give
282
+ `warmup()` the same environment the run will have: it warms one grid per floor in play.
283
+
284
+ ## How it relates to the research repo
285
+
286
+ This package is a **release artifact**, not a mirror — see "Two repos" above for which
287
+ change goes where. The ladder (`allenai/kernel-fun-dev`, `kernels/<family>/ideas/*`) stays free
288
+ to fork and falsify; when an idea wins a recorded bench row, `tools/vendor.py` copies that
289
+ commit's kernels here and prints a checklist of the edits it cannot do (freeze the env
290
+ knobs, delete the branches they selected, unify the call cache). `_provenance.py` records
291
+ which ladder commit each family came from — its paths are ladder-relative, which is why
292
+ `tools/drift.py` needs a ladder checkout to report what has moved since. The real check that
293
+ the two agree is the parity test, not a hash.
294
+
295
+ For kda that is ~10 modules of the ladder's ~13k lines: the forward scan+readout and four of
296
+ the backward's seven stages. The rest of the chain is fla's own kernels at fla's own stage
297
+ boundaries — which is what makes a stage-by-stage comparison meaningful, and why the tests
298
+ can hold to fla's own tolerances. For cconv it is one module: both directions, whole.
299
+
300
+ ## Releasing
301
+
302
+ Published to PyPI as [`kernel-fun`](https://pypi.org/project/kernel-fun/) by
303
+ `.github/workflows/release.yml`. Auth is **Trusted Publishing**: GitHub mints a short-lived
304
+ OIDC token for the job, PyPI checks four claims against a publisher entry it holds, and
305
+ trades it for an upload token good for minutes. No API token exists in this repo, in GitHub
306
+ secrets, or on anyone's laptop. The four claims are owner `allenai`, repository
307
+ `kernel-fun`, workflow filename `release.yml`, and the environment — so **renaming that
308
+ workflow file, or an environment, breaks publishing** until the entry on PyPI is edited to
309
+ match. That is the one non-obvious way this setup fails.
310
+
311
+ | index | trigger | environment |
312
+ |---|---|---|
313
+ | TestPyPI | Actions → Release → Run workflow, target `testpypi` | `testpypi`, ungated |
314
+ | PyPI | push a `v*` tag | `pypi`, manual approval, `v*` tags only |
315
+
316
+ Cutting a release:
317
+
318
+ ```sh
319
+ # 1. bump __version__ in src/kernel_fun/__init__.py (the ONLY place it lives)
320
+ # 2. rehearse on TestPyPI first -- it is the only way to exercise the real upload path
321
+ gh workflow run Release -f target=testpypi
322
+ # 3. tag; the build refuses a tag that disagrees with __version__, then waits for approval
323
+ git tag v0.2.0 && git push origin v0.2.0
324
+ ```
325
+
326
+ Two things here cannot be undone, which is what the approval gate and the tag check are
327
+ for: **a version number is burnable once** — deleting `0.2.0` from PyPI does not let you
328
+ re-upload it, so a bad release is fixed by shipping `0.2.1`, never by replacing it — and a
329
+ release with a tag that disagrees with the metadata inside the wheel cannot be corrected in
330
+ place. Installing from TestPyPI needs both indexes, since torch and `fla-core` are not
331
+ mirrored there:
332
+
333
+ ```sh
334
+ pip install --index-url https://test.pypi.org/simple/ \
335
+ --extra-index-url https://pypi.org/simple/ --pre kernel-fun
336
+ ```
337
+
338
+ ## Licensing
339
+
340
+ Apache-2.0 (`LICENSE`), matching the research ladder and Ai2's default. Three of the Triton
341
+ modules are derived from flash-linear-attention, which is MIT: `NOTICE` names them module by
342
+ module and reproduces the MIT terms, which keep applying to those portions.
343
+ `THIRD_PARTY_NOTICES.md` covers the rest of the dependency set — torch (BSD-3-Clause),
344
+ triton (MIT), and the NVIDIA-licensed CuTe DSL and cuda-python that arrive with the base
345
+ image — none of which are vendored here. All three files ship inside the wheel —
346
+ `license-files` in `pyproject.toml` puts them there, which is what makes the attribution
347
+ travel with an install rather than living only in this checkout.
@@ -0,0 +1,30 @@
1
+ kernel_fun/__init__.py,sha256=chmRNG1k-iGrS_YQbvr0fONBC4bQwcnQZSYmj7dQWtQ,2792
2
+ kernel_fun/_common/__init__.py,sha256=S0FepNya2JLkmnrWJFAdgd01HycOXUFCRRRjblXR6qg,586
3
+ kernel_fun/_common/cache.py,sha256=qeD1PTs7tV2QCT4fNzhG8-Ph90Zd8yo4MgYi9hbt730,4776
4
+ kernel_fun/_common/compat.py,sha256=R1ejTGzOT2BmReDBv0DlGBV-sUekq0kdMLkxEl_Frz0,6651
5
+ kernel_fun/_common/support.py,sha256=iMH590_5ye7eLgB4nQ0owsDvHj9GjAIw0KZ8QwgIGEM,11301
6
+ kernel_fun/cconv/__init__.py,sha256=HLe5soJQ8gZOP8ABi6mGuJ8BazFdYBE5__ULrc0XWZc,1147
7
+ kernel_fun/cconv/_provenance.py,sha256=UhQudpkvSYIdh_8u9LBTtq5V5v7w76K3m1JGZZJqiQI,443
8
+ kernel_fun/cconv/ops.py,sha256=BDY7dXGhT31m2Zl62ZQt2SdFeyDwcPrHcoo0p9L68Vg,10914
9
+ kernel_fun/cconv/_kernels/__init__.py,sha256=-i4zmoLZ2H_qTjSyRjws2AUzfymqbJIWn2YsYJcnR6w,323
10
+ kernel_fun/cconv/_kernels/strip.py,sha256=_I06ovppBBb9o4XW5uJ7hjq7j9oFbhun6ZaFDShrZlY,18871
11
+ kernel_fun/kda/__init__.py,sha256=Nb6c8xwEG23TInk8GHV7sSldEHSKTbsn01i-hA3oCSE,1020
12
+ kernel_fun/kda/_provenance.py,sha256=P6oZJ2tCp098bbLC_gxJ-3xsTnyT6Ym1a-Qqmu1UVIs,1311
13
+ kernel_fun/kda/autograd.py,sha256=tMYl9hI6ensTpOsHjruvv_Ue-UHmdJow4z-hfibVQVw,4515
14
+ kernel_fun/kda/chain.py,sha256=UL92wkhnkr8mL9NqCETErYgY0WuLai54udT9PW5D4FI,6840
15
+ kernel_fun/kda/ops.py,sha256=aE1XSLBoux90bQPlCqzgPQIA5vqHrUyxcAws08_3WWw,15132
16
+ kernel_fun/kda/_kernels/__init__.py,sha256=PKTAudnL6NRxSockkdHxf__spLwTcjZz8ItuP28uWAU,406
17
+ kernel_fun/kda/_kernels/bwd_dhu.py,sha256=7qaRWOREdGD4NUyZMxtUcMfKYj6XfRrrYp3baoR59MY,46809
18
+ kernel_fun/kda/_kernels/bwd_intra.py,sha256=JGMUktLd-cnawMjsTQNiaUaftaFiIHrIbOYhCjGhtU8,51875
19
+ kernel_fun/kda/_kernels/bwd_intra_triton.py,sha256=QXdxFOTgJIFa7N583G8B3vLN2m83WE0K1CAKjUevWrE,14431
20
+ kernel_fun/kda/_kernels/bwd_scan.py,sha256=VCV0Fj5_RKDNptJzrHUMkqFRHgKPROiZLw1ZcnpEotI,53349
21
+ kernel_fun/kda/_kernels/bwd_wy.py,sha256=1zqGMW6PMjRUbTRbd2g23VKjWX600OuowMOIQD4KgVg,11888
22
+ kernel_fun/kda/_kernels/bwd_wy_t.py,sha256=NljLGhtrJqxuvYyyL33Rox3omiPrIROOajBuHFU5ndM,14917
23
+ kernel_fun/kda/_kernels/fwd_intra_triton.py,sha256=0PfJXD1A91r9Z5TOzzNwJyWOuqDRMg30iPLK8-KbNFA,4075
24
+ kernel_fun/kda/_kernels/fwd_state.py,sha256=DpWml05Di7SIDj0KbIct60jX9VyQfws2lTPbEnOHVX4,52002
25
+ kernel_fun-0.2.0.dev1.dist-info/METADATA,sha256=DlRvgF9acQfoKiM37LmwOg4MpBgk5H8XCGf4HzFnIQI,19027
26
+ kernel_fun-0.2.0.dev1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
27
+ kernel_fun-0.2.0.dev1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ kernel_fun-0.2.0.dev1.dist-info/licenses/NOTICE,sha256=mcj7to1IuhpyCfb6vdaMwcvO4oanGE_GLYaBKC_dJ60,2907
29
+ kernel_fun-0.2.0.dev1.dist-info/licenses/THIRD_PARTY_NOTICES.md,sha256=QnB8qE_gogmRda_d5KHZyh0ZFRj3BFeYti7iwoC8AM4,7992
30
+ kernel_fun-0.2.0.dev1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,60 @@
1
+ kernel-fun
2
+ Copyright (c) 2026 The Allen Institute for Artificial Intelligence
3
+
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ This product includes software derived from flash-linear-attention
7
+ (https://github.com/fla-org/flash-linear-attention), Copyright (c) 2023-2026
8
+ Songlin Yang, Yu Zhang, Zhiyuan Li, licensed under the MIT License. The MIT
9
+ license text is reproduced at the end of this file and continues to apply to
10
+ those portions.
11
+
12
+ Specifically, the following modules are restructured ports of fla kernels and
13
+ carry that lineage:
14
+
15
+ src/kernel_fun/kda/_kernels/bwd_wy.py
16
+ a full-K restructure of fla.ops.kda.chunk_bwd's fused wy_dqkg kernel
17
+ src/kernel_fun/kda/_kernels/bwd_intra_triton.py
18
+ a restructure of fla.ops.kda.chunk_intra's bwd_intra kernel
19
+ src/kernel_fun/kda/_kernels/fwd_intra_triton.py
20
+ a zero-fill companion to fla.ops.kda's forward intra/solve kernels,
21
+ written against their storage contract
22
+
23
+ In addition, this package calls flash-linear-attention at runtime for the
24
+ stages it does not replace, and delegates to it entirely for any call it does
25
+ not support. It is not a fork: fla is a dependency.
26
+
27
+ The CuTe kernels (fwd_state.py, bwd_scan.py, bwd_dhu.py, bwd_intra.py) are
28
+ original work, though they implement fla's algorithms at fla's stage
29
+ boundaries so that results remain comparable stage by stage.
30
+
31
+ Attribution for the other projects this package depends on at runtime (torch,
32
+ triton, and the optional NVIDIA CuTe DSL / cuda-python extras) is in
33
+ THIRD_PARTY_NOTICES.md. None of them are vendored here; they are installed
34
+ separately by pip.
35
+
36
+ --------------------------------------------------------------------------------
37
+ flash-linear-attention — MIT License
38
+ --------------------------------------------------------------------------------
39
+
40
+ MIT License
41
+
42
+ Copyright (c) 2023-2026 Songlin Yang, Yu Zhang, Zhiyuan Li
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining a copy
45
+ of this software and associated documentation files (the "Software"), to deal
46
+ in the Software without restriction, including without limitation the rights
47
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
48
+ copies of the Software, and to permit persons to whom the Software is
49
+ furnished to do so, subject to the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be included in all
52
+ copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
60
+ SOFTWARE.