You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a586f3d
Browse filesBrowse the repository at this point in the historyBrowse files
fix: kill -USR1 prints the stacks of a CUDA server too
cmd_serve returned into _serve_cuda before it registered the SIGUSR1
stack dump, so the dump its comment calls "the way to see where a silent
server waits" existed only on the Mac. The registration now comes before
the backend branch; nothing else moves.
Test: the handler is registered before _serve_cuda runs (host; fails
before the change). The CUDA dispatch test stubs the registration, as the
MLX tests do.
(cherry picked from commit 10e0cc7)
Copy file name to clipboardExpand all lines: README.md
+31-5Lines changed: 31 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# TensorFold
2
2
3
-
TensorFold serves text models on Apple Silicon and NVIDIA GPUs through an OpenAI-compatible API.
3
+
TensorFold serves language models on Apple Silicon and NVIDIA GPUs through an OpenAI-compatible API.
4
4
Each model family supplies its own kernels and draft verification.
5
5
6
6
```bash
@@ -12,6 +12,11 @@ Use `http://127.0.0.1:8080/v1` as the client base URL and the model ID from `/v1
12
12
Python 3.11 or newer is required, and MLX 0.32.2 or newer on a Mac (pip installs it). See the [runbook](RUNBOOK.md)
13
13
for installation and a first request.
14
14
15
+
## Image input
16
+
17
+
Install `pip install '.[vision]'` from this branch and start a compatible Qwen3.5/3.8 dense checkpoint with `--vision` to accept image and text content parts through the same lane engine.
18
+
See [image input](docs/vision.md) for the API, checkpoint requirements, cache behavior and qualification status.
19
+
15
20
## Models
16
21
17
22
| Model | Checkpoint | Backend | Drafting |
@@ -21,8 +26,12 @@ for installation and a first request.
21
26
| Qwen3.8 Flash Next |`Vontra/Qwen3.8-Flash-Next-MLX-4bit-MTP`| MLX, CUDA | Included MTP head and context copies |
22
27
| GLM-5.3-Flash |`Vontra/GLM-5.3-Flash-MLX-4bit-MTP`| MLX on a 256 GB Mac, CUDA with two ranks | MTP; optional DFlash2 on CUDA |
| DeepSeek-V4-Flash |`mlx-community/DeepSeek-V4-Flash-4bit`| MLX on a 256 GB Mac | DSpark or MTP, converted from DeepSeek's releases |
30
+
| Qwen3.8-27B (NVFP4) |`nvidia/Qwen3.8-27B-NVFP4` (ModelOpt: NVFP4 MLP, FP8 attention) | CUDA, one GPU |`z-lab/Qwen3.8-27B-DFlash2` and context copies |
24
31
| Qwen3.8-27B (EXL3, experimental) |`turboderp/Qwen3.8-27B-exl3` (branches `3.00bpw`, `4.00bpw`; any codebook, 1 to 8 bits per weight) | CUDA |`z-lab/Qwen3.8-27B-DFlash2` and context copies |
25
32
| Qwen3.8 Flash Next (EXL3, experimental) |`turboderp/Qwen3.8-Flash-Next-exl3` (branch `3.05bpw_h5_ng5`; any codebook, a width per tensor) | CUDA | Included MTP head and context copies |
| Qwen3.8 Flash Next (NVFP4) |`local-inference-lab/Qwen3.8-Flash-Next-NVFP4` (ModelOpt: NVFP4 experts, MXFP8 attention and DeltaNet); `RadixArk/Qwen3.8-Flash-Next-NVFP4` (bf16 besides the experts) | CUDA, one GPU | Included MTP head and context copies |
26
35
27
36
`tensorfold models` lists families and checkpoints. `tensorfold info MODEL` checks configuration without
28
37
fetching weights. `serve` downloads a missing checkpoint; `pull` downloads it ahead of time.
@@ -43,7 +52,9 @@ keep the installed MLX version within the package requirements. The named checkp
43
52
`mtp-4bit.safetensors`, which `pull` and `serve` check for.
44
53
45
54
Flash Next requires 4-bit/group-32 weights. Without an MTP head it can run without MTP drafting on MLX;
46
-
on CUDA, explicitly pass `--no-drafts`. Nemotron CUDA requires 4-bit/group-64 weights and an MTP head
55
+
on CUDA, explicitly pass `--no-drafts`. On one CUDA GPU it also reads the two NVFP4 exports in the table as they
56
+
ship; see [the recipe](docs/recipes/qwen3.8-flash-next.md#nvfp4-checkpoints) for their formats, the checks they
57
+
passed and what is not supported. Nemotron CUDA requires 4-bit/group-64 weights and an MTP head
47
58
unless `--no-drafts` is set. GLM on MLX reads 4-bit/group-64 weights and mlx-lm's mixed-bit conversions,
48
59
whose 5-, 6- and 8-bit tensors take their own row kernels; it needs MLX 0.32.2 or later. GLM CUDA reads
49
60
MLX 4-bit/group-64 weights and the experimental `Mia-AiLab/GLM-5.3-Flash-EXL3-TR3-4bpw` conversion. GLM's optional
@@ -55,6 +66,11 @@ Gemma 4 has no draft head. It drafts copies of its context, and chains from z-la
55
66
with an 8-bit router, as the mlx-community conversion stores them; `serve` refuses other Gemma 4 layouts
56
67
before downloading.
57
68
69
+
DeepSeek-V4-Flash reads the mlx-community conversion (affine 4-bit/group-64 weights, mxfp4 routed experts) and
70
+
needs MLX 0.32.2 or later. Its draft heads come from DeepSeek's MIT-licensed releases, converted once with
71
+
`python -m tensorfold.families.deepseek_v4.convert` and passed with `--drafter`; see
72
+
[its recipe](docs/recipes/deepseek-v4-flash.md).
73
+
58
74
See the [recipes](docs/recipes/README.md) for supported formats and backend limits.
59
75
60
76
## Exact decoding
@@ -80,6 +96,7 @@ between MLX and CUDA, different quantizations, or different tensor-parallel rank
80
96
| --- | --- | --- |
81
97
|`--host`, `--port`| Listen address, default `127.0.0.1:8080`| Both |
82
98
|`--name`| Model ID advertised to clients | Both |
99
+
|`--vision`| Opt-in Qwen3.5/3.8 dense image input | Both |
83
100
|`--alias`| Additional model IDs | MLX |
84
101
|`--context N`| Prompt plus reply capacity | Both |
85
102
|`--max-tokens N`| Default reply limit, 4096 | Both |
@@ -95,6 +112,7 @@ between MLX and CUDA, different quantizations, or different tensor-parallel rank
95
112
|`--kv-dtype bf16`, `int8`, `int4`| Flash Next: `int8` or `int4` stores keys and values with one fp16 scale per 32 values. Other families and the MLX path refuse it | CUDA |
96
113
|`--mtp-confidence P`| Flash Next: stop a draft chain before a later draft under this probability, 0 to 1 (default 0.30) | CUDA |
97
114
|`--tp 2 --rank R --master HOST`| Two-rank CUDA execution | CUDA |
115
+
|`--decode-share F`| While a prompt prefills, running replies keep moving for this share of each chunk's time and later prompts start later (default 0.25; 0 prefills whole prompts first, as 0.3.6.2) | MLX |
Replace the documentation address with rank 0's reachable address. Both ranks must agree on context and
91
-
drafting settings. The default rendezvous port is 29551. GLM requires two CUDA ranks; Flash Next can use
92
-
one or two and needs `--no-drafts` when its checkpoint lacks an MTP head.
93
+
drafting settings. The default rendezvous port is 29551. The rendezvous port and the link between the ranks
94
+
are not authenticated: keep them on a private link, or firewall the port to the peer. GLM requires two CUDA
95
+
ranks; Flash Next can use one or two and needs `--no-drafts` when its checkpoint lacks an MTP head.
93
96
94
97
## Memory and context
95
98
@@ -131,6 +134,7 @@ to refresh installed metadata and dependencies. Update inside the container when
131
134
| Rejected checkpoint | Quantization, model family and draft-head requirements |
132
135
| Client cannot connect | Server process, `/health`, base URL and model ID |
133
136
| Two-rank startup waits | Link reachability, rendezvous port, NCCL devices and matching settings |
137
+
| CUDA start stops after `loading …`, GPU idle |`kill -USR1 <pid>` prints every thread's Python stack. A wait in the extension build is a build lock, whose path the start log names: when no other build is running, stop the start, delete the lock and start again |
134
138
135
139
Unsupported architectures or formats need a family implementation. See [adding a family](docs/recipes/adding-a-family.md)
136
140
or [adding a CUDA family](docs/recipes/adding-a-cuda-family.md); forcing an unsupported checkpoint to load
`src/tensorfold/families/deepseek_v4/vendor/encoding_dsv4.py` is the unmodified `encoding/encoding_dsv4.py` of
85
+
[deepseek-ai/DeepSeek-V4-Flash](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash) (revision 60d8d70), and
86
+
`tests/fixtures/deepseek_v4/` holds two of its test cases, MIT License, Copyright (c) 2023 DeepSeek.
87
+
The MTP layer TensorFold drafts with comes from that checkpoint's last shard (MIT), converted by
88
+
`families/deepseek_v4/convert.py`.
89
+
84
90
TensorFold ships no model weights. The `z-lab/Qwen3.8-27B-DFlash2` model card states Apache-2.0.
85
91
The optional `incoai/GLM-5.3-Flash-DFlash2` model card states CC BY-NC-ND 4.0, for non-commercial use
86
92
without derivatives. Each checkpoint keeps its own license.
Copy file name to clipboardExpand all lines: docs/api.md
+28-10Lines changed: 28 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,14 @@ The base URL is `http://127.0.0.1:8080/v1` with the default server settings.
6
6
| --- | --- |
7
7
|`GET /v1/models`| Served model ID; MLX also lists configured aliases |
8
8
|`GET /health`| Server health and available status information |
9
-
|`POST /v1/chat/completions`| Text chat, tools and reasoning; streamed or non-streamed |
9
+
|`POST /v1/chat/completions`| Text chat, optional image input, tools and reasoning; streamed or non-streamed |
10
10
|`POST /v1/completions`| Raw text without a chat template; MLX also accepts token IDs |
11
11
12
12
On MLX, a completions body containing a nonempty `messages` list uses chat handling. CUDA completions
13
13
require a string `prompt`.
14
-
Image, audio and video input or output requests receive HTTP 400.
14
+
With `--vision`, supported Qwen3.5/3.8 dense checkpoints accept user `image_url` content parts alongside text.
15
+
See [image input](vision.md) for data URLs, public image URLs, limits and cache behavior.
16
+
Unsupported image input, audio, video and non-text output requests receive HTTP 400.
15
17
16
18
## Request fields
17
19
@@ -27,20 +29,32 @@ Image, audio and video input or output requests receive HTTP 400.
27
29
|`stream`| Server-sent events with final usage | Both |
28
30
|`chat_template_kwargs.enable_thinking`| Template thinking toggle | Both |
29
31
|`draft`| False selects the serial reference; CUDA rejects it if the engine has no serial switch | Both |
30
-
|`ignore_eos`| Disable model end-of-sequence stopping; the reply limit still applies | MLX and GLM CUDA |
31
-
|`stop`| Stop at a string or any string in a list; omit the matched text from the response |MLX|
32
+
|`ignore_eos`| Disable model end-of-sequence stopping; the reply limit still applies | MLX, and GLM, Qwen3.8-27B and Qwen3.6 CUDA |
33
+
|`stop`| Stop at a string or any string in a list; omit the matched text from the response |Both|
32
34
|`reasoning_effort`|`none`, `minimal`, `low`, `medium`, `high` or `xhigh`| MLX |
|`priority`|`background` yields to foreground requests | MLX |
35
37
36
-
CUDA does not enforce the MLX-only fields above. Its Qwen engines also ignore `ignore_eos`. Unsupported
37
-
generation features include multiple choices through `n` and `logprobs`. On MLX, `ignore_eos: true`
38
-
keeps user-supplied `stop` strings active, including when a stop string spans streamed chunks.
39
-
MLX rejects malformed numeric controls and out-of-vocabulary raw prompt IDs with HTTP 400;
38
+
CUDA does not enforce the MLX-only fields above. Its Flash Next and Nemotron engines stop at an end token
39
+
whatever `ignore_eos` says. Unsupported generation features include multiple choices through `n` and `logprobs`.
40
+
`ignore_eos: true` keeps user-supplied `stop` strings active, including when a stop string spans streamed chunks.
41
+
Both backends reject a non-boolean `ignore_eos` or a malformed `stop` with HTTP 400 before a stream opens.
42
+
Both backends reject malformed `temperature`, `top_p`, `top_k` and `seed` values with HTTP 400, whether or not
43
+
the request samples: booleans, non-finite numbers, non-numeric strings, and non-integral `top_k` or `seed`.
44
+
MLX also rejects its other malformed numeric controls and out-of-vocabulary raw prompt IDs.
40
45
`top_k` at zero or below disables top-k filtering, and null sampling fields retain server defaults.
41
46
47
+
On CUDA, stop strings are checked after every token on the generated text, reasoning included, so drafted and
48
+
`"draft": false` replies stop at the same token; usage and `token_sha` count the tokens through the one that
49
+
completes the match. The GLM engine, and Flash Next and Nemotron on two ranks, decode on after a match to an end
50
+
token or the reply limit; the server returns the reply only up to the match. Where a CUDA engine honors
51
+
`ignore_eos`, end tokens inside the reply are decoded into its text, as on MLX, and `finish_reason` is `length`
52
+
unless a stop string or a tool call ended the reply.
53
+
42
54
On MLX, `--parallel auto` is the default: requests share rounds within the configured concurrency and memory
43
-
budget. Background work waits behind foreground requests. An active background request yields when a
55
+
budget. A new prompt prefills one chunk at a time, and running replies take rounds between its chunks for
56
+
`--decode-share` of each chunk's time (default 0.25): they keep moving, and queued prompts' first tokens come later.
57
+
`--decode-share 0` prefills each prompt whole first, as 0.3.6.2 did. Background work waits behind foreground requests. An active background request yields when a
44
58
foreground request needs its lane or memory, then restarts with already-delivered tokens suppressed.
45
59
Session-title requests are also treated as background work.
46
60
@@ -105,7 +119,11 @@ and fitting guidance before generation. MLX returns HTTP 400 for non-streamed re
105
119
`invalid_request_error` event after opening a stream. CUDA returns HTTP 400 before opening a stream.
106
120
The 0.3.4.1 MLX server capped that explicit limit to the remaining context.
107
121
When the request omits the reply limit, the server still caps its configured default to the remaining context.
108
-
MLX also returns generation errors in the stream after streaming starts.
122
+
CUDA returns HTTP 400 before generation when the chat template rejects the request or
123
+
`chat_template_kwargs` is neither an object nor null. A generation error returns HTTP 500 for a
124
+
non-streamed request; after a stream opens, both backends send an error event of type `server_error`,
125
+
then `[DONE]`. On two CUDA ranks such an error can leave the ranks out of step, so restart both: the 27B's
126
+
`--parallel` decoder refuses every later request until then, and the other two-rank engines don't detect it.
109
127
MLX also checks projected memory before prefill. CUDA checks its allocated cache capacity and model window.
110
128
A startup capacity estimate is not a measured release capacity.
0 commit comments