Sliding-window retention currently drops leading cache blocks, so a
cached window cannot preserve token sinks independently of full-history
storage. This change adds sink retention throughout the existing cache
path and lets block drafters write context KV through their own cache
group.
- Retain, match, publish and restore the sink and window union; include
it in Host L2 matching, eviction, capacity accounting and PD landing and
transfer selection.
- Keep sink blocks last within the existing LRU order, including demoted
entries. Cover prefix hits, partial-tail copies and exact-capacity
admission.
- Support separate K and V fields with padded page strides in the arena,
prologue, fused context writes and attention. Preserve sinks in folded
Triton decode and physical strides in TRT-LLM paged cache views.
- Preserve the previous scheduler API for zero-sink groups and report a
clear error when an older scheduler is asked to retain sinks.
Validation: Linux C++ scheduler 1,408 tests; Python scheduler 405 tests;
Rust PD 72 tests; 50 focused B300 runtime and kernel regressions for the
scoped page-default and diagnostic update, including unchanged generic
MHA defaults, eager and graph replay, changed page tables, FP8 composite
writes, large offsets and compilation reuse. `pre-commit run
--all-files` passes.
Draft: real-model acceptance and full native 1P1D and L2 end-to-end
validation remain pending. Sink groups currently require a
non-replayable window at least as large as the prefix granularity.
Sink-enabled configurations require the matching scheduler source build;
scheduler release and dependency-version updates follow separately.
Token-sink draft attention remains on the Triton path.
Co-authored-by: longcat-ia-team
<312376714+longcat-ia-team@users.noreply.github.com>
---------
Signed-off-by: wangbo981016 <wangbo981016@gmail.com>
Co-authored-by: longcat-ia-team <312376714+longcat-ia-team@users.noreply.github.com>
Cut CI time of the runtime-1gpu suite on gfx950 runners, where most of
each file's cost is process startup:
- Drop parametrizations that repeat a covered path in the slowest file,
test_startup_process_ownership.py: SIGUSR1 and SIGQUIT share one
handler.
- Disable files whose every test skips off NVIDIA on amd-* runners, so
they no longer pay startup only to skip.
- Remove test_deepseek_v4_slot_mappings.py (field-absence check) and
test_table_export_fast.py (covered by test_block_tables_bridge.py).
- Avoid a needless spawned process in test_metrics_server.py.
- Remove trivial argument-validation tests (types, positivity, lengths,
required fields) and structure-only checks (field, method placement,
signature), and fold one-flag CLI round trips into one table test.
- Narrow the lm_head dtype matrix to the bounding shards and dtypes.
Signed-off-by: Lei Zhang <antiagainst@gmail.com>
## Summary
Switch all test cases to pytest. Deprecate unittest-based tests.
- Convert all 100 files containing unittest TestCase classes to native
pytest classes, assertions, fixtures, skips, subtests, and asyncio
tests. Keep unittest.mock where useful.
- Run every selected runtime test file through pytest while preserving
subprocess-per-file isolation, suite and runner filtering, timeouts,
retry handling, and artifacts.
- Require pytest 9 for built-in subtests. Preserve existing test
definitions and inherited cases.
- Repair stale test doubles and module isolation uncovered when
previously import-only files begin executing. Restrict real CuTe and
Mamba2 GPU checks to their supported platforms; keep metadata-only
checks active.
## Test Plan
- `pre-commit run --all-files` and Ruff F checks passed.
- Static audit preserves test-function definitions in changed Python
files and finds no remaining TestCase bases.
- 261 existing CI-system tests passed.
- Isolated CPU L3 and communicator checks: 68 passed, 1 skipped;
standalone n16 layout check: 6 passed.
- AMD runtime-1gpu: both partitions passed, covering 81 and 82 files
(413.96s and 409.43s). External ROCm profiler auto-registration was
disabled in the validation environment because it also breaks the
original unittest profiler check; tracked runner environment handling is
unchanged.
- Collection checked all 100 migrated files: 98 collected normally; two
existing Inkling whole-module skips require NVIDIA Blackwell.
- NVIDIA GPU execution remains pending.
---------
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
## Summary
A cache group carried two classification fields, `retention`
(`full_history` | `sliding_window`) and `family` (`history` | `state`),
with a validation rule forbidding the `(state, sliding_window)` cell. A
2×2 with one forbidden cell is a three-valued enum, and the C++
scheduler already read only that enum: `CacheGroupConfig::Kind()` folded
the pair into `AttnKind` at the bridge, and no scheduler logic touched
the two fields. This PR makes the attention kind the one classification
on both sides.
* **Python** `CacheGroupSpec.attn_kind: Literal["full_history",
"sliding_window", "state"]` replaces `retention` + `family`.
`__post_init__` holds each kind to its shape (window only on a sliding
group, row geometry only on a history group, bounded replay only on a
sliding group) and rejects an unknown kind at construction. One
`_LAYER_TYPE_ATTN_KIND` table replaces `_LAYER_TYPE_RETENTION` plus the
separate state label set; state groups no longer carry a placeholder
`full_history` retention.
* **C++** `CacheGroupConfig.attn_kind: AttnKind` crosses the bridge
directly (the scheduling-form `CacheGroupSpec` carries the same name).
`CacheGroupConfig::Retention`, `CacheGroupFamily` and `Kind()` are gone;
`AttnKind::kMambaState` is renamed `kState`. The nanobind constructor
requires `attn_kind` (the old `retention` / `family` defaults selected
behaviour, which AGENTS.md forbids) and exposes `AttnKind` as the only
cache-group enum. The field is qualified because bare `kind` is already
taken in the same headers (`StateStep::kind`, `boundary_kind`).
* **Backends** claim the kinds they read: `cache_consumer_families` →
`cache_consumer_attn_kinds`; paged backends declare both history kinds,
state consumers `state`. `validate_scheduler_config` now also catches a
sliding group with no consumer that handles windows.
`CacheGroupGeometry.families` / `retentions` → `attn_kinds` + `windows`
(the window stays part of rebind equality).
* **PD** `validate_cache_peer_layout` compares `attn_kind`.
`CacheGroupSpec` rides the bootstrap wire, so prefill and decode peers
must be upgraded together.
* "Retention" remains the name of the reclaim policy (`ExpiredBlocksAt`
/ `ReclaimExpired`); only the classification field and its types go.
`docs/design/cache-concepts.md`, `scheduler.md` and `unified_path.md`
are updated to the attention-kind vocabulary, and stale `family` /
`retention` wording in comments and tests is swept.
The second commit bumps `tokenspeed-scheduler` to 0.1.37 and pins the
runtime to it; the release is triggered from this branch.
## Test plan
- [x] `tokenspeed-scheduler` C++ tests: 579 passed
- [x] `tokenspeed-scheduler/python/tests`: 235 passed against the
rebuilt extension
- [x] `test/runtime`: the 81 test files touching `CacheGroupSpec` / the
bridge / backend claims run file by file; every file with failures has
identical fail/pass counts on an untouched `main` checkout with its own
scheduler build (stale local `flash_mla`, mock gaps, pre-existing
capacity assertions) — no regressions
- [x] `pre-commit run --all-files`
- [ ] CI model tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: FC-Li <robert_lexis@163.com>
Co-authored-by: longcat-ia-team <longcat_ia_team@meituan.com>
Every paged attention layer now prepares its query and writes its K/V
rows through one kernel-family entry per attention shape,
`gqa_attention_prologue` and `mla_attention_prologue` in
tokenspeed-kernel, dispatched like any other kernel. Models state their
steps once (`PagedAttention(..., rotary_emb=, qk_norm=)`) and no longer
normalize, rotate, quantize or store K/V themselves; backends never
write the cache.
Solutions: a fused Triton kernel (AMD and NVIDIA) that computes the
steps in fp32 and rounds every output once; `fused_rope`, the CUDA
embedding.rope write, for unnormed layers past 512 token-heads on
NVIDIA; and the composite of the existing step kernels, which serves
Ascend and MXFP8 caches. Selection is by declared traits; a kernel that
would round differently declines instead of being admitted with a
tolerance.
The design document `docs/design/attention-prologue.md` records the
accepted inputs (validated once from metadata), the rounding contract,
who writes the cache, breakable prefill graphs, formats and scales.
Also:
- Qwen3.5's M-RoPE rotated text tokens through per-op bf16 rounding; it
now selects the position row per pair and rotates once in fp32.
- Gemma's `1 + w` is formed in fp32, never rounded to the activation
dtype.
- KV caches run at unit scale: a checkpoint KV scale other than one, or
a non-unit `--quantization-param-path` under an FP8 cache, is rejected.
- MXFP8 (Inkling) and FP8 per-token-head (GLM) caches write through the
same entries; the MXFP8 writer validates its rows, planes and pages.
- The Triton RoPE kernels use the CUDA kernel's fma association so
unnormed solutions agree byte for byte; every step kernel forms row and
head offsets in 64 bits.
- The MiniMax-M3 fused QK-norm/RoPE/KV CUDA kernel and the per-model KV
write paths are removed.
<!-- Headings and layout are optional. Include change context and
validation
(checks performed or planned, or why testing was not run or is not
applicable)
anywhere in the description. -->
## Summary
<!-- What changed and why? -->
## Test Plan
<!-- How was this validated? -->
---------
Signed-off-by: Nicolas Perrin <nperrin.ai@gmail.com>