diff --git a/LICENSE b/LICENSE index 16af582..3b30ed6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,199 @@ -Copyright (c) 2024-2026 Carmen Esteban. All rights reserved. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -This software is the exclusive property of Carmen Esteban. -No part of this software may be copied, modified, distributed, -sublicensed, or used in any form without the express written -permission of the author. + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -Unauthorized use, reproduction, or distribution of this software -or any portion of it may result in civil and criminal penalties. + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to the Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by the Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding any notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. Please also get an + OpenAI-compatible identifier for your project. + + Copyright 2024-2026 Carmen Esteban + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index a708e7d..2da63eb 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,11 @@ High-performance C++ inference engine for Diffusion Language Models, built on GGML. +[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) [![C++17](https://img.shields.io/badge/C%2B%2B-17-blue.svg)](https://en.cppreference.com/w/cpp/17) [![GGML](https://img.shields.io/badge/GGML-v0.9.8-green.svg)](https://github.com/ggerganov/ggml) +[![Paper](https://img.shields.io/badge/Paper-Zenodo-blue.svg)](https://doi.org/10.5281/zenodo.19119814) +[![Models](https://img.shields.io/badge/Models-HuggingFace-yellow.svg)](https://huggingface.co/diffuse-cpp) ## Highlights @@ -161,8 +164,8 @@ Available quantization formats: |-------|-------------|---------------|--------| | [LLaDA-8B-Instruct](https://huggingface.co/GSAI-ML/LLaDA-8B-Instruct) | Llama, MHA (32/32) | [diffuse-cpp/LLaDA-8B-Instruct-GGUF](https://huggingface.co/diffuse-cpp/LLaDA-8B-Instruct-GGUF) | Production | | [Dream-v0-Instruct-7B](https://huggingface.co/Dream-org/Dream-v0-Instruct-7B) | Qwen2.5, GQA (28/4) | [diffuse-cpp/Dream-v0-Instruct-7B-GGUF](https://huggingface.co/diffuse-cpp/Dream-v0-Instruct-7B-GGUF) | Production | -| SEDD | Score-based diffusion | — | Planned | -| MDLM | Masked discrete diffusion | — | Planned | + +PRs welcome for additional masked diffusion architectures. ## How It Works @@ -302,25 +305,37 @@ Current limitations: ## Contributing -Contributions welcome. Areas of interest: -- Additional model architectures +Contributions welcome! This is the only C++ inference engine for diffusion LLMs — there's plenty of room to build. + +**High-impact areas:** +- Additional masked diffusion model architectures +- Integrated tokenizer (eliminate the Python pre-tokenization step) +- Batched inference for serving workloads +- GPU offloading via GGML (Metal, Vulkan, CUDA) - Improved scheduling heuristics -- Tokenizer integration -- Multi-query batching +- Benchmarks on different hardware (Intel, ARM, Apple Silicon) + +**How to contribute:** +1. Fork the repo and create a branch +2. Make your changes with tests +3. Open a PR with a clear description of what and why ## License -Copyright (c) 2024-2026 Carmen Esteban. All rights reserved. No part of this software may be copied, modified, distributed or used without express written permission. +Apache License 2.0. See [LICENSE](LICENSE) for details. + ## Citation If you use diffuse-cpp in your research, please cite: ```bibtex -@software{diffuse_cpp_2026, - title={diffuse-cpp: High-Performance Inference for Diffusion Language Models}, - author={Carmen Estévez}, +@article{esteban2026diffuse, + title={Diffusion Language Models are Faster than Autoregressive on CPU: + An Empirical Study of the Memory-Compute Regime Inversion}, + author={Carmen Esteban}, year={2026}, - url={https://github.com/iafiscal1212/diffuse-cpp} + doi={10.5281/zenodo.19119814}, + url={https://doi.org/10.5281/zenodo.19119814} } ``` diff --git a/paper.pdf b/paper.pdf index b99b1ea..a509982 100644 Binary files a/paper.pdf and b/paper.pdf differ diff --git a/paper.tex b/paper.tex index ffef77d..946be4b 100644 --- a/paper.tex +++ b/paper.tex @@ -1,6 +1,6 @@ % Diffusion Language Models are Faster than Autoregressive on CPU -% v2.0 — March 22, 2026 -% Updated with inter-step KV cache results +% v2.1 — March 22, 2026 +% Updated with Dream-7B comparative benchmarks and inter-step KV cache results % % NOTE: Figures 1–4 must be generated separately (see research/benchmark/ % scripts or regenerate with matplotlib). Place as fig1.pdf, fig2.pdf, @@ -42,25 +42,25 @@ Diffusion language models (dLLMs) are widely considered slower than autoregressi on commodity CPUs, dLLMs can outperform optimized AR inference. We identify the mechanism---a regime inversion from memory-bound (AR) to compute-bound (diffusion)---and validate it with systematic benchmarks. We present \texttt{diffuse-cpp}, the first C++ -inference engine for diffusion LLMs with GGML quantization support. On a 12-core AMD EPYC -with LLaDA-8B Q4\_K\_M, \texttt{diffuse-cpp} achieves 15--28~tok/s with entropy-exit -scheduling, inter-step KV cache, and 256-token generation on easy prompts---up to -$3.2\times$ faster than \texttt{llama.cpp} with Llama-3-8B Q4\_K\_M (8.51~tok/s) on the -same hardware. Thread scaling reaches $7.5\times$ from 1 to 12 cores for diffusion versus -saturation at 4 cores for AR. An entropy-based adaptive scheduler reduces denoising steps -from 16 to 2--4 on easy prompts without quality loss, providing up to $6\times$ speedup -over the F16 baseline. An inter-step KV cache reuses Key and Value tensors between -denoising steps, providing $1.6\times$ average speedup with no quality degradation and -implicit regularization benefits. Increasing the generation buffer from 64 to 256 tokens -yields 20\% lower cost per token, confirming that diffusion's matrix-matrix advantage -amplifies with sequence length. These results suggest that diffusion models may be a -viable path toward democratizing LLM inference on commodity hardware without GPU dependency. +inference engine for diffusion LLMs with GGML quantization support. On a 12-core AMD EPYC, +\texttt{diffuse-cpp} supports two models---LLaDA-8B (Llama backbone, MHA) and +Dream-7B (Qwen2.5 backbone, GQA)---and achieves 14--28~tok/s with entropy-exit +scheduling, inter-step KV cache, and 256-token generation on easy prompts, up to +$3.3\times$ faster than \texttt{llama.cpp} (8.51~tok/s) on the same hardware. Dream +excels at math and code (21.6~tok/s, correctly solving arithmetic), while LLaDA excels +at translation (27.7~tok/s). Thread scaling reaches $7.5\times$ from 1 to 12 cores for +diffusion versus saturation at 4 cores for AR. An entropy-based adaptive scheduler +reduces denoising steps from 16 to 2--4 on easy prompts without quality loss. An +inter-step KV cache reuses Key and Value tensors between denoising steps, providing +$1.6\times$ average speedup with implicit regularization benefits. These results suggest +that diffusion models may be a viable path toward democratizing LLM inference on commodity +hardware without GPU dependency. \end{abstract} \textbf{Keywords:} diffusion language models, CPU inference, memory-bound, compute-bound, -LLM acceleration, quantization, adaptive scheduling, inter-step cache +LLM acceleration, quantization, adaptive scheduling, inter-step cache, multi-model -\textbf{License:} CC-BY-4.0 (paper), AGPL-3.0 (code) +\textbf{License:} CC-BY-4.0 (paper), Apache-2.0 (code) \section{Introduction} @@ -92,7 +92,7 @@ MDLM~\cite{sahoo2024} report wall-clock times on A100 and H100 GPUs, where the m memory bandwidth makes AR models fast and the compute advantages of diffusion are less pronounced. No prior work has measured dLLM inference on commodity CPUs. -This paper makes five contributions: +This paper makes six contributions: \begin{enumerate} \item \textbf{First empirical demonstration} of the memory-compute regime inversion on @@ -100,7 +100,9 @@ This paper makes five contributions: while AR inference saturates at 4 cores ($2.4\times$). \item \textbf{\texttt{diffuse-cpp}}: the first C++ inference engine for dLLMs, built on - GGML~\cite{gerganov2023}, with support for F16, Q8\_0, and Q4\_K\_M quantization. + GGML~\cite{gerganov2023}, supporting two model architectures: LLaDA-8B + (Llama backbone, MHA) and Dream-7B (Qwen2.5 backbone, GQA). Both use + F16, Q8\_0, and Q4\_K\_M quantization. \item \textbf{Entropy-exit adaptive scheduling}: an entropy-based early termination mechanism that reduces denoising steps from 16 to 2--4 on easy prompts, providing up @@ -111,8 +113,13 @@ This paper makes five contributions: Achieves $1.6\times$ average speedup with an implicit regularization effect that improves output quality on 3 of 8 benchmarked prompts. +\item \textbf{Multi-model comparative benchmarking}: systematic comparison of two + dLLM architectures (MHA vs GQA) on identical hardware, revealing complementary + strengths---Dream-7B excels at math and code while LLaDA-8B excels at translation. + \item \textbf{Systematic benchmarking}: 288 configurations with 3 repetitions each, - plus 8 diverse real prompts, totaling 6.5 hours of continuous CPU measurement. + plus 8 diverse real prompts across 2 models, totaling over 8 hours of continuous + CPU measurement. \end{enumerate} @@ -151,11 +158,14 @@ bidirectional (non-causal) masking. \subsection{Prior Work} LLaDA~\cite{nie2025} introduced masked discrete diffusion for language modeling with a -Llama-style backbone. SEDD~\cite{lou2024} proposed score-based discrete diffusion. -MDLM~\cite{sahoo2024} simplified the training objective. Prophet~\cite{li2025} -introduced speculative decoding for discrete diffusion, using a confidence-gap criterion -for early stopping. EAGS~\cite{koh2024} and Fast-dLLM~\cite{wu2025} explored -entropy-adaptive scheduling. All prior work benchmarked on GPU. +Llama-style backbone and Multi-Head Attention (MHA). Dream~\cite{ye2025} adopted a +Qwen2.5 backbone with Grouped Query Attention (GQA), autoregressive logit shift for +causal bias, and additional remasking strategies. SEDD~\cite{lou2024} proposed +score-based discrete diffusion. MDLM~\cite{sahoo2024} simplified the training objective. +Prophet~\cite{li2025} introduced speculative decoding for discrete diffusion, using a +confidence-gap criterion for early stopping. EAGS~\cite{koh2024} and +Fast-dLLM~\cite{wu2025} explored entropy-adaptive scheduling. All prior work +benchmarked on GPU. For CPU inference, \texttt{llama.cpp}~\cite{gerganov2023b} is the state of the art for AR models, achieving near-theoretical throughput through GGML's optimized SIMD kernels @@ -244,13 +254,22 @@ between 16 and 32 cores on current hardware. built on the GGML tensor library~\cite{gerganov2023}---the same foundation as \texttt{llama.cpp}. This section describes its design. -\textbf{Forward pass.} The model implements a standard Llama transformer architecture -with one critical difference: attention is bidirectional (no causal mask). All token -positions attend to all others at every step. There is no KV cache in the standard -autoregressive sense; the full attention computation is performed at each denoising step. -While this appears wasteful relative to AR inference, it is precisely this structure that -enables the compute-bound regime: the large matrix-matrix multiplications at each step -amortize memory access costs. +\textbf{Supported architectures.} \texttt{diffuse-cpp} supports two model families: + +\begin{itemize} +\item \textbf{LLaDA-8B}~\cite{nie2025}: Llama backbone, 32 layers, 4096 hidden dim, + Multi-Head Attention (32 query / 32 KV heads), SwiGLU FFN (12288 intermediate), + vocabulary 126{,}464, RoPE $\theta$=500{,}000. +\item \textbf{Dream-7B}~\cite{ye2025}: Qwen2.5 backbone, 28 layers, 3584 hidden dim, + Grouped Query Attention (28 query / 4 KV heads), SwiGLU FFN (18944 intermediate), + vocabulary 152{,}064, RoPE $\theta$=1{,}000{,}000. Dream adds QKV biases (kept at F32 + in all quantizations), an autoregressive logit shift for causal bias, and additional + remasking strategies (\texttt{maskgit\_plus}, \texttt{topk\_margin}). +\end{itemize} + +Both models use bidirectional (non-causal) attention. The shared forward pass differs +only in GQA handling: for Dream, each KV head is expanded to serve $n_\text{rep}=7$ +query heads via grouped repetition before attention computation. \textbf{Denoising loop.} Generation proceeds as follows: (1) initialize a sequence of $B$ mask tokens; (2) perform a forward pass to obtain logits for all positions; (3) for @@ -259,14 +278,14 @@ the scheduling policy; (5) repeat until all positions are unmasked or the step b exhausted. \textbf{Model format.} Models are stored in GGUF format, converted from HuggingFace -SafeTensors via a Python script (\texttt{tools/convert-llada.py}). The converter maps -LLaDA's tensor names to GGML conventions and validates architecture parameters (hidden -size, number of heads, vocabulary size, RoPE configuration). +SafeTensors via dedicated Python scripts (\texttt{tools/convert-llada.py} and +\texttt{tools/convert-dream.py}). LLaDA produces 226 tensors; Dream produces 339 +tensors (255 weights + 84 QKV biases). \textbf{Quantization.} \texttt{diffuse-cpp} supports three quantization levels via -\texttt{diffuse-quantize}: F16 (14.9~GB), Q8\_0 (8.4~GB), and Q4\_K\_M (5.1~GB). -Quantization is performed weight-only; activations remain in FP32. The Q4\_K\_M format -uses mixed 4-bit/6-bit precision with per-block scaling, following the GGML specification. +\texttt{diffuse-quantize}: F16, Q8\_0, and Q4\_K\_M. For LLaDA: 14.9/8.4/5.1~GB; +for Dream: 15.2/8.6/5.3~GB. Quantization is weight-only; activations remain in FP32. +QKV biases (Dream only) are preserved at F32 in all quantization levels. \textbf{Scheduling policies.} Two scheduling policies are implemented. \texttt{low\_confidence} is the default baseline: at each step, it unmasks a fixed @@ -594,22 +613,76 @@ active set to include positions that changed within the last $N$ steps. At $N$=5 fidelity (exact match with uncached output) reaches 59.4\% with $1.64\times$ speedup---a useful trade-off when output reproducibility matters. +\subsection{Multi-Model Comparison: Dream-7B vs LLaDA-8B} +\label{sec:multimodel} + +Table~\ref{tab:multimodel} compares the two supported architectures on all 8 prompts +under identical conditions (Q4\_K\_M, \texttt{entropy\_exit} + inter-step cache, 12 +threads, seed=42). Dream generates $B$=64 tokens; LLaDA generates $B$=256. + +\begin{table}[h] +\centering +\caption{Dream-7B vs LLaDA-8B (Q4\_K\_M, entropy\_exit + cache, 12 threads). Bold indicates the faster model per prompt.} +\label{tab:multimodel} +\begin{tabular}{lrrrrrr} +\toprule + & \multicolumn{2}{c}{\textbf{Dream-7B}} & \multicolumn{2}{c}{\textbf{LLaDA-8B}} & \multicolumn{2}{c}{\textbf{vs llama.cpp}} \\ +\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} +\textbf{Prompt} & \textbf{tok/s} & \textbf{Steps} & \textbf{tok/s} & \textbf{Steps} & \textbf{Dream} & \textbf{LLaDA} \\ +\midrule +Capital of France? & \textbf{21.6} & 2 & 22.4 & 3 & $2.5\times$ & $2.6\times$ \\ +Translate to French & 14.3 & 6 & \textbf{25.7} & 2 & $1.7\times$ & $3.0\times$ \\ +$15 \times 23 = ?$ & \textbf{21.6} & 2 & 6.0 & 16 & $2.5\times$ & $0.7\times$ \\ +Translate to Spanish & 13.2 & 10 & \textbf{23.3} & 5 & $1.6\times$ & $2.7\times$ \\ +Python \texttt{is\_prime} & \textbf{8.2} & 7 & 4.5 & 15 & $1.0\times$ & $0.5\times$ \\ +Why sky is blue & 4.9 & 16 & \textbf{5.0} & 16 & $0.6\times$ & $0.6\times$ \\ +List the planets & 4.9 & 16 & \textbf{9.5} & 16 & $0.6\times$ & $1.1\times$ \\ +Poem about ocean & 4.5 & 16 & \textbf{5.0} & 16 & $0.5\times$ & $0.6\times$ \\ +\midrule +\textbf{Average} & \textbf{11.6} & & \textbf{12.7} & & $1.4\times$ & $1.5\times$ \\ +\bottomrule +\end{tabular} +\end{table} + +\textbf{Complementary strengths.} The two models exhibit complementary performance +profiles. Dream-7B excels at \emph{math and code}: it correctly solves $15 \times 23 = 345$ +in 2 steps (21.6~tok/s), where LLaDA requires all 16 steps and produces an incorrect +answer. Dream also generates a complete, correct \texttt{is\_prime()} function in 7 +steps (8.2~tok/s) versus LLaDA's 15 steps (4.5~tok/s). LLaDA-8B excels at +\emph{translation}: French translation converges in 2 steps at 25.7~tok/s ($3.0\times$ +llama.cpp), while Dream requires 6 steps (14.3~tok/s). Both models struggle with +creative writing (4.5--5.0~tok/s), requiring all 16 steps. + +\textbf{Architecture effects.} Dream's GQA (28/4 heads) reduces KV computation by +$7\times$ compared to LLaDA's MHA (32/32 heads), but this advantage is partially offset +by Dream's smaller generation buffer ($B$=64 vs $B$=256). The inter-step cache benefits +both architectures; for Dream, cached K,V are stored post-GQA-expansion (at full +$n_\text{head}$ dimensionality) to avoid recomputing the grouped repetition on each step. + +\textbf{Practical recommendation.} Users should select the model based on their primary +use case: Dream for math, code, and factual queries; LLaDA for translation and +conversational tasks. Both outperform \texttt{llama.cpp} on 5--6 of 8 prompts. + \section{Limitations} We are transparent about the limitations of this work. -\textbf{Model quality.} LLaDA-8B produces noticeably lower-quality outputs than -Llama-3-8B. We observed repetitions (``the and and molecules''), incomplete outputs on -code prompts, and mediocre translations. The throughput comparison is between paradigms, -not quality-equivalent models. A fair comparison would require a diffusion model trained -to match Llama-3-8B quality, which does not yet exist. +\textbf{Model quality.} Both LLaDA-8B and Dream-7B produce lower-quality outputs than +their AR counterparts (Llama-3-8B, Qwen2.5-7B). LLaDA shows occasional repetitions and +incomplete code; Dream produces higher-quality math and code but sometimes generates +hallucinated content. The throughput comparison is between paradigms, not +quality-equivalent models. -\textbf{Different models.} We compare LLaDA-8B (diffusion) against Llama-3-8B -(autoregressive). These share the same parameter count and Llama backbone architecture -but differ in training procedure, data, and generation mechanism. The comparison -demonstrates the \emph{computational} regime inversion, not a head-to-head model quality -contest. +\textbf{Different models.} We compare dLLMs (LLaDA-8B, Dream-7B) against AR models +(Llama-3-8B). These share similar parameter counts and backbone architectures but differ +in training procedure, data, and generation mechanism. The comparison demonstrates the +\emph{computational} regime inversion, not a head-to-head model quality contest. + +\textbf{Generation buffer asymmetry.} Dream benchmarks use $B$=64 tokens while LLaDA +uses $B$=256. This reflects practical constraints (Dream's Qwen2.5 tokenizer produces +shorter outputs) but means the per-token throughput comparison is not perfectly +controlled. Dream would likely achieve higher throughput at $B$=256. \textbf{Prior art on scheduling.} Entropy-based scheduling is not novel. Prophet~\cite{li2025}, EAGS~\cite{koh2024}, and Fast-dLLM~\cite{wu2025} proposed @@ -656,7 +729,9 @@ demonstrates that significant speedups are achievable through caching strategies Further optimizations remain unexplored: bidirectional Flash Attention~\cite{dao2022} adapted for non-causal masks, delta attention (recomputing only changed hidden state contributions), batched inference for serving workloads, generation buffers beyond 256 -tokens, and support for additional architectures (SEDD, MDLM). +tokens, and support for additional architectures (SEDD, MDLM). Dream-7B's GQA +architecture also opens the possibility of a more memory-efficient inter-step cache +that stores K,V at the reduced KV-head dimensionality rather than post-expansion. \textbf{Better diffusion models.} The regime inversion becomes practically relevant when dLLM quality matches AR models. Investment in larger, better-trained diffusion models @@ -673,15 +748,15 @@ CPUs, however, the computational regime inverts: AR inference hits a hard bandwi ceiling while diffusion inference scales with available compute. We demonstrated this empirically with \texttt{diffuse-cpp}, the first C++ inference -engine for diffusion LLMs. On an AMD EPYC 12-core CPU, thread scaling reaches +engine for diffusion LLMs, supporting two architectures: LLaDA-8B (Llama/MHA) and +Dream-7B (Qwen2.5/GQA). On an AMD EPYC 12-core CPU, thread scaling reaches $7.4\times$ for diffusion versus $2.4\times$ for AR. With Q4\_K\_M quantization, -entropy-exit scheduling, inter-step KV cache, and 256-token generation, -\texttt{diffuse-cpp} achieves 15--28~tok/s on real prompts---up to $3.2\times$ faster -than \texttt{llama.cpp}'s 8.51~tok/s on the same hardware, with 6 of 8 prompts -outperforming the AR baseline. The inter-step cache provides $1.6\times$ average -speedup with no quality degradation. Increasing the generation buffer from 64 to 256 -tokens reduces per-token cost by 20\%, confirming that diffusion's advantage amplifies -with sequence length. +entropy-exit scheduling, and inter-step KV cache, \texttt{diffuse-cpp} achieves +14--28~tok/s on easy prompts---up to $3.3\times$ faster than \texttt{llama.cpp}'s +8.51~tok/s on the same hardware. The two models exhibit complementary strengths: +Dream excels at math and code (21.6~tok/s), while LLaDA excels at translation +(27.7~tok/s). The inter-step cache provides $1.6\times$ average speedup with no quality +degradation. The contribution is not a claim that diffusion is universally faster. It is the identification and empirical validation of a hardware-dependent regime inversion, and the @@ -695,7 +770,8 @@ The code, models, benchmark data, and this paper are publicly available under op This work was inspired by the GGML library and llama.cpp~\cite{gerganov2023b}. The entropy-exit scheduler builds on ideas from Prophet~\cite{li2025} and the -entropy-adaptive scheduling literature~\cite{koh2024,wu2025}. Figures~1--3 were +entropy-adaptive scheduling literature~\cite{koh2024,wu2025}. Dream support was +developed using the architecture specifications from~\cite{ye2025}. Figures~1--3 were generated with Matplotlib. @@ -766,6 +842,13 @@ Chengyue Wu, Hao Zhang, Shuchen Xue, Zhijian Liu, Shizhe Diao, Ligeng Zhu, cache and parallel decoding. \newblock \emph{arXiv preprint arXiv:2505.22618}, 2025. +\bibitem[Ye et~al.(2025)]{ye2025} +Jiacheng Ye, Shansan Gong, Liheng Chen, Lin Zheng, Mukai Li, Thong Nguyen, + Kaiyan Zhang, Shuicheng Yan, Silvio Savarese, Caiming Xiong, and Yingbo Zhou. +\newblock Dream 7B -- Scalable generation of structured and unstructured content + from diffusion language modeling. +\newblock \emph{arXiv preprint arXiv:2504.16915}, 2025. + \end{thebibliography}