clairic-sm120-serve β€” Concurrent SGLang Serving Stack, SM120 Triton Kernels, Quantization Pipeline, and SGLang v0.5.23 Patch Set for Cloudflare/clairic

Full Technical Specification & Benchmark Report: Read ENGINEERING_REPORT.md for the complete SM120 architecture specification, custom Triton kernel microbenchmarks, 3-repeat concurrency sweeps (N = 32), 8-case selection and 12-case disjoint held-out calibration tables, and controlled ablations.

geudrik/clairic-sm120-serve provides the concurrent serving engine, SM120 Triton kernels, quantization scripts, SGLang v0.5.23 unified diff set, and benchmark harnesses for Cloudflare/clairic on a single NVIDIA RTX PRO 6000 Blackwell Server Edition (sm_120, 188 SMs, 95.03 GiB visible GDDR7).

Under the published CLI defaults (--kv-cache-dtype auto --mem-fraction-static 0.80 --max-mamba-cache-size 180 --max-running-requests 48 --chunked-prefill-size 16384 --pool-size 24, measured across 3 repeats at N = 32 requests per concurrency level):

  • Paired with geudrik/clairic-27b-fp8-sm120 (28.75 GiB backbone / 29.02 GiB total vs. 51.75 / 52.02 GiB BF16, 1.80x smaller backbone): matches 51/51 selection-suite fields and 79/79 disjoint held-out fields across all 3 repeats under the suite tolerances (all 11/11 estimate/forecast fields within 1.86% of the BF16 reference, 3-run median confidence drift 0.0064–0.0125) and reaches 1.318 req/s (8.40 fields/s, 5.87x reference) at concurrency C = 8.
  • Paired with geudrik/clairic-27b-nvfp4-sm120 (20.85 GiB backbone / 21.12 GiB total, 2.48x smaller backbone): reaches 1.768 req/s (11.27 fields/s, 7.87x reference) at engine level and 1.748 req/s (11.14 fields/s, 7.78x reference) over live FastAPI HTTP at C = 8, scoring 50/51 on the selection suite (shifting case5.closing_inventory 1000 -> 100 under BF16 KV) and 76/79 reference agreement / 69/71 (97.2%) ground-truth accuracy on the 12-case held-out suite, with larger confidence drift (3-run median 0.0338–0.0577, max 0.6860–0.7974).

Note β€” Concurrent Batching (C > 1) Answer Sensitivity on clairic-27b-nvfp4-sm120 (Serving Stack Exonerated): Under C > 1 concurrent load, geudrik/clairic-27b-nvfp4-sm120 occasionally flips borderline list-extraction answers (~0.4% of responses in mixed invoice workloads; 23–31% under targeted C = 2 co-batching on multi-item invoices beginning with "Folders; Desk lamps"), whereas C = 1 executes a fixed sub-prompt wave schedule and repeats the same output. Reverting patches/sglang-v0.5.23-clairic-sm120.patch and disabling all clairic-sm120-serve hooks (CLAIRIC_FUSED_SAMPLER=0, disable_radix_cache=True, disable_prefill_cuda_graph=True) on stock lmsysorg/sglang:v0.5.23-cu130 reproduces identical 8-decimal-place log probabilities and identical C > 1 flipsβ€”confirming that clairic-sm120-serve's Triton kernels, Sampler/LogitsProcessor hooks, MambaRadixCache, xgrammar bitmasks, and isolated frontend slot pool do not cause the drift.

  • Root cause (SM120 operator & layer trace): FlashInfer's SM120 NVFP4 quantizer and CUTLASS GEMM (fp4_quantize + mm_fp4) and ModelOpt per-tensor FP8 GEMMs are 100.00% bit-exact batch-invariant (max_abs = 0.000000 across prefill M = 231, 468, 1404 and decode M = 1, 2, 8). Batch-size non-invariance enters at unquantized BF16 projectionsβ€”starting at layers.0.linear_attn.in_proj_ba ([M, 5120] -> [M, 96]), where cuBLAS changes its split-K reduction strategy with total batch tokens M (max_abs = 0.03125, mean_abs = 0.00192). When a 1-ULP BF16 perturbation (rel_rms = 0.00133) enters layers.4.mlp, 0.180% of dynamic fp4_quantize activations cross a discrete 4-bit E2M1 step boundary, amplifying relative difference by 40.70x in a single NVFP4 MLP versus 4.14x in BF16. Across 52 interior NVFP4 layers, step-0 vocabulary logits shift by up to 3.33 nats (mean_abs = 0.418) between B = 1 (M = 231) and B = 6 (M = 1404). Where 4-bit quantization and Qwen3.5 BPE boundary splitting ("Folders" splits mass between merged token 83565 '"F' and 1 '"' + 89582 'Folders', whereas "Desk lamps" concentrates on 1 '"' + 67166 'Desk') narrow item-1 confidence from 0.68–0.71 (BF16) to 0.29–0.55 (NVFP4), co-batching flips near-tie prompts.
  • Deterministic mode & recommended C > 1 checkpoint: SGLang --enable-deterministic-inference --linear-attn-prefill-backend triton (batch_invariant_ops) eliminates C > 1 batch variance (collapsing concurrent responses to 1 bit-identical float state), but disables RadixCache on FlashInfer attention and shows that clairic-27b-nvfp4-sm120 deterministically mispredicts 3 / 12 tested "Folders; Desk lamps" invoices even at B = 1. For concurrent C > 1 production serving, pair clairic-sm120-serve with geudrik/clairic-27b-fp8-sm120, which avoids 4-bit E2M1 step amplification, preserves BF16-level margins (12 / 12 "Folders" across all batch shapes at 0.55–0.75 confidence), and achieved 0 / 30 (0.0%) failures in the same C = 2 concurrent mixed-load stress loop while retaining MambaRadixCache and CUDA graphs (1.318 req/s at C = 8).

Repository Ecosystem

Repository / Resource Contents Size (Backbone / Total) Role
geudrik/clairic-sm120-serve clairic_sm120 package, clairic-sm120-serve CLI, patches/, quantization/, benchmarks/, ENGINEERING_REPORT.md Code + 2.3 MiB logs/JSON Serving engine, Triton kernels, SGLang v0.5.23 patch, PTQ scripts, and benchmark archive
geudrik/clairic-27b-fp8-sm120 Block-128 Dynamic W8A8 FP8 checkpoint + clair_head.safetensors, clairic_runtime, patches/, benchmarks/results/ 28.75 / 29.02 GiB Recommended for concurrent C > 1 production serving, reference agreement (51/51 selection, 79/79 held-out), and confidence calibration (1.318 req/s @C=8)
geudrik/clairic-27b-nvfp4-sm120 Boundary-Protected Mixed NVFP4 + FP8 checkpoint + clair_head.safetensors, clairic_runtime, patches/, benchmarks/results/ 20.85 / 21.12 GiB Peak SM120 throughput (1.768 req/s engine / 1.748 req/s HTTP @C=8) and lowest static footprint; subject to C > 1 batch-size flips on low-margin fields (see note above)
hf://buckets/geudrik/clairic-sm120-work Raw benchmark JSONs, provenance_v2.json, job_6b0c7e8054072e8b7170ed22.log, and archived candidate responses ~2.5 MiB Complete measurement and candidate-response archive

1. Architecture Summary

Cloudflare/clairic combines a 64-layer Qwen3_5ForConditionalGeneration backbone (26.90B text parameters across 48 Gated DeltaNet linear_attention layers and 16 gated full_attention GQA layers with head_dim = 256 + 0.46B 27-layer vision encoder = 27.36B active serving parameters; 51.75 GiB in BF16) with a 276.95 MiB (290.41 MB) FP32 2-layer cross-attention readout module (ClairicHead in clair_head.safetensors). Standard extraction fields execute parallel xgrammar-constrained greedy autoregressive prompts (_ar_all), whereas compute, duration, estimate, and forecast fields execute a single <|fim_pad|> slot pass decoded by ClairicHead (read_typed).

clairic-sm120-serve addresses four serving requirements on SM120:

  1. Isolated Frontend Slot Pool (clairic_sm120/engine.py): ClairicConcurrentService maintains pool_size Clairic27BModel slots (max_concurrency = 1 per slot, each with its own AutoTokenizer and AutoProcessor) sharing one SGLangClairicEngine (74 piecewise prefill + 8–16 decode CUDA graphs recorded in benchmarks/results/v2_audit/job_6b0c7e8054072e8b7170ed22.log). Keeping max_concurrency = 1 inside each slot preserves Clairic27BModel's list-termination verification (list-gating), secondary multi-page purchase-order crops (po_image_supplement), and image-context routing (media_state_prompt), avoiding TransformersEngine's single-request ClairQueueFull serialization.
  2. Intra-Request Prefix Pre-Warming and Ephemeral GDN Sizing: clairic_runtime/backend.py:798, 1296, 1369 creates and clears a fresh ImageCache with fresh uuid4 salts per predict_async call, giving 0% cross-request cache reuse while multi-field image requests share a long prefix across their 8–39 sub-prompts. _maybe_warmup_prefixes prefills that shared prefix once when warm_len >= 128 and all <|vision_end|> tokens lie inside the prefix (1.31x higher C = 8 throughput in isolated ablation). Default --max-mamba-cache-size 180 (25.97 GiB across 147.75 MiB slots = 144.00 MiB FP32 recurrent + 3.75 MiB BF16 conv1d state) bounds GDN memory to active intra-request fan-out while keeping full-attention KV in native BF16 (--kv-cache-dtype auto).
  3. In-Worker TP-Rank-0 ClairicHead Execution (clairic_sm120/kernels.py): read_typed tags requests via token_ids_logprobs = [248319, 248318, hi, lo] (where 248319 and 248318 are unassigned tail vocabulary IDs inside vocab_size = 248,320, len(tokenizer) = 248,077, and hi, lo are in-range token IDs carrying the 16-bit-PID-namespaced integer tag) with logprob_start_len = -1. On TP rank 0, maybe_run_extend runs fast_read_layout_gpu_only on GPU (11.13x–48.11x faster GPU readout; 1.25x–1.42x standalone end-to-end including CPU decode_record) and writes only the compact FP32 readout vector (3,880 to 135,968 bytes across benchmarked calls) to /dev/shm, evicting stale chunks older than 120 s or whose request JSON was unlinked on subsequent LogitsProcessor calls.
  4. Two-Stage Greedy Vocabulary Reduction: run_fused_greedy_logprob replaces SGLang's [B, 248,320] log_softmax allocation and B-way pin_memory().to(device) gather loop with one batched H2D copy and a two-stage Triton reduction (1.45x faster at B = 8, 4.36x faster at B = 64 reducing extra HBM from 30.34 MiB to 0.06 MiB, and 0.71x at B = 1). End-to-end log probabilities match SGLang's default FP32-cast sampler within 1.56e-5 (zero field value changes; across 3 repeats on FP8, end-to-end C = 8 throughput is 1.318 vs 1.339 req/s, -1.6%).

2. SGLang v0.5.23 Unified Diff Set (patches/)

patches/sglang-v0.5.23-clairic-sm120.patch applies cleanly against sgl-project/sglang tag v0.5.23 (both git checkouts at /sgl-workspace/sglang and wheel-installed site-packages/sglang):

python3 patches/apply_sglang_patch.py --check
python3 patches/apply_sglang_patch.py

The patch adds python/sglang/srt/layers/clairic_sm120.py and wires two environment-gated hooks into logits_processor.py (CLAIRIC_HEAD_DIR) and sampler.py (CLAIRIC_FUSED_SAMPLER=1, gated on is_all_greedy, return_logprob, target_logprobs is None, not SGLANG_RETURN_ORIGINAL_LOGPROB, and not return_sampling_mask). On unpatched environments, SGLangClairicEngine.load installs an equivalent post-import hook via clairic_sm120/sgl_hook/sitecustomize.py.


3. Benchmarks on NVIDIA RTX PRO 6000 (sm_120, 95.03 GiB Visible)

Testbed: 1x NVIDIA RTX PRO 6000 Blackwell Server Edition (driver 620.70.06, max clock 2,430 MHz), lmsysorg/sglang:v0.5.23-cu130 (sglang 0.5.23, torch 2.14.1+cu130, triton 3.8.0, flashinfer 0.7.2, transformers 5.19.0; transformers 5.10.2 isolated in /tmp/tf510 for TransformersEngine). All benchmark JSONs, job_6b0c7e8054072e8b7170ed22.log, and candidate responses live in benchmarks/results/v2_audit/.

Comparison Rules: Exact match for discrete/list/object fields; isclose(rel_tol=1e-4, abs_tol=1e-2) for floats; <= 8% relative difference for estimate/forecast fields; confidence and p_null tracked separately across 47 selection and 72 held-out confidence fields. All concurrency sweeps use N = 32 requests per concurrency level after warming text AR, multimodal ViT+AR, and ClairicHead.

3.1 Concurrent Scaling, Parity, and Calibration (N = 32 Requests / Level)

Configuration (KV / mem_frac / mamba / pool) Size (Backbone / Total) Selection Match (51) / GT (47) Held-Out Match (79) / GT (71) Mean (Max) Abs Ξ” Conf (Sel) C=1 req/s (p50/p95) C=8 req/s (p50/p95) C=16 req/s (p50/p95) C=32 req/s (p50/p95)
Ref TransformersEngine BF16 (sdpa, Semaphore(1)) 51.75 / 52.02 GiB Ref 51/51 / 45/47 Ref 79/79 / 66/71 0.0000 (0.0000) 0.225 (2.27 / 17.62 s) 0.225 (35.59 / 35.67 s) 0.225 (71.22 / 71.28 s) 0.225 (72.26 / 141.85 s)
SGLang BF16 (auto / 0.85 / 150 / 24)* 51.75 / 52.02 GiB 51/51 / 45/47 79/79 / 66/71 0.0037 (0.0585) 0.560 (1.62 / 3.99 s) 0.856 (8.76 / 17.24 s) 0.681 (18.57 / 38.13 s) 0.691 (36.01 / 46.21 s)
Block-128 FP8 CLI Defaults (auto / 0.80 / 180 / 24, 3x med) 28.75 / 29.02 GiB 51/51 / 45/47 79/79 / 66/71 0.0064 (0.1408) 0.842 (1.00 / 2.57 s) 1.318 (5.60 / 11.08 s) 1.259 (11.53 / 21.97 s) 1.137 (23.69 / 28.04 s)
NVFP4+FP8 CLI Defaults (auto / 0.80 / 180 / 24, 3x med) 20.85 / 21.12 GiB 50/51 / 44/47 76/79 / 69/71 0.0338 (0.6860) 1.076 (0.75 / 2.13 s) 1.768 (4.09 / 8.82 s) 1.733 (8.35 / 15.33 s) 1.420 (17.98 / 22.48 s)
NVFP4+FP8 Live HTTP (uvicorn + httpx, CLI Defaults) 20.85 / 21.12 GiB 50/51 / 44/47 Not run over HTTP 0.0356 (0.4913) 1.084 (0.76 / 2.17 s) 1.748 (4.04 / 9.04 s) 1.514 (9.29 / 17.62 s) Not run over HTTP
NVFP4+FP8 + fp8_e4m3 KV (fp8_e4m3 / 0.80 / 180 / 24) 20.85 / 21.12 GiB 50/51 / 44/47 77/79 / 66/71 0.0542 (0.7347) 1.077 (0.76 / 2.16 s) 1.719 (4.22 / 8.20 s) 1.671 (8.91 / 16.09 s) 1.634 (16.06 / 19.49 s)
NVFP4+FP8 No Prefix Warmup (auto / 0.80 / 180 / 24)* 20.85 / 21.12 GiB 50/51 / 44/47 75/79 / 68/71 0.0324 (0.6846) 0.938 (0.75 / 2.74 s) 1.354 (5.86 / 10.45 s) 1.416 (9.29 / 17.07 s) 1.247 (18.34 / 25.54 s)
NVFP4+FP8 Mode B No-Radix (auto / 0.72 / 96 / 32) 20.85 / 21.12 GiB 50/51 / 44/47 75/79 / 68/71 0.0329 (0.6900) 0.650 (0.74 / 6.62 s) 0.804 (9.86 / 19.58 s) 0.821 (14.57 / 33.78 s) 0.825 (19.59 / 38.76 s)
FP8 + NEXTN MTP (auto / 0.85 / 90 / 24) 28.75 / 29.02 GiB 48/51 / 43/47 73/79 / 61/71 0.0822 (0.8690) 0.958 (0.80 / 2.45 s) 1.115 (7.24 / 11.38 s) 0.839 (17.41 / 31.03 s) Not run (max_run=24)

*sglang_bf16_auto_kv_v2 (mem_frac=0.85) and sglang_nvfp4_no_prefix_warmup_v2 logged one recoverable CUDACachingAllocator OOM cache-flush warning each during C = 32; all other runs logged zero OOM warnings.

3.2 SM120 Kernel and Sampler Microbenchmarks (benchmarks/bench_and_verify_kernels.py)

Kernel / Subsystem Shape & Condition Reference (Peak Extra HBM) SM120 Kernel (Peak Extra HBM) Speedup Numerical Agreement
fused_span_argmax_prob F = 12, S = 16,384, W = 64 0.368 ms (96.75 MiB) 0.057 ms (0.05 MiB) 6.47x Exact argmax; 8.15e-10 max prob diff
fused_span_argmax_prob F = 8, S = 65,273, W = 64 1.777 ms (257.99 MiB) 0.064 ms (0.13 MiB) 27.77x Exact argmax; 3.49e-10 max prob diff
run_fused_greedy_logprob (sampler microbench) B = 1 .. 64, V = 248,320 BF16 0.085 – 1.146 ms (0.48 – 30.34 MiB) 0.120 – 0.263 ms (0.00 – 0.06 MiB) 0.71x (B=1) – 4.36x (B=64) Exact argmax; <= 1.0e-6 vs FP32 (<= 1.56e-5 E2E vs SGLang)
fused_vocab_argmax_logprob (masked) B = 32 / 128, V = 248,320 + ~3.1% bitmask 0.211 / 0.586 ms (76.6 / 303.1 MiB) 0.065 / 0.066 ms (0.03 / 0.12 MiB) 3.24x / 8.85x Exact argmax; 9.54e-7 max lp diff
fast_read_slots rows = 1024, H = 5120, V = 248,320 14.236 ms (606.26 MiB) 6.955 ms (485.01 MiB) 2.05x Exact token ID; 9.54e-7 max lp diff
ClairicHead (S = 3,167, GPU / E2E w/ CPU) 6 typed fields, 3 seeds (randn * 0.1) 84.51 / 288.53 ms (459.21 MiB) 7.59 / 210.77 ms (170.62 MiB) 11.13x GPU / 1.37x E2E Discrete slots differ on randn*0.1; 1.81e-4 max float rel diff*
ClairicHead (S = 34,808, GPU / E2E w/ CPU) 6 typed fields, 3 seeds (randn * 0.1) 704.35 / 2,224.14 ms (1,786.54 MiB) 14.64 / 1,568.33 ms (608.62 MiB) 48.11x GPU / 1.42x E2E Discrete slots differ on randn*0.1; 1.42e-4 max float rel diff*

*In the end-to-end stack comparison (sglang_bf16_auto_kv_v2 vs baseline_sm120_v2), all 15/15 discrete/numeric ClairicHead fields across the 20 benchmark cases matched to 1e-6.


4. Serving Quickstart

git clone https://huggingface.co/geudrik/clairic-sm120-serve
cd clairic-sm120-serve
pip install -e .
python3 patches/apply_sglang_patch.py

Mode A (Default): Multi-Field Multimodal & Structured Extraction (Intra-Request Prefix Sharing Enabled)

# Option 1: Block-128 FP8 (recommended for 51/51 & 79/79 reference parity and calibrated confidences)
hf download geudrik/clairic-27b-fp8-sm120 --local-dir /models/clairic-27b-fp8-sm120
clairic-sm120-serve \
  --model-path /models/clairic-27b-fp8-sm120 \
  --kv-cache-dtype auto \
  --mem-fraction-static 0.80 \
  --max-mamba-cache-size 180 \
  --max-running-requests 48 \
  --chunked-prefill-size 16384 \
  --pool-size 24 \
  --port 8000

# Option 2: Boundary-Protected NVFP4 + FP8 (highest throughput: 1.768 req/s @ C=8)
hf download geudrik/clairic-27b-nvfp4-sm120 --local-dir /models/clairic-27b-nvfp4-sm120
clairic-sm120-serve \
  --model-path /models/clairic-27b-nvfp4-sm120 \
  --kv-cache-dtype auto \
  --mem-fraction-static 0.80 \
  --max-mamba-cache-size 180 \
  --max-running-requests 48 \
  --chunked-prefill-size 16384 \
  --pool-size 24 \
  --port 8000

Mode B: Single-Pass ClairicHead or 1-Field Workloads Only (--disable-radix-cache, 79.57 GiB Peak VRAM)

--disable-radix-cache also disables intra-request prefix sharing across multi-field AR prompts (case4 slows from 2.15 s 3-run median to 6.78 s, and ho09.carrier shifts to null); use Mode B only for single-pass ClairicHead or 1-field workloads.

clairic-sm120-serve \
  --model-path /models/clairic-27b-nvfp4-sm120 \
  --disable-radix-cache \
  --kv-cache-dtype auto \
  --mem-fraction-static 0.72 \
  --max-mamba-cache-size 96 \
  --max-running-requests 96 \
  --chunked-prefill-size 16384 \
  --pool-size 32 \
  --port 8000

5. End-to-End Reproduction

Inside lmsysorg/sglang:v0.5.23-cu130 on an NVIDIA RTX PRO 6000 (sm_120) with Cloudflare/clairic mounted at /models/clairic, clairic-27b-fp8-sm120 at /models/fp8, and clairic-27b-nvfp4-sm120 at /models/nvfp4:

# Run the complete benchmark suite (provenance, baseline, kernels, 3-repeat sweeps, ablations, live HTTP)
python3 benchmarks/run_v2_audit_suite.py \
  --clairic-dir /models/clairic \
  --fp8-dir /models/fp8 \
  --nvfp4-dir /models/nvfp4 \
  --work-dir /tmp/v2_audit

# Regenerate quantized checkpoints from Cloudflare/clairic:
python3 quantization/quantize_fp8_block128.py --src-dir /models/clairic --dst-dir /tmp/clairic-fp8 --scale-dtype bfloat16
PYTHONPATH=/tmp/tf510 python3 quantization/quantize_nvfp4_mixed.py --src-dir /models/clairic --dst-dir /tmp/clairic-nvfp4

6. Qualification Scope and Limitations

  • Qualified: 1x NVIDIA RTX PRO 6000 Blackwell Server Edition (sm_120, 95.03 GiB visible), lmsysorg/sglang:v0.5.23-cu130, the configurations in Section 3.1, the 8-case selection suite (workload_suite.py), the 12-case synthetic/scan held-out suite (heldout_suite.py), and warmed local HTTP serving on clairic-27b-nvfp4-sm120 (C = 1, 8, 16).
  • Not Qualified / Untested: tp_size > 1, other GPUs (NVFP4 requires sm_100/sm_120; FP8 targets sm_90/sm_100/sm_120), real camera/multi-hundred-page production PDFs, fix_mistral_regex=True tokenizer loading, long-duration soak testing, and NEXTN MTP gated on draft-worker identity (leaving mtp_num_hidden_layers: 0 is required; enabling NEXTN corrupts ClairicHead readouts, flips held-out AR confidences across 0.50, and reduces C = 8/C = 16 throughput by 15.4% / 33.3%).
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for geudrik/clairic-sm120-serve

Base model

Qwen/Qwen3.8-27B
Finetuned
(2)
this model