Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .agents/skills/_shared/preflight.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ Query the `spyre-kb` MCP server for context relevant to the kernel at hand:
Use KB results to **supplement, not override** the procedure in each skill. If
the KB gives more specific or newer guidance for a pattern, prefer it and note
the discrepancy in your output.

## Check known issues before converting

Lowering and interpreter gaps are tracked as GitHub issues, not just in the KB.
Before converting a kernel, **search the two repos for open issues touching the
descriptor pattern you're about to write** — a known gap changes the approach
(pick a layout that lowers, or mark the site per
[`spyre/gap-handling.md`](spyre/gap-handling.md)) instead of discovering it after
a failed lowering.

- **`torch-spyre/triton`** — compiler / KTIR-lowering gaps.
`gh issue list --repo torch-spyre/triton --search "descriptor <pattern>" --state all`
- **`torch-spyre/ktir-cpu`** — CPU interpreter gaps (what `tests/ktir/` runs
against). Unsupported ops/types surface here, and fixes land often — **check
the pinned rev in `pyproject.toml` against the issue's fix commit**; a stale
pin reproduces already-closed bugs.
15 changes: 12 additions & 3 deletions .agents/skills/td-test/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ accumulates in a different order than the reference), or the KB documents a
precision difference. **f32 outputs should be near-exact** (reductions
accumulate in f32) — keep `1e-5`.

**Single-tile cases are bitwise-identical.** When a row/problem fits one tile
(`size <= BLOCK_SIZE`), there is no reduction-order difference — assert
`atol=0, rtol=0`. A loose tolerance there hides regressions.
**`atol=0` is for bytes the kernel *moved*, `TOL[dtype]` is for numbers it
*computed*.** Reduction order is not the only source of divergence: the original
and the `_td` kernel lower their loads differently (raw pointer + mask vs
descriptor + `where`), so the compiler may contract a multiply-add into an FMA
on one path and not the other — ~1 ULP, elementwise, no reduction involved. So a
single-tile / no-reduction case is *not* automatically bitwise-identical.

- Output the kernel computes arithmetically (any multiply-then-add/sub) → FMA
hazard → use `TOL[dtype]`, even single-tile.
- Output the kernel only copies/passes through untouched → genuinely
bitwise-identical → assert `atol=0, rtol=0`. A loose tolerance there hides
regressions.

### 2. Edge cases

Expand Down
114 changes: 0 additions & 114 deletions kernels/mrope/block_ptr.py

This file was deleted.

26 changes: 26 additions & 0 deletions kernels/mrope/conversion-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# mrope conversion notes

## Tensor-descriptor conversion

- Source: original.py → tensor_descriptor.py (kernel `_mrope_kernel_td`)
- Pointer arithmetic replaced with `tl.make_tensor_descriptor`:
- cos/sin viewed as 3D `[3, num_tokens, half_rd]` (the lead axis is the
t/h/w section); each section row loaded with `desc.load([sec, pid, 0])`.
- q/k viewed as 4D `[num_tokens, heads, 2, half_rd]`; the third axis selects
left/right rotary halves, so descriptor offsets stay block-aligned even
when `rotary_dim < head_size`.
- **Section masks kept (not tail masks).** The t/h/w masks select *which*
section contributes to each lane — value selection, not a boundary. Kept as
`tl.where(mask, row, 0.0)` over the three section rows; sections are disjoint
so the sum reproduces the original merge. Descriptor zero-fill does NOT
replace these.
- Tail masks on q/k dropped: descriptor `shape`'s last dim is `half_rd`, so the
padded tile tail is zero-filled on load and clamped on store. Non-rotary
lanes beyond `rotary_dim` are outside the descriptor shape and remain
untouched, matching the original `arange < rd//2` load/store masks.
- Signature preserved; wrapper dispatches via existing `kernel_fn=` arg.
- 16-byte last dim: descriptor block width is `max(pad_hd // 2, 8)`, so the
last dimension is at least 8 elements (16 bytes for fp16/bf16; larger for
fp32). Descriptor shape may be smaller; out-of-range lanes zero-fill/clamp.
- Scope: supports full and partial rotary (`rotary_dim <= head_size`) for the
same non-interleaved/interleaved section semantics as the original.
175 changes: 0 additions & 175 deletions kernels/mrope/kernel.ktir

This file was deleted.

Loading
Loading