Skip to main content

Deployment

Unlimited-OCR-2 support is not in a tagged SGLang release yet. Until it is, install SGLang from a source build that contains it. For all methods and hardware platforms, see the official SGLang installation guide.
Command
Then run the Python output of the command panel below in that environment.
Pick your hardware to generate the launch command. SGLang selects the unlimited_ocr_v2 attention backend, the page size the checkpoint requires and a disabled radix cache on its own. The recipes enable page-window processing with --uocr-doc-split and a per-page output budget; NVIDIA recipes also enable decode CUDA graphs. The built-in page guard runs automatically; --enable-custom-logit-processor is only needed for an external custom processor. The command panel provides Python and Docker recipes for L20, H100, H200, B200, B300, GB200 and GB300, and a Python-only Apple Silicon recipe. NVIDIA recipes target Linux with CUDA 13; Docker also requires a CUDA 13-compatible driver and NVIDIA Container Toolkit. Each recipe starts with one GPU on one node, including on GB200/GB300 systems. The Apple Silicon recipe was tested on an M5 MacBook Pro with 16 GB unified memory, macOS 26.6.2 and PyTorch 2.13.0. Other Apple Silicon configurations have not been verified. It uses the BF16 checkpoint and caps the KV pool at 32,768 tokens to leave memory for the vision encoder.
The additional NVIDIA platforms are starting recipes marked Not Verified. H200 TP1 and B200 TP1/TP2 have passed service checks with a smaller per-page output budget and bounded concurrency/CUDA-graph sizes; these exact 8,000-token/page recipes remain unverified. H100, B300, GB200 and GB300 have not been tested for this model here.

Playground

Use the Playground to adjust tensor parallelism on top of the selected deployment cell. TP2 requires two visible NVIDIA GPUs on the same node; it does not enable multi-node serving. Torch MPS supports TP1 only. The platform badge describes the base recipe, not every Playground override.

1. Model Introduction

Unlimited-OCR-2 is Baidu’s document parsing model for long and very long documents: all pages of a document go into one request, and the answer carries one <PAGE> section per input page, in page order. It replaces the sliding window of Unlimited-OCR with DASH sparse attention, where a learned router picks the KV blocks each query reads and every page keeps its own 2D position frame, so decode cost stays nearly flat as the document grows. The checkpoint has about 3.3B parameters in BF16 (a DeepSeek-style MoE language backbone with SAM and CLIP vision encoders) and is released under the MIT license. Recommended generation: temperature=0, with skip_special_tokens=false so the <PAGE> markers stay in the output. Resources: Hugging Face · GitHub · MarathonDocBench

2. Configuration Tips

  • GPU memory: on NVIDIA, first reduce --max-running-requests and --cuda-graph-max-bs-decode together, for example to 4. On MPS, reduce --max-running-requests or the KV pool cap (--max-total-tokens). The recipes keep BF16 weights and the checkpoint’s KV-cache precision. Reduce the per-page budget only when shorter output is acceptable; it can truncate a page.
  • Attention backend: keep the model-selected unlimited_ocr_v2 backend on every platform, including Blackwell, because the model requires DASH attention.
  • Prompt layout: list the page images first, then one text part holding <PAGE><image> once per page followed by the instruction, for example "<PAGE><image>" * num_pages + "Multi page parsing.".
  • Whole-document processing is the default. Omit --uocr-doc-split to process the document together, within the configured context length.
  • Page-window processing is opt-in. The deployment recipe enables --uocr-doc-split for long documents. --uocr-doc-page-window N sets the maximum pages each window transcribes in every image mode (default 1). Later windows reuse the preceding window’s KV tail. This changes the available context and is approximate; it is not a lossless replacement for whole-document inference. The client still sends one request and receives one response or stream, with metadata.doc_split_* describing the processing.
  • Per-page output budget: --uocr-max-page-tokens N limits how many tokens one output page may spend before the guard advances to the next page or ends the document. The default 0 leaves the page length uncapped. A nonzero cap also sizes the default context of a split server. It changes stopping behavior and needs no custom-processor flag. The page budget excludes page markers and termination tokens; overlap scheduling may leave one already-computed token beyond the budget. Set the request’s total max_tokens to cover the document.
  • Per-request options: doc_split_options.max_batch_pages may lower the server’s window size; max_page_tokens may lower a nonzero server page cap. lookahead_pages defaults to 1 and overlap_pages to 0. Set lookahead_pages: 0 to omit the following page from the window’s input. Lookahead and overlap change the input context and must fit the server’s context budget. Window options require --uocr-doc-split; a per-page output cap can also be used without splitting.
  • Data parallelism: page-window processing requires a single DP rank. Omit --uocr-doc-split with --dp-size or --attn-dp-size above 1.
  • Apple Silicon: select it in the command picker for the Torch MPS recipe. Quantized checkpoints, CUDA graphs and overlap scheduling are not supported on this path. See Apple Metal for details.
  • Not supported: speculative decoding, pipeline parallelism and PD disaggregation are rejected at launch.

3. Advanced Usage

3.1 Multi-page document

The example renders a three-page document and prints each page’s section. It uses the page-window deployment recipe above.
Example
Check metadata.doc_split_complete before treating a non-streaming split response as a complete document. If a window exceeds the context limit while other windows succeed, the response contains those successful windows, reports finish_reason: "length", and lists the rejected window in metadata.doc_split_incomplete_batches.
Output

3.2 Choosing an image mode

Pass images_config.image_mode per request; when it is omitted SGLang uses gundam. vLLM’s mm_processor_kwargs={"crop_mode": true} selects gundam and false selects base. Lower modes reduce prefill cost per page, which also lets a window hold more pages.
ModeUseWindow policy
tiny, smallLowest prefill cost for simple pages.—uocr-doc-page-window
baseOne global view per page; the model card’s multi-page setting.—uocr-doc-page-window
largeHigher-resolution global view.—uocr-doc-page-window
gundamDefault. Global view plus dynamic tiles for dense pages.—uocr-doc-page-window