Fix compute buffer sizing + add generate.py wrapper

- Increase base buffer from 256MB to 512MB for graph node overhead
- Better per-layer intermediate estimation (16× instead of 4×)
- Add generate.py: tokenize→diffuse-cli→detokenize pipeline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iafiscal1212andClaude Opus 4.6 committed 2026-03-19 05:06:32 +01:00
1 parent 4d6bd72d4e
commit 2bb4358450
2 files changed
+140 -4

No files matched your search

+7 -4
View File
@@ -145,10 +145,13 @@ bool diffuse_forward(diffuse_context * ctx,
float * logits_out) {
const auto & hp = ctx->model->hparams;
size_t buf_size = 256ull * 1024 * 1024;
buf_size += (size_t)n_tokens * hp.n_vocab * sizeof(float);
buf_size += (size_t)n_tokens * hp.n_embd * hp.n_layer * 4 * sizeof(float);
buf_size += (size_t)n_tokens * n_tokens * hp.n_head * sizeof(float);
// Compute buffer: logits + per-layer intermediates + attention matrices + overhead
// Each layer needs: Q,K,V,attn_out (4×n_embd×N) + attn scores (N×N×n_head)
// Plus norm casts, SwiGLU intermediates, graph nodes overhead
size_t buf_size = 512ull * 1024 * 1024; // base overhead for graph nodes + plan
buf_size += (size_t)n_tokens * hp.n_vocab * sizeof(float) * 2; // logits + output matmul
buf_size += (size_t)n_tokens * hp.n_embd * 16 * sizeof(float); // per-layer intermediates
buf_size += (size_t)n_tokens * (size_t)n_tokens * hp.n_head * sizeof(float) * 2; // attn scores + softmax
struct ggml_init_params cparams = {
/*.mem_size = */ buf_size,