DeepSeek-V3.2-Exp Documentation

repository·main·Indexed 23 days ago

https://github.com/deepseek-ai/deepseek-v3.2-exp

Experimental large language model featuring DeepSeek Sparse Attention (DSA) for improved long-context efficiency. Includes guides for converting HuggingFace weights, running interactive chat via torchrun, and deployment using SGLang and vLLM. Provides references for high-performance CUDA kernels via DeepGEMM and FlashMLA, and research-oriented kernels via TileLang.

Tokens
1.1K
Snippets
4
Records
7
Agent score
32%

What's inside DeepSeek-V3.2-Exp

  1. DeepSeek-V3.2-Exp Overview

    main

    DeepSeek-V3.2-Exp is an experimental model that introduces DeepSeek Sparse Attention (DSA). DSA provides fine-grained sparse attention to improve training and inference efficiency in long-context scenarios while maintaining performance levels comparable to the V3.1-Terminus model.

    Key architectural note: When implementing custom inference, note that the input tensor to RoPE in the indexer module requires a non-interleaved layout, whereas RoPE in the MLA module expects an interleaved layout.

  2. Run DeepSeek-V3.2-Exp locally using HuggingFace weights

    main

    To run the model locally using the provided inference demo, you must first convert the HuggingFace model weights into the format required by the demo. You will need to specify the number of experts (e.g., 256) and set the MP (Model Parallel) variable to match your available GPU count.

    After conversion, you can launch an interactive chat interface using torchrun with the appropriate configuration file.

    cd inference
    export EXPERTS=256
    python convert.py --hf-ckpt-path ${HF_CKPT_PATH} --save-path ${SAVE_PATH} --n-experts ${EXPERTS} --model-parallel ${MP}
    
    export CONFIG=config_671B_v3.2.json
    torchrun --nproc-per-node ${MP} generate.py --ckpt-path ${SAVE_PATH} --config ${CONFIG} --interactive
  3. Run the DeepSeek V3.2 interactive chat interface

    main

    To launch an interactive chat session, use torchrun to distribute the process across your GPUs. You must provide the path to the converted checkpoint, the specific model configuration JSON file, and the model parallel degree (MP).

    Ensure you have exported the CONFIG environment variable pointing to your configuration file (e.g., config_671B_v3.2.json) before running the command.

    export CONFIG=config_671B_v3.2.json
    torchrun --nproc-per-node ${MP} generate.py --ckpt-path ${SAVE_PATH} --config ${CONFIG} --interactive
  4. Convert HuggingFace weights for DeepSeek V3.2 inference

    main

    Before running the inference demo, you must convert HuggingFace model weights into the format required by the DeepSeek inference engine. You need to specify the number of experts, the model parallel degree (MP), the source HuggingFace checkpoint path, and the destination save path.

    Set the EXPERTS environment variable (e.g., 256) to match the model's expert count and MP to match your available GPU count.

    cd inference
    export EXPERTS=256
    python convert.py --hf-ckpt-path ${HF_CKPT_PATH} --save-path ${SAVE_PATH} --n-experts ${EXPERTS} --model-parallel ${MP}
  5. Run DeepSeek-V3.2-Exp using SGLang

    main

    SGLang supports DeepSeek-V3.2-Exp via Docker containers optimized for different hardware architectures.

    1. Install via Docker

    Select the image corresponding to your hardware:

    • H200: lmsysorg/sglang:dsv32
    • MI350: lmsysorg/sglang:dsv32-rocm
    • NPUs: lmsysorg/sglang:dsv32-a2 or lmsysorg/sglang:dsv32-a3

    2. Launch the Server

    Use the following command to launch the server with Tensor Parallelism (--tp) and Data Parallelism (--dp) enabled, along with --enable-dp-attention for optimized performance.

    # Example Docker Pulls
    docker pull lmsysorg/sglang:dsv32
    
    # Launch Command
    python -m sglang.launch_server --model deepseek-ai/DeepSeek-V3.2-Exp --tp 8 --dp 8 --enable-dp-attention