File size: 5,655 Bytes
f882f26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Serving laya on one Tenstorrent p150

`tt serve changh95/laya` (or `tt-model serve` of the staged package) starts the model's own FastAPI app
(`tt_laya.server.app:app`) under uvicorn on port 20000; READY (`Application startup complete`) means the weights are
on the device, the megakernel is compiled, its trace captured and one warm-up request answered.

| profile | checkpoint (convaiinnovations/laya @ 246177e5) | encoder | default max_len / head_max_len |
| --- | --- | --- | --- |
| `english` (default) | repo root (what `laya.Agent("convaiinnovations/laya")` loads) | ModernBERT-large, 28 x 1024 | 512 / 192 |
| `typed-decisions` | `typed-decisions/` | ModernBERT-large, 28 x 1024 | 1024 / 256 |
| `multilingual` | `multilingual/` | mmBERT-base, 22 x 768 | 1024 / 256 |

## Routes

| route | body | response |
| --- | --- | --- |
| `POST /v1/systemone` | `state` (string, JSON object or conversation list), `questions` ({id: question}), optional `max_len`, `head_max_len`, `lang`, `min_confidence` (float or {bucket: float}), `model` (the served profile) | the official `laya-serve` response: `{"model": "laya-rl-agent", "answers": {...}, "usage": {...}, "routing": {...}}`; choice / score answers carry `x_jev_confidence` |
| `POST /v1/systemone/batch` | `states` (list) + the same fields | `{"results": [...], "total_usage": {...}}` (the official key; `usage` carries the same numbers) |
| `POST /predict`, `POST /predict_batch` | as above | exactly `Laya.predict` / `predict_batch` (no `routing`, no `x_jev_confidence`) |
| `GET /health` (`/v1/health`) | - | `{"status": "ok" | "starting" | "error", ...}` |
| `GET /info` | - | profile, engine, device (dispatch, grid), configuration, limits, checkpoint revision, calibration, batcher counters |

Errors: 400 malformed JSON / missing fields / an unpaired UTF-16 surrogate escape anywhere in the body (the official
message), 401 bad bearer token (`LAYA_API_KEY` set), 413 too many states / a state longer than `LAYA_MAX_STATE_CHARS`
characters (default 50,000 as the official server; measured on the text that gets tokenized) / body too large, 422 an
invalid question or parameter (the official message, naming it), 429 queue full (`Retry-After`), 503 starting / queue
timeout, 500 `inference failed`. `max_len` and `head_max_len` take any positive integers, as officially (`max_len` up
to `LAYA_MAX_LEN`, `head_max_len` up to 8192; a question whose option markers do not fit in `max_len` is a 422).

## Configuration (environment, read once at start; a bad value refuses to start)

| variable | values | default | meaning |
| --- | --- | --- | --- |
| `LAYA_PROFILE` | english, typed-decisions, multilingual | english | the checkpoint (the serve profiles set it) |
| `LAYA_ENGINE` | mk, ttnn, cpu | mk | megakernel; tt-nn ops (one trace per batch x length bucket; slower, see the card); float32 CPU reference |
| `LAYA_MAX_LEN` | 64 .. 8192 | the checkpoint's | largest per-request `max_len`; rows past 512 tokens run in tt-nn ops (slower) |
| `LAYA_MAX_BATCH` | 1 .. 256 | 32 | states merged into one engine call (requests that arrive together are batched) |
| `LAYA_MAX_INPUTS` | 1 .. 65536 | 1024 | states per request |
| `LAYA_MAX_QUESTIONS` / `LAYA_MAX_OPTIONS` | 1 .. 256 / 1 .. 127 | 64 / 100 | per request / per question (the official laya-serve limits) |
| `LAYA_FIDELITY` | HiFi4, HiFi3, HiFi2 | HiFi4 | matmul fidelity of the megakernel (see the evaluation) |
| `LAYA_CALIBRATION` | JSON file or text: `{"temperature": [3], "temperature_by_options": {...}}` | the checkpoint's | temperatures (the official `load_calibration` format; values clamped to [0.5, 5] as officially) |
| `LAYA_LANG_TEMPERATURES` | JSON: `{lang: {temperature, temperature_by_options}}` | none | per-language temperatures, selected by the request's `lang` |
| `LAYA_API_KEY` | string | unset | require `Authorization: Bearer <key>` (the official variable) |
| `LAYA_MAX_STATE_CHARS` | 0 .. 10^8 | 50000 | longest state (characters of its tokenized text); 0 = no cap |
| `LAYA_WARMUP_LONG_TOKENS` | 0 .. 262144 | 8192 | start-up compiles the long-row buckets with batch x length <= this (always (1, longest)) |
| `LAYA_BATCH_WINDOW_MS`, `LAYA_QUEUE_DEPTH`, `LAYA_QUEUE_TIMEOUT_S` | ms, requests, s | 0, 256, 60 | batching window and queue |
| `LAYA_SEQ_BUCKETS`, `LAYA_BATCH_BUCKETS` | multiples of 32 in 64 .. 8192; 1 .. 256 | per LAYA_MAX_LEN; 1,2,4,8,16,32 | tt-nn engine buckets |
| `LAYA_DISPATCH` | eth, worker | eth | ETH dispatch gives the 12 x 10 grid the megakernel needs |
| `LAYA_WEIGHTS_DIR` | path | unset | a local snapshot of the repo instead of the HF cache |

Per-request (runtime) parameters: `state`, `questions` (types, criteria, labels, option order), `max_len`,
`head_max_len`, `lang`, `min_confidence`, the batch of states. Batch size and lengths are not configuration: every
megakernel launch runs at its real size on one of two programs compiled at start (launches of <= 10 / <= 20 row tiles
of 32 tokens, one trace each).

Rows longer than 512 tokens (`LAYA_MAX_LEN` > 512; the typed-decisions and multilingual profiles default to 1024) run
in tt-nn operations with one trace per (batch, length) bucket. The warm-up compiles every long bucket with
batch x length <= `LAYA_WARMUP_LONG_TOKENS` (default 8192: batches 1, 2, 4, 8 of 1024 tokens; always (1,
`LAYA_MAX_LEN`)) before the megakernel, so ordinary long requests do not compile; a request that needs a larger
bucket compiles it once (up to about a minute on a cold kernel cache; the tt-metal kernel cache keeps it for later
starts) and makes the megakernel re-capture its traces once (no recompilation; `tt_laya/tt/traces.py`).