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>
This commit is contained in:
Carmen EstebanandClaude Opus 4.6 committed 2026-04-05 17:49:37 +02:00
1 parent 6126b13ad1
commit 2b8ead2fb6
9 files changed
+1063 -18

No files matched your search

+25
View File
@@ -90,4 +90,29 @@ std::vector<int32_t> diffuse_generate(
const diffuse_sampler_params & params,
diffuse_step_callback callback = nullptr);
// ═══════════════════════════════════════════════════════════════
// ── Autoregressive API ────────────────────────────────────────
// ═══════════════════════════════════════════════════════════════
// ── AR sampler parameters ─────────────────────────────────────
struct ar_sampler_params {
float temperature = 0.0f; // 0 = greedy/argmax
float top_p = 0.9f; // nucleus sampling
int top_k = 40; // top-k (0 = disabled)
float repeat_penalty = 1.1f; // repetition penalty
int repeat_last_n = 64; // window for repeat penalty
uint32_t seed = 42;
};
// ── AR token callback (return false to stop) ──────────────────
using ar_token_callback = std::function<bool(int32_t token, int pos)>;
// ── AR generation ─────────────────────────────────────────────
std::vector<int32_t> ar_generate(
diffuse_context * ctx,
const std::vector<int32_t> & prompt_tokens,
int max_tokens,
const ar_sampler_params & params,
ar_token_callback callback = nullptr);
// end of diffuse.h