Skip to content

dsv41 metal: CSA2 attention for decode and prompt rows - #1709

Merged
ashhart merged 3 commits into
ashhart:mainfrom
gilby:dsv41-metal-pr/05-csa2-attention
Nov 2, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
gilby:dsv41-metal-pr/05-csa2-attention

Conversation

@gilby

@gilby gilby commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

CSA2 attention on Metal (csa2_attn.metal): decode rows over ring or linear windows and prompt rows in 16-key tiles, over the window, the selected compressed rows and the sink; registered with the kernel contract.

Main's shared files change only by one-line hooks; this part's records, suites and limits go into the family's own files (dsv41_metal_records.zig, metal_dsv41_main.zig, metal_dsv41_limits.zig).

Part 5 of 18 of the stack for #1676; stacks on main, with parts 1 to 4 (#1705 to #1708) merged.

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: TensorFold f8ba719 on main 9e8c368 (native Zig 0.17.0; no MLX or PyTorch); Apple M3 Ultra (60-core GPU), 96 GB, macOS, for the kernel and device tests; checkpoint deepseek-ai/DeepSeek-V4.1-Flash-1017.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: n/a: kernels only; the kernel contract checks each launch geometry's bits against the others and against float64.
  • Decode speed before and after, from tools/bench_openai.py: measured on the PR that turns serving on.
  • Prompt speed before and after: the cold first request's ttft_s from tools/bench_cache.py --require-cold on a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: measured on the PR that turns serving on.
  • Tests run, with pass, fail and skip counts: zig build test tf-kernel-contract -Dcpu=apple_m1: exit 0, 592/592 steps succeeded; kernel contract, tf-kernel-contract --only dsv41 (Metal): SUMMARY 21 kernels: 21 pass gates 1-4, 0 fail, 0 known findings; 33 controls: 33 red as planted, 0 missed; 0 limit problems; gates 92119 ms, limits 1292 ms; python3 tools/zig/lean_check.py: 4924 files, 424 problems, the same count as main (4919 files, 424). Zig's summary counts only the test binaries it ran in that invocation, so the step count is the comparable figure.
  • Not run, and why: CUDA: no CUDA code changes; Metal on M1, M2, M4 and M5: one M3 Ultra only (the contract's limits check covers the M1 to M5 pipeline limits).

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt.
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

gilby and others added 3 commits November 2, 2026 01:40
csa2_attn.metal attends over the sliding window, the selected compressed rows and the sink on one shared latent
row: decode rows over ring or linear windows, prompt rows in 16-key tiles at absolute positions, fp32 or bf16 out.
Registered with the contract against float64, with a row's bytes equal across chunk splits and between launches.
@ashhart
ashhart force-pushed the dsv41-metal-pr/05-csa2-attention branch from f8ba719 to 4b4afdd Compare November 2, 2026 01:40
@ashhart
ashhart merged commit 47bf0e3 into ashhart:main Nov 2, 2026
2 of 9 checks passed
@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thank you @gilby. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks @gilby! This is in TensorFold 1.2.2, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.2

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.

2 participants