Implement exact Qwen Sparse Attention and long-context state #97
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Area
Implement exact Qwen Sparse Attention and all long-context cache, rollback, checkpoint, and admission behavior through the native 262,144-token window.
Sequence
Step 5 of 7. Previous: #96. Next: #98. Start only after short-context generation including PLE is correct; #98 relies on this issue's rollback contract.
Implementation
Verification
Completion requirements
Non-goals
hugo referenced this issue2026-09-01 18:27:01 +00:00
Implemented and verified in final commit
714b39f(Implement exact Qwen sparse attention). The earlier hash was amended before closure so issue #97 remains exactly one commit.Implementation:
metal/qwen38.metal.Behavioral review:
89f485fdc9d6c490f9821c3f7c4b20281094947b05325aa5652cdfa43e36a456, samples[6.406557, 2.0828183, -3.0580456, -0.1210103], greedy token89648.Pinned logical-depth oracle records (depth: logits SHA-256, greedy token, prefill tok/s, AR tok/s, live attention bytes, peak RSS bytes, checkpoint bytes):
4cd0daf267d046d71f23291e756f81b2ebcb549712b441b2d1e8074b41e1da9f, 44,496, 0.601, 0.611, 58,195,968, 735,133,696, 174,839,908.f2513cb75775f0704a52b66053e5e47060234db57b3339e9de5a7d1ba6898bae, 44,496, 0.610, 0.616, 465,567,744, 2,018,492,416, 582,269,028.f104bc1aa6c0e44fbfff2746300374d7c8edf59a6ee5eb43a5f5469a0219e637, 197,597, 0.612, 0.618, 1,862,270,976, 6,098,698,240, 1,979,168,868.660c5f431a6271748c2e4cb326eed6af21a4e67f3937f71b78e635a25fce2669, 180,094, 0.609, 0.626, 3,724,541,952, 13,487,177,728, 3,841,701,988.ead42c990931a88a4196bdc2593013fd471e4f1559e80ccb1779d662e2d08725, 19,559, 0.584, 0.605, 7,449,083,904, 20,488,683,520, 7,566,768,228.Each depth ran the real Rust-owned model prefill and decode graph, asserted its pinned logits/token oracle, enforced at least 90% of dense-boundary throughput, round-tripped the live KV/raw/pooled frontier through resident session swap, wrote and restored the exact disk checkpoint, and checked its byte size. The full-depth run remained within 4.5% of boundary AR throughput.
Additional isolated verification:
cargo fmt --all -- --checkpassed.cargo clippy --all-targets --all-features -- -D warningspassed.make bundlepassed.cargo test --all-featurespassed: 236 main tests plus 4 artifact-tool tests; only declared hardware/artifact tests were ignored.