Commit Graph
33 Commits
Author SHA1 Message Date
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 fb8765fdc7 Fix get_u32_multi: allow optional keys (vocab_size, mask_token_id)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 17:53:47 +02:00
Carmen EstebanandClaude Opus 4.6 dd6aca0fba Fix model loading for llama.cpp GGUF files
- Infer n_vocab from token_embd tensor when not in metadata
- Fix default rope_theta (1e6) and rms_norm_eps (1e-6) for Qwen2.5
- vocab_size key is optional (absent in llama.cpp GGUF files)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 17:52:59 +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
iafiscal1212andClaude Opus 4.6 6126b13ad1 license: change from AGPL-3.0 to Apache-2.0 for open source launch
- LICENSE: Apache-2.0 (enables commercial use and community contributions)
- README: updated badges, Zenodo DOI, expanded contributing section,
  removed SEDD/MDLM planned (inviable), fixed author name in citation
- paper.tex: updated license line to Apache-2.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 09:30:44 +02:00
IAFiscal d29d4a4d55 chore: update README license to All Rights Reserved 2026-03-29 14:36:28 +02:00
IAFiscal b519003259 chore: change license to All Rights Reserved 2026-03-29 14:35:31 +02:00
iafiscal1212andClaude Opus 4.6 9c5cba1466 docs: add Dream-7B vs LLaDA-8B comparative benchmark table
Side-by-side performance comparison of both supported models with
entropy_exit + inter-step KV cache. Dream excels at factual/math (21.6
tok/s), LLaDA at translation (25.7 tok/s). Both beat llama.cpp on
easy prompts. Added HuggingFace GGUF download links.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 15:09:00 +01:00
iafiscal1212andClaude Opus 4.6 eb424961e1 fix(gqa): use grouped repeat in extractable graph for KV cache
The extractable graph builder (used for step 0 when cache is ON) was
still using the old 3D ggml_repeat which produces interleaved head
ordering. This caused cached K,V to have wrong head assignments,
producing garbage output when cache was enabled with GQA models (Dream).

Applied the same 4D reshape→repeat→reshape pattern already used in the
basic and cached graph builders.

Dream-7B Q4_K_M with cache: 22.5 tok/s (2.6x llama.cpp) on easy prompts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 14:42:11 +01:00
iafiscal1212andClaude Opus 4.6 7b8cc6eb25 fix(dream): apply logit shift for Qwen2.5 autoregressive convention
Dream (Qwen2.5 backbone) outputs logits where position i predicts
token at position i+1 (autoregressive convention). The original
Dream code applies: logits = cat([logits[:,:1], logits[:,:-1]], dim=1)

We implement this as: for position i, read logits from max(i-1, 0).
Only active for model_type=="dream"; LLaDA is unaffected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 14:01:31 +01:00
iafiscal1212andClaude Opus 4.6 d261e604af fix(gqa): use grouped repeat instead of interleaved for GQA heads
ggml_repeat with K[d,4,N]→[d,28,N] gives round-robin head assignment
(kv0,kv1,kv2,kv3,kv0,...) but GQA expects grouped assignment
(kv0×7, kv1×7, kv2×7, kv3×7).

Fix: reshape to 4D, repeat the inner dimension, reshape back.
K[d,kv,N] → K[d,1,kv,N] → repeat → K[d,rep,kv,N] → K[d,head,N]

This was the root cause of garbage output on Dream-7B (GQA 28/4).
LLaDA (MHA 32/32) is unaffected since the GQA path is never taken.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 13:50:43 +01:00
iafiscal1212andClaude Opus 4.6 7eb999b09a fix: cast quantized biases to F32 in graph, keep biases unquantized
- diffuse-graph: ensure_f32() helper casts bias tensors before ggml_add
- quantize: classify .bias tensors as TC_NORM (always F32)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 13:37:13 +01:00
iafiscal1212andClaude Opus 4.6 531ef58222 fix(dream): add QKV bias support for Qwen2.5 backbone
Dream/Qwen2.5 uses biases on Q, K, V projections. Without them,
attention is fundamentally incorrect producing garbage output.

Changes:
- diffuse_layer: add optional bq, bk, bv bias tensor pointers
- diffuse-model: load bias tensors from GGUF (nullptr if absent)
- diffuse-graph: apply ggml_add after QKV projection in all 3 graph builders
- convert-dream.py: include QKV bias tensors instead of skipping them

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 13:28:50 +01:00
iafiscal1212andClaude Opus 4.6 3f6aa5597a feat: add Dream-7B model support (Qwen2.5 backbone, GQA)
- New converter: tools/convert-dream.py (Qwen2.5 tensor mapping)
- Multi-model loader: reads diffuse.model_type from GGUF metadata
- GQA support verified (28 query heads, 4 KV heads)
- New remasking strategies: maskgit_plus, topk_margin (from Dream paper)
- Updated CLI, benchmark, and generate.py with new remasking options
- README: supported models table, Dream conversion example
- Zero breaking changes for existing LLaDA GGUF files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 13:03:30 +01:00
iafiscal1212andClaude Opus 4.6 9b76ba9bc3 chore: remove old paper PDF with unwieldy filename
Superseded by paper.pdf (v2.0, compiled from paper.tex with inter-step cache results).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 12:41:48 +01:00
IAFiscal 30db6fa49b Delete .zenodo.json 2026-03-22 12:30:04 +01:00
iafiscal1212andClaude Opus 4.6 8c10a8cb44 feat: inter-step KV cache + updated documentation (v0.2.0)
- Inter-step cache: 1.6x average speedup (15-28 tok/s on easy prompts)
- 6 of 8 prompts now outperform llama.cpp (up to 3.2x)
- New flags: --no-cache, --cache-refresh, --cache-keep-active
- Updated paper, README, RESULTS, .zenodo.json
- Cache improves quality on 3/8 prompts (regularization effect)
- New paper.tex source with cache results (Section 4.1, 6.7)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
v0.2.0
2026-03-22 12:20:32 +01:00
IAFiscal abad74a552 Add files via upload 2026-03-20 16:17:13 +01:00
iafiscal1212andClaude Opus 4.6 a74fdfdd3f Update README and zenodo metadata with B=256 real-prompt data
- Headline: 11-22 tok/s (was ~10 tok/s)
- Full 8-prompt table with B=64 and B=256 columns
- Usage examples updated to -n 256
- Remove "Maximum 128 tokens" limitation
- .zenodo.json: honest 11-22 tok/s range

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 11:10:32 +01:00
iafiscal1212andClaude Opus 4.6 d4268684a0 Add Zenodo metadata for v1.0.0 software DOI
Links to companion paper DOI: 10.5281/zenodo.19119814

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 09:42:25 +01:00
iafiscal1212andClaude Opus 4.6 04ad24946a Increase default generation buffer from 64 to 256 tokens
Benchmark shows 2.7-3x throughput improvement per token (sub-linear
time scaling), with entropy_exit reaching 4.82 tok/s at n=256.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 09:12:12 +01:00
iafiscal1212andClaude Opus 4.6 bfc71d1b28 Prepare for public release: rigorous benchmarks + cleanup
- Replace benchmark JSONs with rigorous 6.5h results (288 configs, 3 reps each)
- Update README and RESULTS.md with verified numbers
- Remove research/fase4.2/ (internal notes)
- Sanitize server paths in run-benchmark.sh and JSON files
- Add real_prompts.txt used in benchmarks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 22:29:27 +01:00
iafiscal1212andClaude Opus 4.6 054a80afda Fix compute buffer sizing for 128+ token generation
Increase safety margin from 1.2x to 1.5x. The previous margin was too
tight for 128 generated tokens (deficit of ~1.4 MB on a 2.76 GB buffer).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 14:34:14 +01:00
iafiscal1212andClaude Opus 4.6 00243730eb Prepare for public release: AGPL-3.0 license + README overhaul
- Change license from MIT to AGPL-3.0 with commercial licensing option
- Expand README with full benchmarks, API docs, and entropy_exit documentation
- Fix build instructions (DIFFUSE_BUILD_TOOLS, not BUILD_BENCH)
- Remove TODO comment from main-cli.cpp

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 14:23:26 +01:00
iafiscal1212andClaude Opus 4.6 bbab396d89 Add exhaustive benchmark results: F16/Q8_0/Q4_K_M × steps × threads × schedulers
3 quantization levels × 3 step counts × 3-4 thread counts × 2 schedulers.
Key result: Q4_K_M + entropy_exit + 12 threads = 13.59 tok/s (1.6x llama.cpp).
Includes format-benchmark.py for publication-ready table generation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 13:27:26 +01:00
iafiscal1212andClaude Opus 4.6 4a10d3574b Rewrite diffuse-bench for exhaustive benchmarking
Supports: steps/threads/schedulers sweep, JSON+markdown output,
warmup runs, actual step counting for entropy_exit.
Add run-benchmark.sh wrapper for F16/Q8_0/Q4_K_M comparison.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 07:01:45 +01:00
iafiscal1212andClaude Opus 4.6 909dba237a Add diffuse-quantize tool: F16 → Q4_K_M/Q8_0/Q6_K quantization
Mixed quantization strategy (Q4_K_M):
- Attention weights: Q4_K
- FFN weights: Q4_K (Q6_K for first/last layers)
- Norms: F32
- Embeddings: F16 (preserved)
- Output head: Q6_K

Results: 15GB → 5.1GB (2.9x), 1.6x faster inference, quality preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 06:48:00 +01:00
iafiscal1212andClaude Opus 4.6 d74a5dbf47 Add systematic entropy_exit benchmark: 42 prompts × 12 categories
55% of real-world prompts benefit (>20% speedup), with ~1.8x weighted
average across typical chatbot traffic. Classification (2.84x),
instruction following (3.86x), and translation (2.71x) are the
biggest winners. Creative writing shows 0% speedup as expected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 06:20:24 +01:00
iafiscal1212andClaude Opus 4.6 627b45891d Add entropy_exit semantic scheduler + research findings
- ENTROPY_EXIT remasking: unmask all low-entropy tokens early, spend
  steps only on difficult tokens. 5-8x speedup on structured tasks
  (translation, factual QA) with no quality loss.
- Add entropy_threshold parameter (default 1.5)
- Research doc: prior art survey (EAGS, Fast-dLLM, WavefrontDiffusion,
  DOS, LoPA) + empirical results on 5 prompts
- Python semantic_scheduler.py experiment framework

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 05:19:52 +01:00
iafiscal1212andClaude Opus 4.6 621e635224 Fix buffer calculation: account for FFN intermediates
Per-layer buffer now includes: 10×embd + 3×ff + 2×attn_score + norm casts
Plus 20% safety margin. Fixes OOM for 48+ token sequences.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 05:07:52 +01:00
iafiscal1212andClaude Opus 4.6 2bb4358450 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>
2026-03-19 05:06:32 +01:00
iafiscal1212andClaude Opus 4.6 4d6bd72d4e Fix forward pass for real LLaDA-8B F16 model
- Add ggml_cast for norm weights (F16→F32) to fix ggml_mul type mismatch
- Switch RoPE from NORMAL to NEOX style (non-interleaved, matching LLaDA/OLMo)
- Use PyTorch framework in converter for BF16 safetensors support
- Add validation tools: validate-gguf.py, compare-logits.py, dump-logits
- Result: 100% argmax match vs PyTorch, cos_sim >0.993

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 05:03:11 +01:00
iafiscal1212andClaude Opus 4.6 6022454e29 Initial scaffold: diffuse-cpp inference engine for Diffusion LLMs
- Project structure with CMake build system, GGML submodule
- Core library: model loader (GGUF), transformer forward pass, diffusion sampler
- CLI tools: diffuse-cli (generation) and diffuse-bench (benchmarks)
- Converter: convert-llada.py (SafeTensors → GGUF with tensor name mapping)
- Tests: unit tests, converter roundtrip test, end-to-end forward pass test
- Bidirectional attention (no causal mask, no KV cache)
- SwiGLU FFN, RoPE, RMSNorm — full LLaDA-8B Llama backbone
- Verified: compiles clean, forward pass produces valid logits on tiny model

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 21:43:36 +01:00