GiuliannoV commited on
Commit
0bae13d
·
verified ·
1 Parent(s): fdae90e

The Lernex engine with its speeds, and direct-mode sampling in generation_config.json

Browse files

Lernex quickstart with decode speeds against vLLM on an RTX 5070 Ti, the vLLM speeds remeasured on the same workload. llama.cpp's whole-context penalty window as 131072 (it rejects -1).

Files changed (2) hide show
  1. README.md +46 -13
  2. generation_config.json +5 -1
README.md CHANGED
@@ -270,8 +270,8 @@ at higher precision.
270
 
271
  | You have | Use | With | Size |
272
  |---|---|---|---|
273
- | A GPU with 16 GB or more | This repository, BF16 | Transformers, vLLM, SGLang | 6.2 GB |
274
- | A smaller GPU | [Metis-1.6-Praxis-FP8](https://huggingface.co/Lernex/Metis-1.6-Praxis-FP8) | vLLM, SGLang | 3.5 GB |
275
  | A Mac with Apple silicon | [Metis-1.6-Praxis-MLX-4bit](https://huggingface.co/Lernex/Metis-1.6-Praxis-MLX-4bit) or [-8bit](https://huggingface.co/Lernex/Metis-1.6-Praxis-MLX-8bit) | mlx-lm | 2.0 / 3.2 GB |
276
  | A laptop, a CPU, anything else | [Metis-1.6-Praxis-GGUF](https://huggingface.co/Lernex/Metis-1.6-Praxis-GGUF), Q4_K_M | llama.cpp | 2.0 GB |
277
 
@@ -300,13 +300,46 @@ with the request. The commands below pass the settings where an engine does not
300
  and keywords on purpose, and the penalty works against them: it cost 12 points on HumanEval+.
301
  - **Keep penalties off in direct mode.** Direct answers are short and rarely repeat, so a penalty
302
  only costs accuracy.
303
- - **In llama.cpp and Ollama, apply the penalty to the whole context** with `--repeat-last-n -1` (or
304
- `repeat_last_n -1`). By default they look at the last 64 tokens only.
305
  - **If your engine has no repetition penalty, use temperature 1.0** for thinking.
306
 
307
  I chose these by sweeping 13 thinking and 8 direct settings over MATH-500, GPQA Diamond, HumanEval+
308
  and IFEval, then comparing the finalists blind on 32 everyday conversations.
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  ### Transformers
311
 
312
  The Transformers implementation ships in this repository, so the model loads with
@@ -330,7 +363,7 @@ print(answer.strip())
330
  ```
331
 
332
  This implementation is the reference: it computes exactly what the native model computes, but it is
333
- not the fastest way to run it. For serving, use one of the engines below.
334
 
335
  ### vLLM
336
 
@@ -343,10 +376,10 @@ vllm serve Lernex/Metis-1.6-Praxis --trust-remote-code \
343
  [`vllm-metis`](https://github.com/lernex/vllm-metis) registers the model, a reasoning parser and a
344
  tool-call parser through vLLM's plugin system, so there is nothing to patch. You get the
345
  OpenAI-compatible API with the thinking returned apart from the answer, tool calls parsed and typed
346
- from your schema, prefix caching, chunked prefill and CUDA graphs. Praxis runs in BF16 on a 16 GB card: an RTX 5070 Ti decodes 201 tokens/s for a single stream
347
- and 1,836 tokens/s across 32. On a smaller card, serve
348
- [Metis-1.6-Praxis-FP8](https://huggingface.co/Lernex/Metis-1.6-Praxis-FP8) (3.5 GB), which is also
349
- the fastest option: 231 and 2,386 tokens/s.
350
 
351
  ```python
352
  from openai import OpenAI
@@ -391,7 +424,7 @@ git fetch origin pull/31134/head:metis16 && git checkout metis16
391
  cmake -B build # add -DGGML_CUDA=ON for NVIDIA; Metal is on by default on a Mac
392
  cmake --build build --config Release -j
393
  ./build/bin/llama-server -hf Lernex/Metis-1.6-Praxis-GGUF:Q4_K_M --jinja -ngl 99 -c 32768 \
394
- --temp 0.8 --top-p 0.95 --top-k 20 --repeat-penalty 1.05 --repeat-last-n -1
395
  ```
396
 
397
  `--jinja` uses the chat template inside the file, and the server returns the thinking in
@@ -433,9 +466,9 @@ user message and keeps it within an ongoing tool loop, as the model was trained.
433
 
434
  ### Tool calling
435
 
436
- Pass JSON-schema tools with `tools=`. The model writes each call after `<|tool_call|>`; the vLLM,
437
- SGLang and llama.cpp servers parse these into typed `tool_calls` for you. With Transformers, decode
438
- with `skip_special_tokens=False` to find them:
439
 
440
  ```python
441
  tools = [{
 
270
 
271
  | You have | Use | With | Size |
272
  |---|---|---|---|
273
+ | A GPU with 16 GB or more | This repository, BF16 | Lernex, Transformers, vLLM, SGLang | 6.2 GB |
274
+ | A smaller GPU | [Metis-1.6-Praxis-FP8](https://huggingface.co/Lernex/Metis-1.6-Praxis-FP8) | Lernex, vLLM, SGLang | 3.5 GB |
275
  | A Mac with Apple silicon | [Metis-1.6-Praxis-MLX-4bit](https://huggingface.co/Lernex/Metis-1.6-Praxis-MLX-4bit) or [-8bit](https://huggingface.co/Lernex/Metis-1.6-Praxis-MLX-8bit) | mlx-lm | 2.0 / 3.2 GB |
276
  | A laptop, a CPU, anything else | [Metis-1.6-Praxis-GGUF](https://huggingface.co/Lernex/Metis-1.6-Praxis-GGUF), Q4_K_M | llama.cpp | 2.0 GB |
277
 
 
300
  and keywords on purpose, and the penalty works against them: it cost 12 points on HumanEval+.
301
  - **Keep penalties off in direct mode.** Direct answers are short and rarely repeat, so a penalty
302
  only costs accuracy.
303
+ - **In llama.cpp and Ollama, apply the penalty to the whole context** with `--repeat-last-n 131072` (or
304
+ `repeat_last_n 131072`). By default they look at the last 64 tokens only, and they reject `-1`.
305
  - **If your engine has no repetition penalty, use temperature 1.0** for thinking.
306
 
307
  I chose these by sweeping 13 thinking and 8 direct settings over MATH-500, GPQA Diamond, HumanEval+
308
  and IFEval, then comparing the finalists blind on 32 everyday conversations.
309
 
310
+ ### Lernex
311
+
312
+ [Lernex](https://github.com/lernex/lernex-engine) is the inference engine I wrote for Metis, from
313
+ scratch, and the fastest way to run Praxis.
314
+
315
+ ```bash
316
+ git clone https://github.com/lernex/lernex-engine && cd lernex-engine
317
+ cmake -B build -DLX_ARCHS=all # NVIDIA from the RTX 30 series on; a Mac builds for Metal
318
+ cmake --build build -j
319
+ ./build/lernex run praxis # downloads the model, then chats in the terminal
320
+ ./build/lernex serve praxis # an OpenAI-compatible API on port 8080
321
+ ```
322
+
323
+ It needs CMake 3.28 and, for NVIDIA, the CUDA 13 toolkit. With no NVIDIA GPU, add
324
+ `-DLX_BACKEND_CUDA=OFF` for the CPU build. Decode speed on an RTX 5070 Ti in tokens per second,
325
+ against vLLM on the same files, with 512 prompt tokens and 256 generated per stream:
326
+
327
+ | | Lernex | vLLM |
328
+ |---|---|---|
329
+ | BF16, one stream | **294.5** | 204.2 |
330
+ | BF16, 32 streams | **2,141** | 1,871 |
331
+ | FP8, one stream | **295.1** | 235.3 |
332
+ | FP8, 32 streams | **2,489** | 2,268 |
333
+
334
+ In BF16, Lernex decodes from a lossless compressed copy of the weights: it reads fewer bytes for
335
+ every token with nothing lost, which is why BF16 runs as fast as FP8 for one stream.
336
+
337
+ `lernex serve` speaks the same API as vLLM below: the thinking comes back as `reasoning_content`,
338
+ tool calls as typed `tool_calls`, and `"chat_template_kwargs": {"enable_thinking": false}` gives a
339
+ direct answer. Lernex reads the sampling settings above from the model and switches to the direct
340
+ column by itself, so you never pass them. Weights run in the format the file stores, never
341
+ quantized behind your back: `--weights int8` or `--weights fp8` picks a narrower one, and
342
+ `lernex doctor praxis` shows every format, what fits on your machine and the speed to expect.
343
  ### Transformers
344
 
345
  The Transformers implementation ships in this repository, so the model loads with
 
363
  ```
364
 
365
  This implementation is the reference: it computes exactly what the native model computes, but it is
366
+ not the fastest way to run it. For serving, use Lernex or one of the engines below.
367
 
368
  ### vLLM
369
 
 
376
  [`vllm-metis`](https://github.com/lernex/vllm-metis) registers the model, a reasoning parser and a
377
  tool-call parser through vLLM's plugin system, so there is nothing to patch. You get the
378
  OpenAI-compatible API with the thinking returned apart from the answer, tool calls parsed and typed
379
+ from your schema, prefix caching, chunked prefill and CUDA graphs. Praxis runs in BF16 on a 16 GB card: an RTX 5070 Ti decodes 204 tokens/s for a single stream
380
+ and 1,871 tokens/s across 32. On a smaller card, serve
381
+ [Metis-1.6-Praxis-FP8](https://huggingface.co/Lernex/Metis-1.6-Praxis-FP8) (3.5 GB), which vLLM
382
+ also runs faster: 235 and 2,268 tokens/s.
383
 
384
  ```python
385
  from openai import OpenAI
 
424
  cmake -B build # add -DGGML_CUDA=ON for NVIDIA; Metal is on by default on a Mac
425
  cmake --build build --config Release -j
426
  ./build/bin/llama-server -hf Lernex/Metis-1.6-Praxis-GGUF:Q4_K_M --jinja -ngl 99 -c 32768 \
427
+ --temp 0.8 --top-p 0.95 --top-k 20 --repeat-penalty 1.05 --repeat-last-n 131072
428
  ```
429
 
430
  `--jinja` uses the chat template inside the file, and the server returns the thinking in
 
466
 
467
  ### Tool calling
468
 
469
+ Pass JSON-schema tools with `tools=`. The model writes each call after `<|tool_call|>`; the Lernex,
470
+ vLLM, SGLang and llama.cpp servers parse these into typed `tool_calls` for you. With Transformers,
471
+ decode with `skip_special_tokens=False` to find them:
472
 
473
  ```python
474
  tools = [{
generation_config.json CHANGED
@@ -9,5 +9,9 @@
9
  "temperature": 0.8,
10
  "top_p": 0.95,
11
  "top_k": 20,
12
- "repetition_penalty": 1.05
 
 
 
 
13
  }
 
9
  "temperature": 0.8,
10
  "top_p": 0.95,
11
  "top_k": 20,
12
+ "repetition_penalty": 1.05,
13
+ "direct": {
14
+ "temperature": 0.3,
15
+ "repetition_penalty": 1.0
16
+ }
17
  }