Phase 4: Layer skip with VSIDS-inspired profiling + sliding window

- Profile per-layer importance during prefill (||delta||² metric)
- Skip N least important layers during decode (saves bandwidth)
- Protect first/last 2 layers from being skipped
- Sliding window attention mask (--sliding-window W)
- CLI: --layer-skip N, --sliding-window W
- Integrated in both standard AR and speculative paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Carmen EstebanandClaude Opus 4.6 committed 2026-04-05 19:07:02 +02:00
1 parent 04065aa1ce
commit 46e9dc1fbe
7 files changed
+195 -12

No files matched your search

+5 -1
View File
@@ -102,6 +102,8 @@ struct ar_sampler_params {
float repeat_penalty = 1.1f; // repetition penalty
int repeat_last_n = 64; // window for repeat penalty
uint32_t seed = 42;
int layer_skip = 0; // skip N least important layers (0 = disabled)
int sliding_window = 0; // attend last W positions only (0 = full)
};
// ── AR token callback (return false to stop) ──────────────────
@@ -120,7 +122,9 @@ std::vector<int32_t> ar_generate(
// ═══════════════════════════════════════════════════════════════
struct ar_spec_params {
int K = 5; // speculative lookahead (draft tokens per round)
int K = 5; // speculative lookahead (draft tokens per round)
int layer_skip = 0; // skip N least important target layers (0 = disabled)
int sliding_window = 0; // attend last W positions only (0 = full)
};
struct ar_spec_stats {