Instructions to use internlm/Intern-S2-397B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/Intern-S2-397B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="internlm/Intern-S2-397B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("internlm/Intern-S2-397B") model = AutoModelForMultimodalLM.from_pretrained("internlm/Intern-S2-397B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use internlm/Intern-S2-397B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/Intern-S2-397B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/Intern-S2-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/internlm/Intern-S2-397B
- SGLang
How to use internlm/Intern-S2-397B 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 "internlm/Intern-S2-397B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/Intern-S2-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "internlm/Intern-S2-397B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/Intern-S2-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use internlm/Intern-S2-397B with Docker Model Runner:
docker model run hf.co/internlm/Intern-S2-397B
Upload deployment_guide.md
Browse files- deployment_guide.md +153 -0
deployment_guide.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Intern-S2-397B Deployment Guide
|
| 2 |
+
|
| 3 |
+
We recommend deploying the Intern-S2-397B model on H100 (x8) or H200 (x8) nodes. The next section provides deployment examples for the configurations listed below:
|
| 4 |
+
|
| 5 |
+
- Basic serving without MTP
|
| 6 |
+
- MTP speculative decoding
|
| 7 |
+
- Long-context inference with YaRN RoPE configuration
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
## LMDeploy (>=0.14.0)
|
| 11 |
+
|
| 12 |
+
- Basic Serving Without MTP
|
| 13 |
+
|
| 14 |
+
```bash
|
| 15 |
+
# proxy server
|
| 16 |
+
lmdeploy serve proxy --server-name ${proxy_server_ip} --server-port ${proxy_server_port}
|
| 17 |
+
|
| 18 |
+
# api_server
|
| 19 |
+
lmdeploy serve api_server \
|
| 20 |
+
internlm/Intern-S2-FP8 \
|
| 21 |
+
--model-name internlm/Intern-S2-397B \
|
| 22 |
+
--trust-remote-code \
|
| 23 |
+
--backend pytorch \
|
| 24 |
+
--dp 4 \
|
| 25 |
+
--ep 8 \
|
| 26 |
+
--enable-prefix-caching \
|
| 27 |
+
--proxy-url http://${proxy_server_ip}:${proxy_server_port} \
|
| 28 |
+
--reasoning-parser default \
|
| 29 |
+
--tool-call-parser interns2-preview
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
- Serving With MTP
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
lmdeploy serve api_server \
|
| 36 |
+
internlm/Intern-S2-FP8 \
|
| 37 |
+
--model-name internlm/Intern-S2-397B \
|
| 38 |
+
--trust-remote-code \
|
| 39 |
+
--backend pytorch \
|
| 40 |
+
--dp 4 \
|
| 41 |
+
--ep 8 \
|
| 42 |
+
--enable-prefix-caching \
|
| 43 |
+
--proxy-url http://${proxy_server_ip}:${proxy_server_port} \
|
| 44 |
+
--reasoning-parser default \
|
| 45 |
+
--tool-call-parser interns2-preview \
|
| 46 |
+
--speculative-algorithm qwen3_5_mtp \
|
| 47 |
+
--speculative-num-draft-tokens 4 \
|
| 48 |
+
--max-batch-size 256
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
- Long-Context Serving
|
| 52 |
+
|
| 53 |
+
For long-context inference, configure both `--session-len` and YaRN RoPE parameters. The following example uses a 512k context length:
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
lmdeploy serve api_server \
|
| 57 |
+
internlm/Intern-S2-FP8 \
|
| 58 |
+
--model-name internlm/Intern-S2-397B \
|
| 59 |
+
--trust-remote-code \
|
| 60 |
+
--backend pytorch \
|
| 61 |
+
--dp 4 \
|
| 62 |
+
--ep 8 \
|
| 63 |
+
--enable-prefix-caching \
|
| 64 |
+
--reasoning-parser default \
|
| 65 |
+
--tool-call-parser interns2-preview \
|
| 66 |
+
--session-len 512000 \
|
| 67 |
+
--max-batch-size 64 \
|
| 68 |
+
--hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}'
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## vLLM (>=v0.22.1)
|
| 72 |
+
|
| 73 |
+
- Basic Serving Without MTP
|
| 74 |
+
|
| 75 |
+
```bash
|
| 76 |
+
export VLLM_DEEP_GEMM_WARMUP=skip
|
| 77 |
+
export VLLM_USE_DEEP_GEMM=0
|
| 78 |
+
export VLLM_FLASHINFER_MOE_BACKEND=latency
|
| 79 |
+
|
| 80 |
+
vllm serve internlm/Intern-S2-FP8 \
|
| 81 |
+
--served-model-name internlm/Intern-S2-397B \
|
| 82 |
+
--trust-remote-code \
|
| 83 |
+
--tensor-parallel-size 8 \
|
| 84 |
+
--enable-auto-tool-choice \
|
| 85 |
+
--tool-call-parser qwen3_coder \
|
| 86 |
+
--reasoning-parser qwen3 \
|
| 87 |
+
--mm-encoder-tp-mode data
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
- Serving With MTP
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
export VLLM_DEEP_GEMM_WARMUP=skip
|
| 94 |
+
export VLLM_USE_DEEP_GEMM=0
|
| 95 |
+
export VLLM_FLASHINFER_MOE_BACKEND=latency
|
| 96 |
+
|
| 97 |
+
vllm serve internlm/Intern-S2-FP8 \
|
| 98 |
+
--served-model-name internlm/Intern-S2-397B \
|
| 99 |
+
--trust-remote-code \
|
| 100 |
+
--tensor-parallel-size 8 \
|
| 101 |
+
--enable-auto-tool-choice \
|
| 102 |
+
--tool-call-parser qwen3_coder \
|
| 103 |
+
--mm-encoder-tp-mode data \
|
| 104 |
+
--reasoning-parser qwen3 \
|
| 105 |
+
--speculative-config '{"method":"mtp","num_speculative_tokens":3}'
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
- Long-Context Serving
|
| 109 |
+
|
| 110 |
+
```bash
|
| 111 |
+
VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve internlm/Intern-S2-FP8 \
|
| 112 |
+
--served-model-name internlm/Intern-S2-397B \
|
| 113 |
+
--tensor-parallel-size 8 \
|
| 114 |
+
--max-model-len 1010000 \
|
| 115 |
+
--reasoning-parser qwen3 \
|
| 116 |
+
--hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}'
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
## SGLang (>=v0.5.13)
|
| 120 |
+
|
| 121 |
+
- Basic Serving Without MTP
|
| 122 |
+
|
| 123 |
+
```bash
|
| 124 |
+
python3 -m sglang.launch_server \
|
| 125 |
+
--model-path internlm/Intern-S2-FP8 \
|
| 126 |
+
--served-model-name internlm/Intern-S2-397B \
|
| 127 |
+
--trust-remote-code \
|
| 128 |
+
--tp-size 8 \
|
| 129 |
+
--mem-fraction-static 0.8 \
|
| 130 |
+
--enable-flashinfer-allreduce-fusion \
|
| 131 |
+
--reasoning-parser qwen3 \
|
| 132 |
+
--tool-call-parser qwen3_coder
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
- Serving With MTP
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
SGLANG_ENABLE_SPEC_V2=1 \
|
| 139 |
+
python3 -m sglang.launch_server \
|
| 140 |
+
--model-path internlm/Intern-S2-FP8 \
|
| 141 |
+
--served-model-name internlm/Intern-S2-397B \
|
| 142 |
+
--trust-remote-code \
|
| 143 |
+
--tp-size 8 \
|
| 144 |
+
--reasoning-parser qwen3 \
|
| 145 |
+
--tool-call-parser qwen3_coder \
|
| 146 |
+
--mem-fraction-static 0.8 \
|
| 147 |
+
--mamba-scheduler-strategy extra_buffer \
|
| 148 |
+
--enable-flashinfer-allreduce-fusion \
|
| 149 |
+
--speculative-algo 'NEXTN' \
|
| 150 |
+
--speculative-eagle-topk 1 \
|
| 151 |
+
--speculative-num-steps 3 \
|
| 152 |
+
--speculative-num-draft-tokens 4
|
| 153 |
+
```
|