This guide provides step-by-step instructions for installing and using the dllm_plugin with vLLM.
- Python 3.9 or higher
- CUDA-capable GPU (for optimal performance)
- uv package manager
UV is a fast Python package manager. Install it following the official guide:
# On macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or using pip
pip install uvFor easy activation, add an alias to your shell configuration:
echo "alias uvon='source .venv/bin/activate'" >> ~/.zshrc # or ~/.bashrc for bash
source ~/.zshrcIf you prefer to set up everything from the plugin directory:
cd /path/to/diffuplug
# Create and activate virtual environment
uv venv
source .venv/bin/activate
# Install Diffulex
cd Diffulex
uv pip install -e Diffulex
# Install vLLM
uv pip install vllm
# Install the plugin
uv pip install -e .To verify the plugin is installed correctly:
from vllm import ModelRegistry
# Check if the diffusion models are registered
supported_archs = ModelRegistry.get_supported_archs()
print("DreamForDiffusionLM" in supported_archs) # Should print True
print("LLaDAForDiffusionLM" in supported_archs) # Should print Truepython example_usage.py \
--model /path/to/dream/or/llada/model \
--prompt "The future of AI is" \
--max-tokens 100from vllm import LLM, SamplingParams
# Load a Dream or LLaDA model
llm = LLM(
model="/path/to/model",
trust_remote_code=True
)
# Generate text
sampling_params = SamplingParams(temperature=0.8, max_tokens=100)
outputs = llm.generate(["Tell me about diffusion models"], sampling_params)
print(outputs[0].outputs[0].text)# Start the server
python -m vllm.entrypoints.openai.api_server \
--model /path/to/model \
--trust-remote-code
# In another terminal, use the API
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "/path/to/model",
"prompt": "Tell me about diffusion models",
"max_tokens": 100
}'If vLLM doesn't recognize the plugin:
-
Check installation:
uv pip list | grep dllm-plugin -
Verify entry points:
python -c "import pkg_resources; print([ep for ep in pkg_resources.iter_entry_points('vllm.general_plugins')])" -
Force plugin loading:
export VLLM_PLUGINS=register_dllm_models
If you get import errors related to d2f_engine:
-
Make sure Diffulex is installed:
uv pip list | grep d2f -
Install it if missing:
cd /path/to/Diffulex uv sync source .venv/bin/activate uv pip install -e .
Ensure your model's config.json contains:
{
"architectures": ["DreamForDiffusionLM"]
}or
{
"architectures": ["LLaDAForDiffusionLM"]
}To uninstall the plugin:
uv pip uninstall dllm-pluginFor development, install with additional dependencies:
uv pip install -e ".[dev]"Or if you want to use UV's project management:
# From the plugin directory
uv sync --all-extras- Check out the README.md for detailed usage examples
- See example_usage.py for more code examples
- Read the vLLM documentation for advanced configurations