Instructions to use SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora
- SGLang
How to use SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora with Docker Model Runner:
docker model run hf.co/SJTU-DENG-Lab/D2F_DiffuCoder_Instruct_7B_Lora
| license: apache-2.0 | |
| language: en | |
| library_name: transformers | |
| tags: | |
| - d2f | |
| - diffusion-llm | |
| - text-generation | |
| - dream | |
| - lora | |
| base_model: apple/DiffuCoder-7B-Instruct | |
| model_name: D2F_DiffuCoder_Instruct_7B_Lora | |
| # D2F LoRA adapter for DiffuCoder-7B-Instruct | |
| This repository contains the **LoRA adapter** for the `apple/DiffuCoder-7B-Instruct` model, trained using the **Discrete Diffusion Forcing (D2F)** method. | |
| This adapter allows the `DiffuCoder-7B-Instruct` diffusion LLM (dLLM) to achieve inference speeds that are significantly faster than both its original version and leading autoregressive (AR) models like LLaMA3, while maintaining comparable output quality. | |
| The D2F method and its results are detailed in the paper: **[D2F: Diffusion LLMs Can Do Faster-Than-AR Inference via Discrete Diffusion Forcing](https://arxiv.org/abs/2508.09192)**. | |
| - **Official Code:** [D2F GitHub Repository](https://github.com/zhijie-group/Discrete-Diffusion-Forcing) | |
| - **Demo Space:** [D2F-LLaDA-Instruct-8B](https://huggingface.co/spaces/zhijie3/D2F-LLaDA-Instruct-8B) | |
| - **The model is used in** [LoPA](https://github.com/zhijie-group/LoPA) | |
| ## Method: Discrete Diffusion Forcing (D2F) | |
| Diffusion LLMs (dLLMs) have long promised ultra-fast parallel decoding, but this potential was historically crippled by two main bottlenecks: | |
| 1. **KV Cache Incompatibility:** Their bidirectional attention mechanism prevented the use of the Key-Value Cache, a critical optimization in AR models. | |
| 2. **Strict Inter-Block Dependency:** Previous attempts at block-based generation required each block to be fully generated before starting the next, preventing true parallelism. | |
| **D2F** solves these issues with a novel hybrid approach: | |
| 1. **Hybrid Architecture:** D2F reframes text generation as a block-autoregressive process. | |
| * **Within a block:** Attention remains **bidirectional** to capture rich local context. | |
| * **Between blocks:** Attention is made **causal**, allowing the model to be fully compatible with the standard **KV Cache**. | |
| 2. **Pipelined Parallel Decoding:** D2F uses an efficient training and inference strategy. | |
| * **Training:** It uses *Asymmetric Distillation*, where a D2F student model learns to mimic a powerful bidirectional teacher model, efficiently transferring its capabilities to the fast, cache-friendly architecture. | |
| * **Inference:** It enables a dynamic **pipelined parallel decoder**. New text blocks are added to the pipeline as soon as their predecessors are only partially complete. This creates an asynchronous workflow that maximizes GPU utilization and dramatically boosts throughput. | |
| ## How to Use | |
| ⚠️ **Important:** This is a LoRA adapter and requires the official D2F codebase for inference. | |
| For detailed instructions and code, please refer to the official GitHub repository: | |
| ➡️ **https://github.com/zhijie-group/Discrete-Diffusion-Forcing** ⬅️ |