Replies: 3 comments 1 reply
|
Nice catch on the When we faced this, we had to dig into the import copy
original_config = copy.deepcopy(config.text_config)
# apply override args
config.text_config.update(override_args)
# restore essential attributes
for attr in ['num_attention_heads', 'hidden_size']:
if hasattr(original_config, attr):
setattr(config.text_config, attr, getattr(original_config, attr))Turns out, we weren't alone in hitting this — there were some similar issues reported in the |
|
Yeah, that version issue is tricky. We ended up manually patching the |
|
The issue is that Root cause analysis: Looking at SGLang's model loading logic in
The fix: You need to provide a complete SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 python -m sglang.launch_server \
--model-path Qwen/Qwen3.5-397B-A17B \
--json-model-override-args '{
"text_config": {
"num_attention_heads": 64,
"hidden_size": 8192,
"intermediate_size": 29568,
"num_hidden_layers": 94,
"head_dim": 128,
"vocab_size": 152064,
"max_position_embeddings": 1010000,
"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
}
}
}' \
--context-length 1010000Why this happens: SGLang's config override mechanism uses Python's Alternative approach (safer): Instead of using import json
from transformers import AutoConfig
# Load and modify config
config = AutoConfig.from_pretrained("Qwen/Qwen3.5-397B-A17B", trust_remote_code=True)
# Update rope parameters for 1M context
config.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
}
config.text_config.max_position_embeddings = 1010000
# Save modified config
config.save_pretrained("./Qwen3.5-397B-1M")Then launch with: python -m sglang.launch_server \
--model-path ./Qwen3.5-397B-1M \
--context-length 1010000About 1M context support: Yes, SGLang does support 1M context for Qwen3.5-397B, but it requires:
The official HuggingFace documentation mentions SGLang support because the SGLang team has tested this configuration. The Recommended launch parameters for 1M context: SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 python -m sglang.launch_server \
--model-path Qwen/Qwen3.5-397B-A17B \
--tp 8 \
--context-length 1010000 \
--chunked-prefill-size 8192 \
--mem-fraction-static 0.85 \
--trust-remote-codeThis should work on 8×H200 or 8×A100-80GB (with reduced context length to ~512K for A100). |
Uh oh!
There was an error while loading. Please reload this page.
According to https://huggingface.co/Qwen/Qwen3.5-397B-A17B#processing-ultra-long-texts, sglang can run Qwen3.5-397B with 1M context length, and I quote:
However, I tried the above command on H20 144GB on latest sglang (sglang 0.5.12.post1, and I got:
It seems that the
--json-model-override-argsoption may override the original text_config and cause this bug, could anyone kindly figure out what the problem is?All reactions