mlboydaisuke commited on
Commit
c8cd91b
·
verified ·
1 Parent(s): bd626ac

Add Inkling-2-Mini_mixed_int4_gpu.litertlm for the GPU and update the card and the manifest

Browse files
.gitattributes CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  Inkling-2-Mini_int8.litertlm filter=lfs diff=lfs merge=lfs -text
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  Inkling-2-Mini_int8.litertlm filter=lfs diff=lfs merge=lfs -text
37
+ Inkling-2-Mini_mixed_int4_gpu.litertlm filter=lfs diff=lfs merge=lfs -text
Inkling-2-Mini_mixed_int4_gpu.litertlm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa342804689b929a522befeee54b2a2597f9e283610a605bef60e4e924ff9fd3
3
+ size 20169834496
README.md CHANGED
@@ -16,18 +16,30 @@ tags:
16
 
17
  # Inkling-2-Mini LiteRT-LM
18
 
19
- This repository is a conversion of [thinkingmachines/Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) to LiteRT-LM, for text and image input. On an Apple M4 Max with 128 GB, the one Mac it was tried on, a text-only benchmark with a 1,024-token prompt decoded 256 tokens at 7.05 tok/s on the GPU (WebGPU) and 3.36 tok/s on the CPU, with LiteRT-LM 0.19.2 (2026-11-22).
20
 
21
- [LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM) is Google's runtime for running language models on your own device. Download the 27.74 GB file [`Inkling-2-Mini_int8.litertlm`](https://huggingface.co/litert-community/Inkling-2-Mini/blob/main/Inkling-2-Mini_int8.litertlm). Its first run on each backend writes caches next to it: the file and the caches of both backends take 80.67 GB of disk. Run these commands in its folder, from a fresh Python 3.13 virtual environment: they install the runtime, download a public photo, pad it to a square and ask about it on the GPU.
 
 
 
 
 
 
 
22
 
23
  ```bash
24
  pip install litert-lm==0.19.2 pillow
25
  curl -L -o cat.jpeg https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg
26
  python3 -c "from PIL import Image, ImageOps; im = ImageOps.exif_transpose(Image.open('cat.jpeg')).convert('RGB'); s = max(im.size); sq = Image.new('RGB', (s, s)); sq.paste(im); sq.save('cat_square.png')"
27
- litert-lm run Inkling-2-Mini_int8.litertlm --backend gpu --vision-backend gpu --attachment cat_square.png --prompt "Describe this picture."
28
  ```
29
 
30
- On the CPU:
 
 
 
 
 
 
31
 
32
  ```bash
33
  litert-lm run Inkling-2-Mini_int8.litertlm --backend cpu --vision-backend cpu --attachment cat_square.png --prompt "Describe this picture."
@@ -36,79 +48,78 @@ litert-lm run Inkling-2-Mini_int8.litertlm --backend cpu --vision-backend cpu --
36
  The GPU command printed its thought between `[thinking]` and `[/thinking]`, then this answer:
37
 
38
  ```text
39
- <|message_model|><|content_text|>The photo shows a very fluffy, stocky cat-like animal—likely a Pallas’s cat/manul—walking across a snow-covered surface. Its thick fur is a mix of gray, tan, and brown with darker mottling, and a light dusting of frost or snow sits along its back. The animal has a rounded face, small rounded ears, dark stripes around the muzzle and eyes, and a somewhat grumpy expression. One front leg is reaching forward and slightly blurred, suggesting motion, while the other legs are planted on the snow.
40
-
41
- In the background are vertical pale tree trunks, possibly birch, with dark markings and frost, plus a chain-link fence visible at the left edge. The lower part of the image is a solid black band.<|end_message|>
42
  ```
43
 
 
 
44
  ## When it does not work
45
 
46
- - **Phones.** Not tried: the file is larger than the 12 GB of memory of a Galaxy S26.
47
- - **Prompts over 4,096 tokens.** The context holds 4,096 tokens, and a picture takes 256 of them. Given a longer prompt, the CPU command above printed `An error occurred` on stdout and a Python traceback on stderr that ends with `RuntimeError: INVALID_ARGUMENT: Input token ids are too long. Exceeding the maximum number of tokens allowed: 7480 >= 4096`. It still exited with code 0, so the output is the only sign of the failure.
 
 
48
  - **Pictures that are not square.** The runtime stretches every picture to 640 × 640 pixels without keeping its proportions, so a circle in a wide picture becomes an oval. Pad the picture to a square first, black at the right and bottom, as the `python3` command above does.
49
 
50
  ## First run
51
 
52
- | | GPU (WebGPU) | CPU |
53
  |---|---:|---:|
54
- | Caches the commands above wrote | 25.90 GB | 27.03 GB |
55
- | First run of the commands above, reply included | 102 s | 224 s |
56
- | Engine creation in a first text-only run, writing the caches | 38.18 s | 22.44 s |
57
- | Engine creation in later text-only runs, reading those caches | 3.252–3.513 s | 0.445–0.935 s |
58
 
59
  ## Performance
60
 
61
- | Backend | Prefill (tok/s) | Decode (tok/s) | Time to first token |
62
- |---|---:|---:|---:|
63
- | GPU (WebGPU) | 80.75 | 7.05 | 12.82 s |
64
- | CPU (XNNPACK, default threads) | 40.46 | 3.36 | 25.61 s |
 
65
 
66
- Apple M4 Max (128 GB, macOS 27.0), LiteRT-LM 0.19.2 from PyPI, a 1,024-token text prompt and 256 generated tokens, the median of 3 processes, measured on 2026-11-22.
67
 
68
  Speed is still being tuned (updates follow).
69
 
70
  ## Memory
71
 
72
- | Peak memory footprint | GPU (WebGPU) | CPU |
73
- |---|---:|---:|
74
- | 1,024-token text prompt, 256 tokens out | about 11 GB | 9.15 GB |
75
- | One picture and a short question | 16.54–16.60 GB | 4.76–4.86 GB |
76
 
77
  ## Accuracy
78
 
79
- | Check | GPU (WebGPU) | CPU |
80
- |---|---:|---:|
81
- | 12 short text questions: answer correct | 12 / 12 | 12 / 12 |
82
- | The same 12: every reply token less than 1.0 logit below the author's model's top token | 12 / 12 | 12 / 12 |
83
- | 3 pictures: every reply token less than 1.0 logit below the author's model's top token | 3 / 3 | 3 / 3 |
84
- | One of them, a receipt with 16 lines of text: found in the answer | 14 / 16 | 15 / 16 |
85
- | 3-turn conversation: third answer correct | pass | pass |
86
 
87
- The pictures went to the author's model as the same 640 × 640 pixels.
88
 
89
  The author's model found all 16 from a different input: the picture at its own size, 768 image tokens instead of 256, at the lowest thinking effort.
90
 
91
- None of the WebGPU runs above printed a `Validation error` message.
92
 
93
  ## Limitations
94
 
95
- - After each complete reply, LiteRT-LM prefills the reply again into the KV cache, thought included, so the thought stays in the conversation and counts toward the 4,096 tokens. In a two-turn WebGPU conversation through the Python API, the context held 605 tokens after the first turn: the cat picture, its question and the reply, 184 of them the thought. On LiteRT-LM 0.19.2, the reply's stream in the Python API ended only after this prefill: 3.5–7.4 s after `<|end_message|>` arrived on the CPU and 6.6–8.6 s on WebGPU. Through the Python API, the thought arrives in a separate `thinking` channel.
96
- - Start a new conversation after a message fails because it does not fit in the 4,096-token context. On LiteRT-LM 0.19.2, after such a failure, the next three messages in the same conversation, two of them short, all failed with `INTERNAL: Task failed with state: 7`, while a new conversation answered. This was measured once with another file, not with this one.
97
  - The model's markers `<|message_model|>`, `<|content_text|>` and `<|end_message|>` come out as text, in the command's output and in the reply text of the Python API. Remove them in your app.
98
- - On the CPU, the same greedy question can get a different reply in a new process. On WebGPU, the photo asked in two processes got the same reply both times.
99
- - Create one Engine per conversation. This file keeps a running state for its short convolutions, and on LiteRT-LM 0.19.2 a new conversation on the same Engine can continue from the previous conversation's state ([LiteRT-LM#3165](https://github.com/google-ai-edge/LiteRT-LM/issues/3165)). This was not measured on this file.
100
- - After the first turn of a conversation, LiteRT-LM can put a token of the conversation into the KV cache without its embedding, because in this file the text embedder is a model of its own and the decoder takes embeddings. Later answers can then differ from what the model answers to the same messages in one prompt. This was read in the source of LiteRT-LM 0.19.1 and measured with 0.18.1 on WeVisOne-VL-2B and Qwen2.5-Coder-1.5B-Instruct, not on this file. One question per conversation avoids it, as does a new conversation that starts with the earlier messages and the new question.
101
- - Tool calls were not tried with this file.
102
 
103
  ## How it was made
104
 
105
- - The file was converted from the author's revision `ed40e7da625f594fc9c4990f5f66be24873c22d7`, which stores the experts in NVFP4 and MXFP8 and the other weights in bf16.
106
- - The file holds four models: the text embedder, the text decoder, the vision encoder and the vision adapter. The author's `mtp.safetensors` is not in it.
107
- - It keeps int8 weights per output channel for the experts, the lm_head and most other linear layers, and fp32 weights for the routers, the attention-residual queries and two small integer-valued matrices. The text embedder's token table is int8, with one scale per row. The vision encoder and adapter keep fp32 weights.
108
- - It declares fp32 activations for all four models.
109
  - The tokenizer is the author's `tokenizer.json`, byte for byte.
110
- - The file's chat template is the author's, with six edits for LiteRT-LM's template engine.
111
 
112
  ## License
113
 
114
- Apache 2.0, the license of the author's model: [LICENSE](https://huggingface.co/litert-community/Inkling-2-Mini/blob/main/LICENSE). The author's [Model Acceptable Use Policy](https://thinkingmachines.ai/model-acceptable-use-policy/) covers modified versions like this one.
 
16
 
17
  # Inkling-2-Mini LiteRT-LM
18
 
19
+ This repository is a conversion of [thinkingmachines/Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) to LiteRT-LM, for text and image input. On an Apple M4 Max with 128 GB and macOS 27.0, a text-only benchmark with a 1,024-token prompt decoded 256 tokens on the GPU (WebGPU) at 8.64 tok/s with the GPU file and at 7.23 tok/s with the int8 file, measured in turn with LiteRT-LM 0.19.2.
20
 
21
+ [LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM) is Google's runtime for running language models on your own device. Download the file for your backend:
22
+
23
+ | Backend | File | Size |
24
+ |---|---|---:|
25
+ | GPU | [`Inkling-2-Mini_mixed_int4_gpu.litertlm`](https://huggingface.co/litert-community/Inkling-2-Mini/blob/main/Inkling-2-Mini_mixed_int4_gpu.litertlm) | 20.17 GB |
26
+ | CPU | [`Inkling-2-Mini_int8.litertlm`](https://huggingface.co/litert-community/Inkling-2-Mini/blob/main/Inkling-2-Mini_int8.litertlm) | 27.74 GB |
27
+
28
+ In that benchmark, the GPU file used more memory than the int8 file, and engine creation took longer with the GPU file. The first run of the commands below writes caches next to the file: the GPU file and its caches take 34.46 GB of disk, and the int8 file and its CPU caches 54.77 GB. Run these commands in the file's folder, from a fresh Python 3.13 virtual environment: they install the runtime, download a public photo and pad it to a square.
29
 
30
  ```bash
31
  pip install litert-lm==0.19.2 pillow
32
  curl -L -o cat.jpeg https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg
33
  python3 -c "from PIL import Image, ImageOps; im = ImageOps.exif_transpose(Image.open('cat.jpeg')).convert('RGB'); s = max(im.size); sq = Image.new('RGB', (s, s)); sq.paste(im); sq.save('cat_square.png')"
 
34
  ```
35
 
36
+ On the GPU, with the GPU file:
37
+
38
+ ```bash
39
+ litert-lm run Inkling-2-Mini_mixed_int4_gpu.litertlm --backend gpu --vision-backend gpu --attachment cat_square.png --prompt "Describe this picture."
40
+ ```
41
+
42
+ On the CPU, with the int8 file:
43
 
44
  ```bash
45
  litert-lm run Inkling-2-Mini_int8.litertlm --backend cpu --vision-backend cpu --attachment cat_square.png --prompt "Describe this picture."
 
48
  The GPU command printed its thought between `[thinking]` and `[/thinking]`, then this answer:
49
 
50
  ```text
51
+ <|message_model|><|content_text|>The photo shows a small, stocky, fluffy wild cat—likely a Pallas’s cat (manul)—walking across a snow-covered surface. Its thick gray-brown fur is speckled and dusted with snow, giving it a frosty, mottled look. The cat has a flat face, small rounded ears, dark stripes on its cheeks, and a somewhat grumpy expression. One front leg is stretched forward and slightly blurred, suggesting it is in motion, while the other legs support its body. In the background are vertical pale tree trunks, possibly birch, with snow and dark markings, plus a chain-link fence visible on the left. The bottom part of the image is a solid black band.<|end_message|>
 
 
52
  ```
53
 
54
+ With LiteRT-LM 0.20.0, the GPU command printed the same bytes as with 0.19.2. The int8 file was not tried with 0.20.0.
55
+
56
  ## When it does not work
57
 
58
+ - **The GPU file on the CPU.** Not checked: its text questions and pictures were not run on the CPU, and its CPU speed was not measured. On the CPU, use the int8 file.
59
+ - **Phones.** Not tried: both files are larger than the 12 GB of memory of a Snapdragon Galaxy S26.
60
+ - **Other computers.** Not tried: only the Mac above ran these files.
61
+ - **Prompts over 4,096 tokens.** The context holds 4,096 tokens, and a picture takes 256 of them. Given a longer prompt, both commands above printed `An error occurred` on stdout and a Python traceback on stderr that ends with `RuntimeError: INVALID_ARGUMENT: Input token ids are too long. Exceeding the maximum number of tokens allowed: 7480 >= 4096`. They still exited with code 0, so the output is the only sign of the failure.
62
  - **Pictures that are not square.** The runtime stretches every picture to 640 × 640 pixels without keeping its proportions, so a circle in a wide picture becomes an oval. Pad the picture to a square first, black at the right and bottom, as the `python3` command above does.
63
 
64
  ## First run
65
 
66
+ | | GPU file, GPU | int8 file, CPU |
67
  |---|---:|---:|
68
+ | First run of each file's command above, reply included | under 2 min | under 4 min |
 
 
 
69
 
70
  ## Performance
71
 
72
+ | File | Backend | Prefill (tok/s) | Decode (tok/s) | Time to first token | Engine creation, reading the caches |
73
+ |---|---|---:|---:|---:|---:|
74
+ | GPU file | GPU (WebGPU) | 84.89 | 8.64 | 12.18 s | 10.528–11.937 s |
75
+ | int8 file | GPU (WebGPU) | 84.82 | 7.23 | 12.21 s | 2.442–3.214 s |
76
+ | int8 file | CPU (XNNPACK, default threads) | 40.46 | 3.36 | 25.61 s | 0.445–0.935 s |
77
 
78
+ Apple M4 Max (128 GB, macOS 27.0), LiteRT-LM 0.19.2 from PyPI, a 1,024-token text prompt and 256 generated tokens, the median of 3 processes (for engine creation, the range of the 3).
79
 
80
  Speed is still being tuned (updates follow).
81
 
82
  ## Memory
83
 
84
+ | Peak memory footprint | GPU file, GPU (WebGPU) | int8 file, GPU (WebGPU) | int8 file, CPU |
85
+ |---|---:|---:|---:|
86
+ | 1,024-token text prompt, 256 tokens out | 16.53–16.54 GB | about 11 GB | 9.15 GB |
87
+ | One picture and a short question | 22.60–22.63 GB | 16.54–16.60 GB | 4.76–4.86 GB |
88
 
89
  ## Accuracy
90
 
91
+ | Check | GPU file, GPU (WebGPU) | int8 file, GPU (WebGPU) | int8 file, CPU |
92
+ |---|---:|---:|---:|
93
+ | 12 short text questions: answer correct | 12 / 12 | 12 / 12 | 12 / 12 |
94
+ | The same 12: every reply token less than 1.0 logit below the author's model's top token | 11 / 12 | 12 / 12 | 12 / 12 |
95
+ | 3 pictures: every reply token less than 1.0 logit below the author's model's top token | 3 / 3 | 3 / 3 | 3 / 3 |
96
+ | One of them, a receipt with 16 lines of text: found in the answer | 15 / 16 | 14 / 16 | 15 / 16 |
97
+ | 3-turn conversation: third answer correct | pass | pass | pass |
98
 
99
+ In the remaining reply of the GPU file, one token is 1.12 logits below the author's model's top token.
100
 
101
  The author's model found all 16 from a different input: the picture at its own size, 768 image tokens instead of 256, at the lowest thinking effort.
102
 
103
+ None of the WebGPU runs above, with either file, printed a `Validation error` message.
104
 
105
  ## Limitations
106
 
107
+ - After each complete reply, LiteRT-LM prefills the reply again into the KV cache, thought included, so the thought stays in the conversation and counts toward the 4,096 tokens. In a two-turn WebGPU conversation with the int8 file through the Python API, the context held 605 tokens after the first turn: the cat picture, its question and the reply, 184 of them the thought. With the int8 file on LiteRT-LM 0.19.2, the reply's stream in the Python API ended only after this prefill: 3.5–7.4 s after `<|end_message|>` arrived on the CPU and 6.6–8.6 s on WebGPU. Through the Python API, the thought arrives in a separate `thinking` channel.
108
+ - Start a new conversation after a message fails because it does not fit in the 4,096-token context. On LiteRT-LM 0.19.2, after such a failure, the next three messages in the same conversation, two of them short, all failed with `INTERNAL: Task failed with state: 7`, while a new conversation answered. This was measured once with another file, not with these two.
109
  - The model's markers `<|message_model|>`, `<|content_text|>` and `<|end_message|>` come out as text, in the command's output and in the reply text of the Python API. Remove them in your app.
110
+ - On the CPU, the same greedy question can get a different reply in a new process. On the GPU, each file, asked about the photo in two processes, gave the same reply both times.
111
+ - Create one Engine per conversation. Both files keep a running state for their short convolutions, and on LiteRT-LM 0.19.2 a new conversation on the same Engine can continue from the previous conversation's state ([LiteRT-LM#3165](https://github.com/google-ai-edge/LiteRT-LM/issues/3165)). This was not measured on these files.
112
+ - After the first turn of a conversation, LiteRT-LM can put a token of the conversation into the KV cache without its embedding, because in both files the text embedder is a model of its own and the decoder takes embeddings. Later answers can then differ from what the model answers to the same messages in one prompt. This was read in the source of LiteRT-LM 0.19.1 and measured with 0.18.1 on WeVisOne-VL-2B and Qwen2.5-Coder-1.5B-Instruct, not on these files. One question per conversation avoids it, as does a new conversation that starts with the earlier messages and the new question.
113
+ - Tool calls were not tried with either file.
114
 
115
  ## How it was made
116
 
117
+ - Both files were converted from the author's revision `ed40e7da625f594fc9c4990f5f66be24873c22d7`, which stores the experts in NVFP4 and MXFP8 and the other weights in bf16.
118
+ - The author's `mtp.safetensors` is not in either file.
119
+ - The GPU file's models differ from the int8 file's only in the text decoder's experts.
 
120
  - The tokenizer is the author's `tokenizer.json`, byte for byte.
121
+ - The chat template is the author's, with six edits for LiteRT-LM's template engine.
122
 
123
  ## License
124
 
125
+ Apache 2.0, the license of the author's model: [LICENSE](https://huggingface.co/litert-community/Inkling-2-Mini/blob/main/LICENSE). The author's [Model Acceptable Use Policy](https://thinkingmachines.ai/model-acceptable-use-policy/) covers modified versions like these two files.
litertlm_manifest.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
- "manifest_schema": "0.1.3",
3
  "repo": "litert-community/Inkling-2-Mini",
4
- "generated": "2026-11-22",
5
  "generator": "make_manifest.py",
6
  "model": {
7
  "display_name": "Inkling-2-Mini",
@@ -29,13 +29,17 @@
29
  "is_reasoning": true
30
  }
31
  ]
 
 
 
 
32
  }
33
  },
34
  "variants": [
35
  {
36
  "file": "Inkling-2-Mini_int8.litertlm",
37
- "size_bytes": 27741208576,
38
  "sha256": "bb1dcd5b1f7616fc94b60965394352497f1941ae161f88ef662e3bd2c7620f3b",
 
39
  "sections": [
40
  {
41
  "type": "LlmMetadataProto",
@@ -148,7 +152,8 @@
148
  }
149
  ],
150
  "known_issues": [
151
- "On the CPU, greedy replies can differ from one process to the next: a second run of each of 3 picture prompts (same file, prompt and settings) gave the same reply for one picture and other replies for two (from reply token 15 and from reply token 43). On WebGPU, one picture run in two processes gave the same reply both times."
 
152
  ],
153
  "context_length": 4096
154
  }
 
1
  {
2
+ "manifest_schema": "0.1.5",
3
  "repo": "litert-community/Inkling-2-Mini",
4
+ "generated": "2026-11-27",
5
  "generator": "make_manifest.py",
6
  "model": {
7
  "display_name": "Inkling-2-Mini",
 
29
  "is_reasoning": true
30
  }
31
  ]
32
+ },
33
+ "session_defaults": {
34
+ "temperature": 1.0,
35
+ "source": "generation_config"
36
  }
37
  },
38
  "variants": [
39
  {
40
  "file": "Inkling-2-Mini_int8.litertlm",
 
41
  "sha256": "bb1dcd5b1f7616fc94b60965394352497f1941ae161f88ef662e3bd2c7620f3b",
42
+ "size_bytes": 27741208576,
43
  "sections": [
44
  {
45
  "type": "LlmMetadataProto",
 
152
  }
153
  ],
154
  "known_issues": [
155
+ "On the CPU, greedy replies can differ from one process to the next: a second run of each of 3 picture prompts (same file, prompt and settings) gave the same reply for one picture and other replies for two (from reply token 15 and from reply token 43). On WebGPU, one picture run in two processes gave the same reply both times.",
156
+ "Inkling-2-Mini_mixed_int4_gpu.litertlm is in this repo and deliberately not a variant of this manifest. Its text questions, pictures and speed were checked only on one Mac's GPU, and no field of a variant can limit a file to one platform. If it were listed as a variant with only the GPU backend and no recommended entry, beside Inkling-2-Mini_int8.litertlm, the manifest readers in https://github.com/john-rocky/hf-to-litertlm would choose it for every request that asks for the GPU or names no backend, unless the request names macOS. On the CPU, use Inkling-2-Mini_int8.litertlm."
157
  ],
158
  "context_length": 4096
159
  }