Commit Graph
4 Commits
Author SHA1 Message Date
Carmen EstebanandClaude Opus 4.6 46e9dc1fbe 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>
2026-04-05 19:07:02 +02:00
Carmen EstebanandClaude Opus 4.6 e9d830652e Phase 3: Speculative decoding with draft model
Add speculative decoding engine that uses a small draft model (e.g.
Qwen2.5-0.5B) to propose K candidate tokens, verified in one batch
by the target model (e.g. Qwen2.5-32B). Greedy mode (temp=0) only.

Key features:
- Fast-reject: skip target batch when d1 mismatches (saves ~40% of batches)
- KV cache rollback after verification (accepted prefix kept)
- Separate threadpools: target=high priority, draft=normal
- ar_forward_batch: new API for multi-token forward without cache reset

New files: src/ar-speculative.{h,cpp}
CLI flags: --draft, --spec-k, --draft-threads

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 18:42:33 +02:00
Carmen EstebanandClaude Opus 4.6 d764edf046 Phase 2: flash_attn_ext + thread binding for AR engine
- Replace manual attention (permute + mul_mat + soft_max_ext + mul_mat)
  with ggml_flash_attn_ext (fused kernel, online softmax)
- Flash attention handles GQA natively (n_head_kv → n_head broadcast)
  eliminating the ggml_repeat GQA expansion (~5x less KV memory)
- Mask changed from F32 to F16 (required by flash_attn kernel)
- Reduced compute buffer sizing (no GQA expansion memory)
- Added --bind-cores flag for CPU thread affinity (OMP_PROC_BIND)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 18:08:27 +02:00
Carmen EstebanandClaude Opus 4.6 2b8ead2fb6 Add autoregressive inference engine for Qwen2.5/Llama models
- ar-cache.h: append-only KV cache (stores KV heads without GQA expansion)
- ar-graph.cpp: forward pass with causal mask (ggml_soft_max_ext) and KV cache
- ar-sampler.cpp: token-by-token generation with temp/top-p/top-k/repeat penalty
- ar-cli.cpp: CLI tool (diffuse-ar) for autoregressive inference
- diffuse-model.cpp: multi-arch GGUF loading (diffuse/qwen2/llama prefixes)
- diffuse.h: extended public API with ar_sampler_params and ar_generate()

Enables loading llama.cpp GGUF files directly (e.g. Thrombia-32B Q4_K_M).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 17:49:37 +02:00