docs: update SGLang quickstart

#1
Files changed (1) hide show
  1. README.md +27 -94
README.md CHANGED
@@ -318,108 +318,41 @@ The source checkout is immutable at `d9fd5f11423a1a5628fe29e7296ceb9de91aac3c`.
318
 
319
  ### SGLang
320
 
321
- The SGLang stack is pinned to public commit [`ffb41d77`](https://github.com/LLM360/sglang/commit/ffb41d77d8b96b8a953351cb4d66d6bf4ed061a7). The setup applies a hash-guarded namespace migration to expose the public `K2Horizon` classes and `k2_horizon` parser identifiers, then verifies both registries before launch. That source locks PyTorch 2.9.1, CUDA Python 12.9, Transformers 5.3.0, sglang-kernel 0.4.1, and FlashInfer 0.6.7.post2; the PyTorch wheel uses CUDA 12.8, and Safetensors 0.8.0 is selected independently. Its declared `flash-attn-4` dependency has only beta candidates, so the reproducible install removes exactly that unused metadata line, assigns the stable local version `0.5.10+ffb41d77.stableonly`, and explicitly selects stable FA3 from sglang-kernel. Keep this source-patched stack in its own environment.
 
 
 
322
 
323
  <details>
324
- <summary>Show SGLang setup and serving commands</summary>
325
 
326
  ```bash
327
- git clone https://github.com/LLM360/sglang.git
328
- cd sglang
329
- git checkout ffb41d77d8b96b8a953351cb4d66d6bf4ed061a7
330
- python - <<'PY'
331
- from hashlib import sha256
332
- from pathlib import Path
333
-
334
- path = Path("python/pyproject.toml")
335
- source = path.read_text(encoding="utf-8")
336
- if sha256(source.encode()).hexdigest() != "b3c46337e6852f4febc45087e96c26543bab7a1cc835276246290de152a1f532":
337
- raise RuntimeError("unexpected pinned SGLang pyproject hash")
338
- unstable = ' "flash-attn-4>=4.0.0b4",\n'
339
- if source.count(unstable) != 1:
340
- raise RuntimeError(f"unexpected flash-attn-4 metadata in {path}")
341
- patched = source.replace(unstable, "")
342
- if sha256(patched.encode()).hexdigest() != "69a86d23327737ad8cb16e0bb81dde8a1c530d93af997e7af32248a43a2efa1d":
343
- raise RuntimeError("unexpected stable-only SGLang pyproject hash")
344
- path.write_text(patched, encoding="utf-8")
345
-
346
- old_class = "K2" + "V3"
347
- old_id = "k2" + "_v3"
348
- old_label = "K2-" + "v3"
349
- contracts = (
350
- (
351
- Path("python/sglang/srt/parser/reasoning_parser.py"),
352
- "8bd1894b7d8c2935d4800e44616ba18c8eebaedde9d7c95c5d270864e928a25c",
353
- "e448c562fd5a994dec67a3ebf5d6539a4acbac0bbc2204d67ba801dd502ca7f5",
354
- ),
355
- (
356
- Path("python/sglang/srt/function_call/function_call_parser.py"),
357
- "0957d87b0e5dbcf761dc4871f4e48a7cc1f8c7e0a7badbfb5d3982b10f4d10eb",
358
- "177dabfc3c73461ecbb7da14c4009e4b6c109502a1d6bed65de0dfba6f9e7785",
359
- ),
360
- (
361
- Path("python/sglang/srt/function_call/multi_format_detector.py"),
362
- "306d310748ba84d3c2084d111a23fb6e2dead2e316bd0bdf69356b3c6e6eeab1",
363
- "b6e5650366afe8f7abf878172e70bdde527df1e1484514625e49178606ba847e",
364
- ),
365
- )
366
- replacements = (
367
- (old_class, "K2Horizon"),
368
- (old_id, "k2_horizon"),
369
- (old_label, "K2-Horizon"),
370
- )
371
- for source_path, original_hash, migrated_hash in contracts:
372
- text = source_path.read_text(encoding="utf-8")
373
- if sha256(text.encode()).hexdigest() != original_hash:
374
- raise RuntimeError(f"unexpected pinned SGLang parser source: {source_path}")
375
- for old, new in replacements:
376
- text = text.replace(old, new)
377
- if sha256(text.encode()).hexdigest() != migrated_hash:
378
- raise RuntimeError(f"unexpected Horizon parser migration: {source_path}")
379
- source_path.write_text(text, encoding="utf-8")
380
- PY
381
-
382
- export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_SGLANG="0.5.10+ffb41d77.stableonly"
383
- python -m pip install ./python "safetensors==0.8.0"
384
- python -m pip check
385
- python - <<'PY'
386
- from importlib.metadata import metadata, version
387
-
388
- from packaging.version import Version
389
- from sglang.srt.function_call.function_call_parser import FunctionCallParser
390
- from sglang.srt.parser.reasoning_parser import ReasoningParser
391
-
392
- assert not Version(version("sglang")).is_prerelease
393
- requirements = metadata("sglang").get_all("Requires-Dist") or []
394
- assert not any(requirement.lower().startswith("flash-attn-4") for requirement in requirements)
395
- assert "k2_horizon" in ReasoningParser.DetectorMap
396
- assert "k2_horizon_legacy" in ReasoningParser.DetectorMap
397
- assert "k2_horizon" in FunctionCallParser.ToolCallParserEnum
398
- PY
399
-
400
- export MODEL_ID="IFM/K2-Horizon-7B"
401
- export MODEL_REVISION="mid_4"
402
- export TP_SIZE=1
403
- export CONTEXT_LENGTH=131072
404
-
405
- python -m sglang.launch_server \
406
- --model-path "$MODEL_ID" \
407
- --revision "$MODEL_REVISION" \
408
- --model-impl transformers \
409
- --tp "$TP_SIZE" \
410
- --trust-remote-code \
411
- --dtype bfloat16 \
412
- --context-length "$CONTEXT_LENGTH" \
413
- --attention-backend fa3 \
414
- --reasoning-parser k2_horizon \
415
- --tool-call-parser k2_horizon \
416
- --mem-fraction-static 0.85 \
417
- --disable-piecewise-cuda-graph
418
  ```
419
 
420
  </details>
421
 
422
- The example starts at 131,072 tokens and explicitly selects stable FA3 from sglang-kernel 0.4.1; FlashInfer 0.6.7.post2 remains installed for compatible alternate paths. The source is launched through SGLang's Transformers backend so the repository's self-contained remote code remains the architecture source of truth. Piecewise CUDA graphs are disabled because this experimental path can trigger an illegal-memory-access failure while warming up XLLM MoVA layers; ordinary serving remains available. The installation preflight verifies the migrated `k2_horizon`, `k2_horizon_legacy`, and tool-parser registrations before the server starts.
 
 
 
423
 
424
  ### Reasoning and Tool Parsers
425
 
 
318
 
319
  ### SGLang
320
 
321
+ Native K2 Horizon support is provided by
322
+ [sgl-project/sglang#37654](https://github.com/sgl-project/sglang/pull/37654).
323
+ Use a `lmsysorg/sglang:dev` image built after that PR is merged. Once support is
324
+ included in a tagged SGLang release, use the corresponding versioned image.
325
 
326
  <details>
327
+ <summary>Show the SGLang serving command</summary>
328
 
329
  ```bash
330
+ docker run --gpus all \
331
+ --shm-size 32g \
332
+ -p 30000:30000 \
333
+ -v ~/.cache/huggingface:/root/.cache/huggingface \
334
+ --ipc=host \
335
+ lmsysorg/sglang:dev \
336
+ python3 -m sglang.launch_server \
337
+ --model-path "IFM/K2-Horizon-7B" \
338
+ --revision main \
339
+ --tp 1 \
340
+ --dtype bfloat16 \
341
+ --context-length 131072 \
342
+ --attention-backend fa3 \
343
+ --reasoning-parser k2_horizon \
344
+ --tool-call-parser k2_horizon \
345
+ --mem-fraction-static 0.85 \
346
+ --host 0.0.0.0 \
347
+ --port 30000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  ```
349
 
350
  </details>
351
 
352
+ This uses SGLang's native `K2HorizonForCausalLM` implementation; no
353
+ `--trust-remote-code`, source patch, or external parser plugin is required. The
354
+ 131,072-token limit is a conservative starting point; increase it only after
355
+ measuring KV-cache capacity.
356
 
357
  ### Reasoning and Tool Parsers
358