feat: Implement --swa-full as an opt-in that keeps every sliding block
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Rust
- Estrellas
- 505
- Forks
- 81
- Merge medio
- 14 h 2 min
- PR fusionados (30 d)
- 448
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de lablup/mlxcel
-
area:core priority:high status:ready type:security
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
priority:medium status:ready type:security
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
-
area:models modeltype:text priority:medium status:in-progress type:bug
Dificultad 4/5 3-5 días Aptitud para principiantes 57/100
Los mantenedores suelen responder en 1 día
-
area:models priority:low status:ready type:test
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
-
area:models modeltype:omni priority:medium status:ready type:bug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
Todos los issues de lablup/mlxcel
Issues similares
-
area:ui effort:medium enhancement P7 source:agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
marketing
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Read a requested CodeRabbit PR review's findings with `coderabbit pullrequest --show-threads`Abiertodocumentation priority: low tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
nledford/Ladderback#1823 ·
Los mantenedores suelen responder en 1 día
-
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)Posiblemente ocupada @ealwanlee la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
psmux/psmux-plugins#47 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día