Skip to main content

DFastLLM

DFastLLM

🚀 High-Performance Inference Engine for Diffusion Language Models

PyPI CI License Python Docs

Quick StartFeaturesPerformanceDocumentationContributing


🎯 What is DFastLLM?

DFastLLM is a production-ready inference engine optimized for Diffusion Language Models (LLaDA, Dream, MDLM). Unlike autoregressive models that generate tokens sequentially, diffusion LLMs generate multiple tokens in parallel through iterative denoising — enabling massive throughput gains.

Traditional LLM:     Token → Token → Token → Token (sequential)
Diffusion LLM:       [████████] → [████████] → Done! (parallel)

⚡ Quick Start

Installation

pip install dfastllm

Generate Text

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from dfastllm.engine.diffusion import DiffusionEngine

# Load model
model = AutoModelForCausalLM.from_pretrained(
    "GSAI-ML/LLaDA-8B-Instruct",
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained("GSAI-ML/LLaDA-8B-Instruct", trust_remote_code=True)

# Create engine and generate
engine = DiffusionEngine(model, tokenizer)
output = engine.generate("What is artificial intelligence?", max_tokens=64)
print(output)

With Quantization (2x Memory Savings)

pip install dfastllm[quantization]
from dfastllm import load_quantized_model

# Load 8B model in ~8GB instead of ~16GB
model = load_quantized_model("GSAI-ML/LLaDA-8B-Instruct", "int4")

Batch Processing (4x Throughput)

prompts = ["What is AI?", "What is ML?", "What is DL?", "What is NLP?"]
outputs = engine.generate(prompts, max_tokens=64)
# Throughput: 1,000+ tok/s

🔥 Features

Feature Description Status
Diffusion Generation Parallel token unmasking
Batch Processing Process multiple requests
INT4/INT8 Quantization 2-4x memory reduction
torch.compile JIT compilation for 2x speedup
FlashAttention Memory-efficient attention
Multi-GPU Tensor parallelism
OpenAI API Drop-in compatible server
Streaming Real-time token streaming
CUDA Graphs Zero-overhead inference
Kubernetes Production deployment

📊 Performance

Benchmarked on NVIDIA L40S (46GB) with LLaDA-8B:

Batch Size Throughput Latency Speedup
1 265 tok/s 241 ms 1.0x
2 484 tok/s 132 ms 1.8x
4 786 tok/s 81 ms 3.0x
8 1,056 tok/s 61 ms 4.0x

Memory Usage

Configuration Memory Notes
BF16 16.8 GB Default
INT8 ~10 GB 1.7x reduction
INT4 ~6 GB 2.8x reduction

🐳 Docker

# GPU image
docker run --gpus all -p 8000:8000 ghcr.io/dfastllm-project/dfastllm:gpu

# CPU image
docker run -p 8000:8000 ghcr.io/dfastllm-project/dfastllm:latest

☸️ Kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dfastllm
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: dfastllm
        image: ghcr.io/dfastllm-project/dfastllm:gpu
        resources:
          limits:
            nvidia.com/gpu: 1
        ports:
        - containerPort: 8000

🌐 OpenAI-Compatible API

Start the server:

dfastllm-serve --model GSAI-ML/LLaDA-8B-Instruct --port 8000

Use with OpenAI client:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")

response = client.chat.completions.create(
    model="GSAI-ML/LLaDA-8B-Instruct",
    messages=[{"role": "user", "content": "What is AI?"}],
    stream=True,
)

for chunk in response:
    print(chunk.choices[0].delta.content, end="")

🛠️ Supported Models

Model Parameters Status
LLaDA-8B-Instruct 8B ✅ Full Support
LLaDA-8B-Base 8B ✅ Full Support
Dream 7B ⚠️ Experimental
MDLM Various ⚠️ Experimental

📚 Documentation


🤝 Contributing

We welcome contributions! Here's how to get started:

# Clone the repo
git clone https://github.com/dfastllm-project/dfastllm.git
cd dfastllm

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

# Run linting
ruff check dfastllm/
black --check dfastllm/

See CONTRIBUTING.md for detailed guidelines.


📄 License

Apache 2.0 - See LICENSE for details.


🙏 Acknowledgments


Made with ❤️ by the DFastLLM Team

Release files for dfastllm 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dfastllm 0.0.4
File Size Uploaded
dfastllm-0.0.4.tar.gz 163.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dfastllm 0.0.4
File Interpreter ABI Platform
dfastllm-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 349.9 kB

Release files / dfastllm-0.0.4.tar.gz

Download URL dfastllm-0.0.4.tar.gz
Size 163.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3dcad96038fc747917d90afc6ed25c7c22b3be896f6fc6ff908854b4f0618a2d
BLAKE2b-256 checksum
How to use checksums
ead5d9da02a578b6e2f4679e6d6f8b634b7a396737e4c3162dcb54301f2a5189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / dfastllm-0.0.4-py3-none-any.whl

Download URL dfastllm-0.0.4-py3-none-any.whl
Size 186.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
002ad851b3694eb6975abc796cb3b0f821f90e62771512d26e6b8a252f546fb2
BLAKE2b-256 checksum
How to use checksums
10a4ae417ce8ad27da4bc8fe73b4d0a2cdd353925d34c8613d57ddb1628892ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page