mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-06 11:04:06 +01:00
(cherry picked from commit 2e8c362430830f1b4ce23757b9a364596bcee6ac) Adapted for upstream: _admit_phase does not exist upstream (grep finds no definition in obliteratus/), so dropped the internal mock and rewrote the main test to group model forwards per cache policy instead of assuming a single two-prompt batch (upstream batches by available memory; on CPU-only hosts each prompt runs its own forward). Kept docs/attention-cache- qualification.md verbatim (no hostnames, receipts, or private refs; the #95/#96/#97 refs are public issue numbers) and the ci/test-risk-map.json registration, which matches the final test file name.
52 lines
2.8 KiB
Markdown
52 lines
2.8 KiB
Markdown
# Attention and cache qualification
|
|
|
|
Issue #97 requires correctness and measured workload gains before changing
|
|
attention or cache defaults. Its A100 measurements depend on the reviewed CUDA
|
|
qualification work in #95 and #96. CPU contracts below provide a candidate for
|
|
that work, not an A100 qualification result.
|
|
|
|
## Activation cache comparison
|
|
|
|
`AbliterationPipeline._collect_activations` accepts a keyword-only `use_cache`
|
|
override for qualification callers:
|
|
|
|
```python
|
|
cached = pipeline._collect_activations(layers, prompts, "cache-enabled", use_cache=True)
|
|
uncached = pipeline._collect_activations(layers, prompts, "cache-disabled", use_cache=False)
|
|
```
|
|
|
|
Omitting the argument, or passing `None`, preserves the existing model-selected
|
|
behavior and does not add a forward keyword. An explicit boolean applies only
|
|
to those activation forward calls. It does not alter model configuration,
|
|
generation configuration, later analysis, or generation calls. Invalid override
|
|
values fail before hooks are installed. Unsupported model/backend overrides
|
|
propagate their error; the collector cleans up its hooks and padding state and
|
|
does not retry a different policy.
|
|
|
|
The collector consumes layer hooks and returns CPU activation tensors; it does
|
|
not return the model's KV cache to downstream analysis. Offline tests exercise
|
|
real tiny GPT-2 eager and SDPA models with padded batches, both last-token and
|
|
multi-position collection, and finite-logit checks. Enabled, disabled and
|
|
inherited runs must agree on captured activations and logits within 1e-6, and
|
|
cache presence must match the requested policy. Model/generation configuration
|
|
and deterministic generation before and after collection must remain unchanged.
|
|
These tests do not establish the same contract for Qwen hybrid or other
|
|
architectures, FlashAttention-2, or accelerator execution.
|
|
|
|
## Remaining adoption evidence
|
|
|
|
The qualification must retain requested and actual attention/cache choices,
|
|
including explicit fallback reasons or unsupported-mode rejection. Preserve
|
|
architecture-specific Qwen requirements and activation hooks. Compare eager,
|
|
SDPA and a pinned A100-compatible FA2 build using the same immutable model,
|
|
tokenizer, prompts, masks, seeds, batch sizes and sequence-length tiers.
|
|
|
|
Before adoption, check hook tensors, padding/masks, finite logits and a stated
|
|
numerical envelope. Measure prefill, decode, probe and edit separately with
|
|
warmup and at least five synchronized repetitions per fixed workload. Retain
|
|
median/spread, per-device and host peaks, slower cases, and correctness failures.
|
|
Generation cache strategies need their own checks; this activation-only override
|
|
does not qualify them. Record reviewed commit/environment identities and broker
|
|
lease ownership with every conditional run. No default has been changed and no
|
|
FA2 speedup, FA3/Hopper result or A100 qualification is claimed here.
|