Skip to content

feat(cache): implement --swa-full opt-in to keep every sliding block - #3658

Merged
inureyes merged 1 commit into
mainfrom
feat/issue-3257-swa-full
Dec 1, 2026
Merged

inureyes merged 1 commit into
mainfrom
feat/issue-3257-swa-full

Conversation

@inureyes

@inureyes inureyes commented Dec 1, 2026

Copy link
Copy Markdown
Member

Part of #3259

Closes #3257

Summary

Implements --swa-full (LLAMA_ARG_SWA_FULL, default false) as an opt-in policy that keeps every sliding-window KV block pinned on live sequences until prompt-cache donation instead of retiring blocks past the window.

  • CLI & config wiring: Adds swa_full: bool to ContextCompatResolution and removes the startup refusal in src/cli/context_args.rs. Threads swa_full through ServerStartupConfig, ServerConfig, runtime_settings, WorkerSchedulerConfig, and BatchScheduler.
  • CachePool sliding policy (mlxcel-core): Adds swa_full: bool to PagedBlockPool and CachePool (remembered across lazy pool initialization). When enabled, settle_window_before_append still advances logical_start so attention numerics stay windowed and unchanged, while skipping retire_head_blocks. clone_detached_paged_prefix also preserves blocks from block_base (0) under --swa-full so multi-turn continuations retain every block until donation.
  • No-effect warning: On models without scheduler-owned sliding layers (layer_state_kinds() is None or has no Sliding entry, or the family is not paged-sliding), BatchScheduler::warn_swa_full_no_effect_once logs one warn naming the model type per worker (surviving idle sleep/wake rebuilds) without refusing startup.
  • Startup memory logging & preflight admission: Extends KvSizing with swa_full and KvArchEstimate with sliding_bytes, and adds estimate_sliding_kv_from_config / format_swa_full_startup_log reusing estimate_kv_arch_from_config and estimate_kv_arch_unwindowed_from_config. Startup logs both windowed and full-size sliding KV estimates at info, and serve_preflight_kv_mode / prompt_cache_sizing_kv_mode feed the full-size figure into preflight admission so an oversized full-size context is refused rather than silently windowed.
  • Docs & compat manifest: Updates docs/llama-server-compat.md with the gemma-4-12b-it memory table (8k / 32k / 128k vs 320 MiB windowed) and notes on prompt-cache-disabled and admission behavior, and updates compat/llama-server/b10621/runtime-and-context.json and pin.json to mark --swa-full as supported.

Validation

  • cargo fmt --all -- --check: passed
  • python3 scripts/ci/check_llama_compat_manifest.py: passed (249 help entries, supported: 171)
  • python3 scripts/ci/check_cross_repo_refs.py: passed
  • cargo clippy --profile test-fast --features metal,accelerate -p mlxcel-core --lib --tests -- -D warnings: passed
  • cargo clippy --profile test-fast --features metal,accelerate --lib --bins --tests -- -D warnings: passed
  • cargo test --profile test-fast --features metal,accelerate -p mlxcel-core --lib -- --test-threads=1 cache::paged: 156 passed, 0 failed (including swa_full_advances_logical_start_without_retiring_blocks)
  • cargo test --profile test-fast --features metal,accelerate --lib -- --test-threads=1 context_args kv_arch:: prompt_cache scheduler_paged_sliding gemma3::: 540 passed, 0 failed (including swa_full_is_accepted_and_defaults_off, swa_full_sliding_kv_estimates_pin_gemma4_12b_at_8k_32k_128k, swa_full_preserves_sliding_blocks_across_divergence_where_windowed_evicts, and swa_full_warns_once_for_model_without_sliding_layers_and_stays_silent_for_gemma3)
  • cargo test --profile test-fast --features metal,accelerate --lib -- --test-threads=1 runtime_settings cli_input: 184 passed, 0 failed
  • cargo test --profile test-fast --features metal,accelerate --test llama_compat_manifest: 4 passed, 0 failed

@inureyes inureyes added type:enhancement New features, capabilities, or significant additions priority:low Low priority area:inference Generation, sampling, decoding (incl. speculative, DRY) area:cli Command-line interface / CLI flags status:done Completed labels Dec 1, 2026
@inureyes
inureyes marked this pull request as ready for review December 1, 2026 21:38
@inureyes
inureyes merged commit 4e4bd2d into main Dec 1, 2026
33 of 36 checks passed
@inureyes
inureyes deleted the feat/issue-3257-swa-full branch December 1, 2026 21:38
inureyes added a commit that referenced this pull request Dec 1, 2026
* fix(server): pass swa_full through the diffusing-interval constructor

main does not compile since #3658 and #3624 landed together. #3658 threads `swa_full` through `ModelProvider` and passes it to `new_with_full_config_and_diffusing_interval`, while #3624 introduced that constructor without the parameter, so `cargo build` fails with E0425 (`swa_full` not in scope) and E0061 (41 arguments where 40 are expected).

Add `swa_full: bool` to the constructor after `context_retention`, where the call from `start` already passes it, and forward it from `new_with_full_config`, which takes it but did not pass it on. The body already uses it.

Validated with `cargo build --profile test-fast --features cuda` on Linux (the lib, `mlxcel`, `mlxcel-server`, `mlxcel-bench-decode` and `examples/logit_trace`).

* chore(docs): drop a raw JSONL record the binary-assets check rejects

#3334 committed `docs/benchmark_results/paged-sliding-decode-gb10-2026-11-23/gemma3-1b-first-run-partial.jsonl`, a partial raw record stream. `scripts/ci/check_benchmark_raw_logs.py` rejects JSONL under benchmark data, so the `binary assets` job fails on main and on every PR based on it. Nothing references the file; the directory keeps its README and JSON results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli Command-line interface / CLI flags area:inference Generation, sampling, decoding (incl. speculative, DRY) priority:low Low priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Implement --swa-full as an opt-in that keeps every sliding block

1 participant