# FactorSpec: Serving Exact Relational Constraints as Speculative Drafts

DevFeed: [FactorSpec: Serving Exact Relational Constraints as Speculative Drafts](<https://devfeed.tech/articles/factorspec-serving-exact-relational-constraints-as-speculative-drafts-114679.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2611.02297>)

Author: Jianchang Su, Dawei Xiang, Wei Zhang

Published: 2026-11-03T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Artificial Intelligence](<https://devfeed.tech/sources/arxiv-artificial-intelligence.md>), [arXiv: Machine Learning](<https://devfeed.tech/sources/arxiv-machine-learning.md>)

Topics: [LLM optimization](<https://devfeed.tech/topics/llm-optimization.md>), [Model Optimizer](<https://devfeed.tech/topics/model-optimizer.md>), [sglang](<https://devfeed.tech/topics/sglang.md>), [vllm](<https://devfeed.tech/topics/vllm.md>), [Large Language Model](<https://devfeed.tech/topics/llm.md>)

Tags: [constraint](<https://devfeed.tech/tags/constraint.md>), [cs-ai](<https://devfeed.tech/tags/cs-ai.md>), [cs-lg](<https://devfeed.tech/tags/cs-lg.md>), [graph](<https://devfeed.tech/tags/graph.md>), [json-schema](<https://devfeed.tech/tags/json-schema.md>), [llm-serving](<https://devfeed.tech/tags/llm-serving.md>), [sglang](<https://devfeed.tech/tags/sglang.md>), [speculative-decoding](<https://devfeed.tech/tags/speculative-decoding.md>), [structured-outputs](<https://devfeed.tech/tags/structured-outputs.md>), [vllm](<https://devfeed.tech/tags/vllm.md>)

## AI overview

FactorSpec turns exact relations among structured-output fields into speculative drafts: it compiles a JSON Schema and its relations into a factor graph, drafts tokens those constraints determine, and checks feasibility exactly. It chooses verification width per request and computes masks in worker processes while the GPU runs. On NATURAL PLAN trip problems, Qwen3-8B produced valid itineraries 10% of the time, rising to 14% after retries that named violated relations. In SGLang, FactorSpec reports up to 10.5 tokens per verify step, up to 1.9x the fastest n-gram drafter, and up to 1.43x faster decoding than speculators tuned per load, with grammar-mask cost; it also leads in vLLM. Its records are valid, yielding up to 13.9x more valid records per GPU-second than syntax-only baselines.

## Source excerpt

arXiv:2611.02297v1 Announce Type: new Abstract: Speculative decoding speeds up LLM serving by drafting tokens that the target model verifies in one pass, and its gain grows with the drafts the target accepts. Structured outputs should be an ideal case, because much of a record follows from relations among its fields: an itinerary's days follow from its cities' stays and flights. Serving engines, however, draft such text by proposing it from the prompt or a learned head, and their grammar masks enforce only syntax, so the model must satisfy the relations, which it violates: on NATURAL PLAN's trip problems, Qwen3-8B writes a valid itinerary for 10%, and retries that name the violated relation raise this to 14%. We present FactorSpec, which serves exact relational constraints as speculative drafts. FactorSpec compiles a JSON Schema and its relations into a factor graph with an exact feasibility check, drafts every token the constraint determines as certain, verifies each request at a width chosen for it, and computes the masks in worker processes outside the scheduler while the GPU runs. In SGLang, its drafts yield up to 10.5 tokens per verify step, up to 1.9x those of the fastest n-gram drafter, and it decodes up to 1.43x faster than speculators tuned per load, at a grammar mask's cost; it also leads in vLLM. Because every record is also valid, it serves up to 13.9x the valid records per GPU-second of syntax-only baselines.