Skip to content

Latest commit

 

History

History
100 lines (77 loc) · 3.68 KB

vllm_setup.md

File metadata and controls

100 lines (77 loc) · 3.68 KB

Serving the backbone with vLLM

MoCA-Fin talks to any OpenAI-compatible chat endpoint. For the paper we serve Qwen/Qwen3.6-27B locally with vLLM. This guide covers a 4×H100 node.


1. (Recommended) Redirect caches off $HOME

On shared clusters, keep the ~52 GB of weights and the vLLM/triton compile caches off your home quota:

export CACHE_ROOT=/path/to/scratch/.cache          # roomy, writable
mkdir -p $CACHE_ROOT/{huggingface,vllm,torch,xdg,triton}
export HF_HOME=$CACHE_ROOT/huggingface
export HUGGINGFACE_HUB_CACHE=$HF_HOME/hub
export HF_DATASETS_CACHE=$HF_HOME/datasets
export VLLM_CACHE_ROOT=$CACHE_ROOT/vllm
export TRITON_CACHE_DIR=$CACHE_ROOT/triton
export TORCH_HOME=$CACHE_ROOT/torch
export XDG_CACHE_HOME=$CACHE_ROOT/xdg

The first vllm serve downloads the weights once into $HF_HOME/hub.


2. Launch vLLM (4×H100)

--tensor-parallel-size must equal the GPU count.

CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve Qwen/Qwen3.6-27B \
    --port 8000 \
    --tensor-parallel-size 4 \
    --max-model-len 65536 \
    --gpu-memory-utilization 0.85 \
    --reasoning-parser qwen3 \
    --trust-remote-code \
    --limit-mm-per-prompt '{"image": 8}'
  • --max-model-len: 65536 is ample for every text benchmark. Only DocMath-Complong (≈18k-word contexts) benefits from going higher; raise to 262144 if you have KV headroom, or rely on the loader's automatic context truncation.
  • --reasoning-parser qwen3 routes <think> content into reasoning_content and the final answer into content. MoCA-Fin disables thinking by default for the JSON role calls (VLLM_ENABLE_THINKING=0), which is what the paper used.
  • --limit-mm-per-prompt '{"image": 8}' enables the multimodal path used by FinChart-Bench. Qwen3.6-27B is itself multimodal, so one server handles both text and vision.

Already have the weights cached?

Serve straight from the local snapshot directory to skip any hub lookup:

vllm serve /path/to/hub/models--Qwen--Qwen3.6-27B/snapshots/<rev> \
    --served-model-name Qwen/Qwen3.6-27B  ...   # keeps the clean API name

Smoke test

curl -s http://localhost:8000/v1/models | python -m json.tool
curl -s http://localhost:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"Qwen/Qwen3.6-27B","messages":[{"role":"user","content":"hi"}],"max_tokens":16}'

3. Point the agent at the server

export LLM_BACKEND=vllm
export VLLM_BASE_URL=http://localhost:8000/v1
export VLLM_API_KEY=EMPTY
export VLLM_MODEL_NAME=Qwen/Qwen3.6-27B
# FinChart vision pass reuses the same server by default:
export VLLM_VISION_BASE_URL=$VLLM_BASE_URL
export VLLM_VISION_MODEL_NAME=$VLLM_MODEL_NAME

To go back to Azure OpenAI: unset LLM_BACKEND (or set LLM_BACKEND=azure) and provide AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, AZURE_DEPLOYMENT_NAME.


Gotchas

Topic Detail
TP size --tensor-parallel-size must equal the number of visible GPUs.
--workers (eval) A single vLLM server batches concurrent requests. Start at 8–16; raise until GPU util saturates.
Empty content With the reasoning parser, if generation is cut off inside <think>, content is empty; the client falls back to reasoning_content.
JSON mode response_format={"type":"json_object"} is supported via xgrammar/outlines; the client falls back to free-form + extraction if the server rejects it.
OOM on long context Drop --max-model-len (e.g. 65536) or lower --gpu-memory-utilization. None of the text benchmarks need 256k.
Different backbone The paper also reports Gemma-4-31B and Qwen-3.5-9B. Just change --model / VLLM_MODEL_NAME; prompts are unchanged.