feat: Implement --swa-full as an opt-in that keeps every sliding block
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in src/cli/context_args.rs at ContextCompatArgs::resolve, where the swa_full == Some(true) refusal sits, and in context_args_tests.rs where the refusal test lives. The policy switch belongs in the CachePool sliding path that depends on #3256, which is not yet merged. Done means --swa-full starts, the startup log prints both sliding estimates, and a model without sliding layers logs one warning.
索引モデルが issue の本文から書いたものです。
説明
Part of #3259
Depends on #3256
Problem / Background
--swa-full (env LLAMA_ARG_SWA_FULL) asks llama-server for a full-size sliding-window cache (common/arg.cpp:1679-1685 at b10621 c1d0e7a0, default false). mlxcel refuses --swa-full true at startup (src/cli/context_args.rs:145-157). The refusal says the capability depends on scheduler-owned sliding caches, not on their size. Once #3256 lands, sliding layers are scheduler-owned blocks, and the flag reduces to one policy: never retire a sliding block from a live sequence.
The opt-in is still wanted for cases #3256 does not cover. With the window-bounded default, a sliding block retired under prompt-cache budget pressure is gone, so a later divergence before it falls back to an earlier d (sliding_window_evicted). With --swa-full, every block of a live sequence survives until donation. Divergence at any block boundary then reuses as on a full-attention family, for the lifetime of the entry under the normal LRU.
The cost is the full-size cache. On gemma-4-12b-it (40 sliding layers at 320 KiB per token, K and V stored), sliding KV is 2.5 GiB at 8k, 10 GiB at 32k and 40 GiB at 128k per sequence, against a fixed 320 MiB with the window.
Current Behavior
ContextCompatArgs::resolve returns Err for swa_full == Some(true) (context_args.rs:145). The accepted spellings --swa-full false and LLAMA_ARG_SWA_FULL=0 are inert. ContextCompatResolution (:119) has no SWA field.
Proposed Solution
- Add
swa_full: booltoContextCompatResolutionand drop the refusal. Carry it through startup into theCachePoolsliding policy that #3256 adds: withswa_full,Slidinglayers ofSchedulerOwnedsequences never move blocks to the retired list.logical_startstill advances, so attention numerics stay windowed and unchanged. Only the release is skipped. No separate cache type. - For a model that has no scheduler-owned sliding layers (
layer_state_kinds()isNone, or has noSlidingentry),--swa-full truelogs onewarnnaming the model type and stating the flag has no effect. Do not refuse, so one launch script works across models. - At startup, log at
infothe sliding KV estimate at--ctx-sizeand the full-size estimate, usingcrate::execution::kv_arch::estimate_kv_arch_unwindowed_from_config(already imported bysnapshot_sizing.rs:31). Feed the full-size figure into the memory estimate the server already prints, so--ctx-sizeadmission and the advisor see it. - Keep the default off. Document the flag in
docs/llama-server-compat.mdwith the memory table above.
Scope
In scope: src/cli/context_args.rs and context_args_tests.rs, the startup wiring, the CachePool sliding policy switch, the memory estimate line, and docs.
Out of scope: the window-bounded design itself (#3256), and quantized sliding blocks (#3250).
Implementation Notes
- Reuse: #3256's retired-list hook (a single branch on the policy) and
kv_archunwindowed estimation. Do not write a second estimator. - Edge cases:
--swa-fullwith the prompt cache disabled still keeps blocks for the live sequence only, so it is useful only for context shift. State this in the docs. A context that does not fit at full size is refused by the existing context admission, not silently windowed.
Acceptance Criteria
-
--swa-fullandLLAMA_ARG_SWA_FULL=1start the server. The refusal testswa_full_is_refused_with_a_diagnostic_naming_the_missing_mode(context_args_tests.rs:65) is replaced by an acceptance test. - On a tiny Gemma 3 fixture with a prompt-cache budget small enough to evict retired blocks, divergence at a block boundary before the evicted range reuses
floor_to_block(d) - block_sizewith--swa-full, and falls back (sliding_window_evicted) without it. Both runs' logits equal a cold run with the same partition. - The startup log prints both sliding estimates. A test pins the figures for the gemma-4-12b config at 8k (320 MiB windowed, 2.5 GiB full).
- A model with no sliding layers logs the no-effect warning once, with a test.
Implement this in one PR, run the verification block once at the end, and keep pushes to a minimum.
Verification
make test-fast FILTER=context_args
make test-fast FILTER=prompt_cache
make test-fast FILTER=gemma3
make verify-test # macOS; on Linux/NVIDIA: make verify-test-cuda
- 主要言語
- Rust
- スター
- 505
- フォーク
- 81
- 平均マージ
- 14時間 2分
- マージ済み PR(30日)
- 448
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lablup/mlxcel のほかの issue
-
area:core priority:high status:ready type:security
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
priority:medium status:ready type:security
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:text priority:medium status:in-progress type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
area:models priority:low status:ready type:test
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:omni priority:medium status:ready type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
area:ui effort:medium enhancement P7 source:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
documentation priority: low tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
nledford/Ladderback#1823 ·
メンテナーはふだん 1 日以内に返信
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)対応中かも @ealwanlee が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
psmux/psmux-plugins#47 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信