Skip to content
ParCISPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

DSparse: Taming Long-Context Agentic Serving with Distributed Host-Backed Sparse Attention

License

DSparse is a distributed host-backed sparse-attention serving system built on SGLang (v0.5.13) and FlashMLA for long-context agentic LLM workloads.

This repository provides the Artifact Evaluation codebase and reproduction scripts for the DSparse paper (currently under review at VLDB).


Repository Structure & Branches

This repository (https://github.com/ParCIS/DSparse.git) hosts three branches so that DSparse and all patched baselines can be checked out via Git worktrees from a single repository:

Branch Role & Included Extensions
main (default) DSparse system implementation, 3rdparty/FlashMLA kernels (cutlass submodule), and artifact/ reproduction suite
baseline/sglang SGLang v0.5.13 used for TP8, DPA8, TP8+HiCache, DPA8+HiCache, and HiSparse, patched with GLM-5.2 AWQ INT4 support, multi-turn prefix caching for HiSparse (HiSparseRadixCache), and opt-in profiling/trace hooks
baseline/echo ECHO baseline patched with GLM-5.2 AWQ Marlin, FP8 KV cache, DPA rank routing, and multi-turn RadixCache prefix reuse

Overlapping paper experiments (sharing datasets, trace collection, server deployments, or profiling harnesses) are consolidated into 7 self-contained folders under artifact/:

DSparse/
├── README.md                                 # This file
├── 3rdparty/FlashMLA/                        # DSparse FlashMLA & distributed indexer kernels
├── python/                                   # DSparse serving engine (SGLang v0.5.13 base)
├── sgl-kernel/                               # SM90 CUDA kernel build scripts
└── artifact/
    ├── config.sh                             # Unified paths (models, datasets, envs, outputs)
    ├── env/                                  # Environment activation, requirements, kernel build
    │   ├── use.sh                            # Switch active env: dsparse | sglang | echo | agentx
    │   ├── build_kernel.sh                   # Build SM90 FlashMLA ops & verify imports
    │   ├── requirements_dsparse.txt          # Python dependencies for DSparse & SGLang baselines
    │   ├── requirements_echo.txt             # Python dependencies for ECHO baseline
    │   └── requirements_agentx.txt           # Python dependencies for AgentX harness & plotting
    ├── common/                               # Shared server launchers, DPA sticky proxy, helpers
    ├── table1/                               # Table 1: AgentX Weka trace statistics
    ├── figure2/                              # Figure 2: Indexer latency share (GLM-5.2)
    ├── figure4_table3_figure6/               # Figures 4, 6 & Table 3: KV reuse & hash assignment
    ├── table2_figure9_table4/                # Tables 2, 4 & Figure 9: Concurrent AgentX serving & KV capacity
    ├── figure10/                             # Figure 10: 315-turn 714K long-context session
    ├── figure11_figure12/                    # Figures 11 & 12: E2E ablation & latency breakdown
    └── figure13_figure14_figure15/           # Figures 13, 14 & 15: Component efficiency & scaling

Experimental Environment

All results in the paper were measured on a single GPU server with the following configuration:

Hardware

  • GPU: 8× NVIDIA H100 80GB HBM3 (NVLink: 18 links/GPU, 900 GB/s bidirectional; PCIe 5.0 ×16: 64 GB/s host interconnect)
  • CPU: 2× Intel Xeon Platinum 8558 (96 physical cores / 192 threads)
  • Host Memory: 2.0 TiB DDR5 DRAM (at least 512 GiB recommended to host the 256 GiB KV pool and runtime buffers)
  • Storage: ~1.2 TB free disk space (~475 GB for GLM-5.2-AWQ-INT4, ~355 GB for DeepSeek-V3.2-AWQ, ~25 GB for datasets and traces)

Software Stack

  • OS & Driver: Ubuntu 22.04 LTS (Linux 5.15), NVIDIA Driver 580.126+, CUDA Toolkit 13.0 (nvcc 13.0.48), CMake 3.22+, GCC 13.4 (via Conda) / GCC 11.4
  • Isolated Python Environments (Python 3.12):
Environment Used By Key Packages
dsparse DSparse & SGLang/HiSparse baselines PyTorch 2.11.0+cu130, Triton 3.6.0, FlashInfer 0.6.12, DeepGEMM 0.1.2, sglang-kernel 0.4.3, transformers 5.8.1, compressed-tensors 0.20.1
echo ECHO baseline PyTorch 2.9.0+cu130, Triton 3.5.0, FlashInfer 0.5.0, DeepGEMM 2.1.1, sgl-kernel 0.3.16.post2, transformers 4.57.1, flash_mla
agentx Benchmark client & plotting agentx-harness 1.0.14, numpy, matplotlib, transformers

Setup & Installation

1. Clone Repository & Expand Baseline Worktrees

export WORKSPACE_ROOT=/path/to/workspace
mkdir -p "$WORKSPACE_ROOT" && cd "$WORKSPACE_ROOT"

# Clone DSparse (main branch + FlashMLA CUTLASS submodule)
git clone --recurse-submodules https://github.com/ParCIS/DSparse.git DSparse

# Expand the two patched baseline branches as sibling worktrees
git -C DSparse fetch origin baseline/sglang baseline/echo
git -C DSparse worktree add ../sglang origin/baseline/sglang
git -C DSparse worktree add ../ECHO   origin/baseline/echo
git -C ../ECHO submodule update --init --recursive

2. Create Python Environments

# (a) DSparse & SGLang environment
conda create -y -n dsparse python=3.12 gxx_linux-64=13.4 cuda-toolkit=13.0 -c conda-forge -c nvidia
conda run -n dsparse pip install -r DSparse/artifact/env/requirements_dsparse.txt

# (b) ECHO baseline environment
conda create -y -n echo python=3.12 cuda-toolkit=13.0 -c conda-forge -c nvidia
conda run -n echo pip install -r DSparse/artifact/env/requirements_echo.txt

# (c) AgentX benchmark & plotting environment
conda create -y -n agentx python=3.12 -c conda-forge
conda run -n agentx pip install -r DSparse/artifact/env/requirements_agentx.txt

3. Build CUDA Kernels

Build DSparse's SM90 FlashMLA / distributed-indexer kernels and verify imports:

# Configure environment paths first (see Step 5 below)
source DSparse/artifact/config.sh
bash DSparse/artifact/env/build_kernel.sh

Build ECHO's sgl-kernel, DeepGEMM, and FlashMLA (required only for running the ECHO baseline):

source DSparse/artifact/env/use.sh echo
cd "$ECHO_REPO_DIR/sglang/sgl-kernel" && make build && pip install dist/*.whl --force-reinstall --no-deps
cd "$ECHO_REPO_DIR/DeepGEMM" && ./install.sh && pip install dist/*.whl --force-reinstall --no-deps
# Install FlashMLA into the echo environment (or set ECHO_FLASHMLA_DIR in config.sh)
cd "$DSPARSE_ROOT/3rdparty/FlashMLA" && pip install --no-build-isolation -e .

4. Download Models & Datasets

export MODEL_ROOT="$WORKSPACE_ROOT/models"
export DATA_ROOT="$WORKSPACE_ROOT/data"
mkdir -p "$MODEL_ROOT" "$DATA_ROOT"

# Models (4-bit AWQ)
huggingface-cli download cyankiwi/GLM-5.2-AWQ-INT4       --local-dir "$MODEL_ROOT/GLM-5.2-AWQ-INT4"
huggingface-cli download QuantTrio/DeepSeek-V3.2-AWQ     --local-dir "$MODEL_ROOT/DeepSeek-V3.2-AWQ"

# Datasets
huggingface-cli download --repo-type dataset semianalysisai/cc-traces-weka-062126 \
    --local-dir "$DATA_ROOT/cc-traces-weka-062126"
huggingface-cli download --repo-type dataset THUDM/LongBench-v2 \
    --local-dir "$DATA_ROOT/LongBench-v2"

5. Configure Paths & Smoke Test

Edit DSparse/artifact/config.sh (or export the corresponding environment variables) to point to your local Conda environments, models, datasets, and output root:

export DSPARSE_ENV_DIR=/path/to/conda/envs/dsparse
export ECHO_ENV_DIR=/path/to/conda/envs/echo
export AGENTX_ENV_DIR=/path/to/conda/envs/agentx
export MODEL_ROOT=/path/to/models
export DATA_ROOT=/path/to/data
export RESULTS_ROOT=/path/to/results

Verify that DSparse boots cleanly on 8×H100:

source DSparse/artifact/config.sh
bash DSparse/artifact/common/launch/run_dsparse.sh --context-length 131072
# In another terminal:
curl -sf http://127.0.0.1:30000/health && echo "OK"

Reproducing Paper Results

Overview Matrix

Paper Result Folder Workload / Scope Hardware & Est. Time Primary Output(s)
Table 1 (§2.2) artifact/table1 Weka trace corpus statistics CPU only (~10 s) table1_weka_stats.md
Figure 2 (§3.2) artifact/figure2 GLM-5.2 indexer latency share (16K–128K) 8×H100 (~15 min) glm_indexer_proportion.pdf
Figure 4, Table 3, Figure 6 (§5–§6) artifact/figure4_table3_figure6 LongBench-v2 128K Top-k traces → LRU reuse, round-wise stats, 8-GPU hash assignment 8×H100 (~30 min trace) + CPU (~5 min analysis) glm_decode_cache_hit_rate.pdf, table3_prefill_reuse.md, glm_hash_hit_rate.pdf
Table 2, Figure 9, Table 4 (§3.3, §9.2) artifact/table2_figure9_table4 AgentX Weka ≤128K (C ∈ {1,4,8,16,32}), 7 methods × 2 models + KV capacity 8×H100 (~5 h/method full; ~45 min/method fast mode) table2_kv_capacity.md, agentx_pareto.pdf, table4_speedup_c32.md
Figure 10 (§9.3) artifact/figure10 315-turn 714K Weka session (debc7f69e2c2) on GLM-5.2 (5 methods) 8×H100 (~4 h sequential for all 5 methods) glm_long_session.pdf
Figures 11 & 12 (§9.4.1) artifact/figure11_figure12 E2E TP8 4-step ablation (Decode 128K, B=16; Prefill 128K+4K, B=1) 8×H100 (~40 min) glm_ablation_decode.pdf, glm_ablation_prefill.pdf
Figures 13, 14 & 15 (§9.4.2–§9.4.3) artifact/figure13_figure14_figure15 Single-layer scaling across W ∈ {1,2,4,8} GPUs (decode, prefill, indexer) 1–8×H100 (~40 min) glm_decode_scaling.pdf, glm_prefill_scaling.pdf, glm_indexer_normalized.pdf

All commands below assume you have sourced DSparse/artifact/config.sh from the repository root (cd DSparse).


1. Table 1 — AgentX Weka Trace Statistics (artifact/table1)

Computes per-session turns, peak context, input, extend, and output distributions (Mean / P50 / P90 / P99 / Max) and overall prefix-cache hit rate over cc-traces-weka-062126:

bash artifact/table1/run.sh

2. Figure 2 — Indexer Latency Share (artifact/figure2)

Profiles GLM-5.2 on SGLang TP8 (B=1) across cached prefix lengths 16K, 32K, 64K, 128K for a 2K-token extend prefill and one CUDA-Graphed decode step, then plots glm_indexer_proportion.pdf:

bash artifact/figure2/run.sh

3. Figures 4, 6 & Table 3 — KV Reuse & Hash-Based Assignment (artifact/figure4_table3_figure6)

These three evaluations share a single set of exact 128K LongBench-v2 Top-k traces (12 prompts spanning all 6 domains, 21 independent indexer layers mapped to 78 attention layers).

# Step 1: Collect 12×128K Top-k traces on 8×H100 (run once; also reused by Figures 13 & 14)
bash artifact/figure4_table3_figure6/run.sh collect

# Step 2: Run offline analyses to produce Figure 4, Table 3, and Figure 6
bash artifact/figure4_table3_figure6/run.sh analyze
# Or run an individual target: figure4 | table3 | figure6

4. Tables 2, 4 & Figure 9 — Concurrent Agentic Serving (artifact/table2_figure9_table4)

Replays all 82 Weka sessions with peak context ≤ 128K across concurrencies C ∈ {1, 4, 8, 16, 32} for all 7 methods (dsparse, tp, tp_hicache, dpa, dpa_hicache, hisparse, echo) on both GLM-5.2 and DeepSeek-V3.2. Server startup logs provide the measured executable KV capacities for Table 2, and the C=32 runs directly generate Table 4 alongside the Pareto curves in Figure 9.

# Prepare the ≤128K Weka trace subset (automatically invoked if missing)
bash artifact/table2_figure9_table4/run.sh prepare

# Run a single method on one 8×H100 node (can be parallelized across 7 nodes)
# MODEL_TAG: glm52 | dsv32
# METHOD:    dsparse | tp | tp_hicache | dpa | dpa_hicache | hisparse | echo | all
bash artifact/table2_figure9_table4/run.sh run glm52 dsparse
bash artifact/table2_figure9_table4/run.sh run dsv32 dsparse

# Optional fast validation mode (shorter duration & subset of concurrencies):
# DURATION=600 CONCURRENCIES="1 8 32" bash artifact/table2_figure9_table4/run.sh run glm52 dsparse

# Aggregate logs & generate Table 2, Figure 9 (agentx_pareto.pdf), and Table 4
bash artifact/table2_figure9_table4/run.sh plot

5. Figure 10 — Long-Context Agentic Session Serving (artifact/figure10)

Replays the 315-turn, 714K-token monotonic Weka session (debc7f69e2c2) on GLM-5.2 across dsparse, tp, dpa, hisparse, and echo, and plots per-turn TTFT and TPOT (glm_long_session.pdf):

# Run all 5 methods sequentially on one 8×H100 node (or pass a single method name)
bash artifact/figure10/run.sh all

# Generate Figure 10 and per-method completion statistics
bash artifact/figure10/run.sh plot

6. Figures 11 & 12 — E2E Ablation & Latency Breakdown (artifact/figure11_figure12)

Evaluates the 4-step TP8 staircase (Base → +KV Reuse → +Distributed Attention → +Distributed Indexer) on GLM-5.2 for both decode (128K, B=16, Figure 11) and extend prefill (128K + 4K, B=1, Figure 12):

# Run both decode and prefill E2E ablations and generate Figures 11 & 12
bash artifact/figure11_figure12/run.sh all

# Or run separately: decode | prefill | plot

7. Figures 13, 14 & 15 — Component Efficiency & Scalability (artifact/figure13_figure14_figure15)

Runs single-layer multi-GPU (W ∈ {1, 2, 4, 8}) benchmarks for decode sparse attention (Figure 13), prefill sparse attention (Figure 14), and the distributed indexer (Figure 15):

# Note: Figures 13 & 14 reuse the 128K Top-k traces from artifact/figure4_table3_figure6.
# Figure 15 (distributed indexer) is standalone and requires no model weights or traces.
bash artifact/figure13_figure14_figure15/run.sh all

# Or run separately: decode | prefill | indexer | plot

License & Acknowledgments

This project is licensed under the Apache License 2.0. DSparse builds upon SGLang and FlashMLA, and uses SemiAnalysis AgentX for end-to-end agentic serving evaluation.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages