xinfer-ai 0.13.6 → 0.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -329,7 +329,7 @@ xinfer --m mistralai/Ministral-3-3B --ui-server
329
329
  ```bash
330
330
  # Prerequisites: Rust compiler, CUDA Toolkit (optional) or Metal Xcode command line tool
331
331
  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
332
- sudo apt-get install -y git build-essential libssl-dev pkg-config
332
+ sudo apt-get install -y git build-essential
333
333
 
334
334
  export XINFER_REPO="https://github.com/guoqingbao/xinfer"
335
335
  # MacOS/Metal: replace features to `metal`
@@ -449,9 +449,14 @@ xinfer --m unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF \
449
449
 
450
450
  ---
451
451
 
452
- ## 🔌 Structured Outputs
452
+ ## 🔌 Structured Outputs & Guided Decoding
453
453
 
454
- Constraint-based generation via llguidance — Lark grammars, regex, JSON Schema.
454
+ Constraint-based generation via llguidance — JSON Schema, regex, Lark grammars, choice lists.
455
+
456
+ ```bash
457
+ # Enable structured outputs and tool grammar
458
+ xinfer --m Qwen/Qwen3.6-27B-FP8 --ui-server --enable-tool-grammar
459
+ ```
455
460
 
456
461
  [Structured outputs documentation →](docs/guided_decoding.md)
457
462
 
@@ -495,7 +500,7 @@ Constraint-based generation via llguidance — Lark grammars, regex, JSON Schema
495
500
  | `--max-num-seqs` | Max concurrent requests (default: 32, macOS: 8) |
496
501
  | `--max-tokens` | Max tokens per response (default: 16384) |
497
502
  | `--kv-fraction` | GPU memory fraction for KV cache |
498
- | `--cpu-mem-fold` | CPU swap memory ratio (default: 0.2) |
503
+ | `--cpu-mem-fold` | CPU swap memory ratio (default: 0.5) |
499
504
  | `--pd-server` | Run as PD prefill server |
500
505
  | `--pd-client` | Run as PD decode client |
501
506
  | `--pd-url` | PD connection URL (`tcp://`, `http://`, `file://`) |
@@ -8,13 +8,23 @@ It focuses on:
8
8
  - how reasoning effort is applied
9
9
  - practical usage and validation commands
10
10
 
11
+ ## JSON Schema Reference
12
+
13
+ For detailed JSON Schema constraint documentation with curl examples, see [`llguidance-json-schema.md`](llguidance-json-schema.md).
14
+
15
+ This covers:
16
+ - Schema type definitions (string, integer, number, boolean, object, array)
17
+ - All supported API endpoints (OpenAI-compatible and Claude server)
18
+ - Complete curl examples for each permutation
19
+ - Schema sanitization behavior
20
+
11
21
  ## Current Model
12
22
 
13
23
  Guided decoding is request-scoped.
14
24
 
15
25
  The core engine does not invent grammars on its own. A request either:
16
26
  - supplies a constraint grammar
17
- - gets that constraint grammar composed with a reasoning prefix
27
+ - gets a composed grammar containing both
18
28
  - or runs unconstrained when neither exists
19
29
 
20
30
  The final grammar is stored in `SamplingParams.grammar` and consumed by the runner.
@@ -44,7 +54,7 @@ The server composes:
44
54
 
45
55
  The result is a single `TopLevelGrammar` assigned to `SamplingParams.grammar`.
46
56
 
47
- If no client-supplied constraint grammar exists, `params.grammar` stays `None`.
57
+ If no constraint grammar and no tool grammar exist, `params.grammar` stays `None`.
48
58
 
49
59
  ### 3. Sampling in runner
50
60
 
@@ -84,14 +94,17 @@ Legacy fields
84
94
  - `constraint`
85
95
  - `constraint_type = regex | lark | json_schema | json`
86
96
 
87
- If a request provides none of the above, guided decoding is not enabled.
97
+ If a request provides none of the above, guided decoding is not enabled unless tool grammar synthesis adds one.
98
+
99
+ The grammar composition logic is in `src/utils/guidance_grammar.rs`. The `GrammarRequestDispatcher` and `GrammarComposer` handle the composition of constraint grammars with reasoning grammars.
88
100
 
89
101
  ### Claude server
90
102
 
103
+ Claude reuses the same tool-grammar builder path.
104
+
91
105
  Current state:
92
106
  - Claude does not expose the same client-supplied grammar request surface as the OpenAI endpoint
93
107
  - Claude reasoning is still driven by explicit thinking behavior, not by `reasoning_effort` grammar composition
94
- - Claude requests therefore do not currently enable guided decoding
95
108
 
96
109
  ## Reasoning Effort
97
110
 
@@ -99,7 +112,7 @@ Reasoning effort is separate from ordinary structured outputs.
99
112
 
100
113
  ### Current state
101
114
 
102
- The OpenAI path maps `reasoning_effort` into grammar composition when a request constraint exists.
115
+ The OpenAI path maps `reasoning_effort` into grammar composition.
103
116
 
104
117
  Accepted values come from `ReasoningEffort::from_str`:
105
118
  - `none`
@@ -115,7 +128,7 @@ Non-Python builds also support:
115
128
  - `custom:<template>`
116
129
 
117
130
  Relevant code:
118
- - `src/utils/reasoning.rs`
131
+ - `src/utils/guidance_grammar.rs`
119
132
  - `src/server/server.rs`
120
133
  - `src/utils/guidance.rs`
121
134
 
@@ -124,7 +137,6 @@ Relevant code:
124
137
  Reasoning effort:
125
138
  - does not enable chat-template thinking by itself
126
139
  - only affects grammar composition
127
- - is ignored when no request constraint grammar is present
128
140
  - only works when reasoning start/end tokens are available
129
141
 
130
142
  If the tokenizer does not expose reasoning markers, the system logs a warning and falls back to the base grammar.
@@ -160,7 +172,7 @@ xinfer --m Qwen/Qwen3.5-35B-A3B-FP8/ --ui-server --d 0
160
172
  | Enforce text pattern | `structured_outputs` or `constraint` | `regex` |
161
173
  | Enforce full object schema | `structured_outputs` or `response_format` | `json` / `json_schema` |
162
174
  | Enforce custom grammar | `structured_outputs` or `constraint` | `grammar` / `lark` |
163
- | Constrain tagged structured output payload | `structured_outputs` | `structural_tag` |
175
+ | Constrain tool call payload | `structured_outputs` or automatic tool grammar | `structural_tag` / tool grammar |
164
176
  | Add a reasoning prefix | `reasoning_effort` | `low`, `medium`, `high`, etc. |
165
177
 
166
178
  ### 1. Constrain the answer to a fixed set
@@ -470,5 +482,5 @@ Check:
470
482
 
471
483
  - Guided decoding is only active when `SamplingParams.grammar` is present.
472
484
  - OpenAI currently has the richest client-facing grammar surface.
473
- - Claude does not currently expose request-level guided decoding.
485
+ - Claude currently reuses tool grammar, but not the same direct constraint request API.
474
486
  - No request-level grammar means no guided decoding.
@@ -46,6 +46,31 @@ snapshot capture remains dense.
46
46
  - Cached KV reuse is automatic; no `session_id` is required.
47
47
  - Sliding window attention limits how much cached context is effectively used.
48
48
 
49
+ ## CPU swap with prefix cache
50
+
51
+ When prefix cache is enabled, live sequence preemption is partial:
52
+
53
+ - Leading prefix/shared blocks stay on GPU and keep their sequence reference.
54
+ - Only the sequence-owned suffix blocks are copied to CPU swap.
55
+ - Swap-in reuses the retained GPU prefix blocks, allocates new suffix blocks,
56
+ and copies only the suffix KV back from CPU.
57
+
58
+ This is different from prefix-cache offload. Prefix-cache offload only helps when
59
+ an evicted cached prefix is requested again later. Partial sequence swap helps
60
+ immediately under memory pressure because it avoids recomputing the active
61
+ sequence suffix after preemption, even when no future request reuses that suffix.
62
+ For hybrid Mamba/GDN models, the active recurrent state remains tied to the
63
+ swapped sequence lifecycle and is not released until the sequence finishes or is
64
+ cancelled. On CUDA, Mamba/GDN prefix snapshots use a separate two-tier cache:
65
+ device snapshots are the fast path, and snapshots evicted from device memory are
66
+ spilled to CPU so a later KV prefix hit can promote the matching recurrent state
67
+ back instead of falling back to a shorter partial hit. Metal uses unified memory,
68
+ so this CPU spill tier is disabled there. The CUDA CPU snapshot tier is 4x the
69
+ device snapshot capacity. Prompt/prefill snapshots and final decode-boundary
70
+ snapshots are protected from ordinary decode-time snapshot churn. When the CPU
71
+ snapshot tier is full, LRU eviction frees at least 10% of the tier in one batch
72
+ before accepting new GDN/Mamba snapshot offloads.
73
+
49
74
  ## Inspecting cache hits
50
75
 
51
76
  Chat completion responses include the prefix-cache hit count under
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xinfer-ai",
3
- "version": "0.13.6",
4
- "assetVersion": "0.13.6",
3
+ "version": "0.13.8",
4
+ "assetVersion": "0.13.8",
5
5
  "description": "xInfer — a high-performance LLM inference engine in Rust with CUDA/Metal acceleration",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/guoqingbao/xinfer#readme",