deciax: Running a Decision Model on TPU with JAX and Pallas
- EN
- ZH-CN
Table of Contents
Laya is a Decision Model that handles choice, score, and yes/no questions in a single forward pass. I ported its inference path to JAX and built deciax to run these models on TPU, then optimized the computation with Pallas.
In this benchmark1, a single TPU v6e chip reached a single-question p50 of 2.18 ms for the English model and 1.55 ms for the multilingual model. The fastest measured results on A100 SXM4, H100 PCIe, and H200 NVL were 6.4 / 4.0 ms, 4.8 / 3.2 ms, and 5.8 / 4.1 ms, respectively (English / multilingual).
At 50 questions per call, v6e Pallas reached 33.69 / 17.83 ms, roughly 2.3× faster than plain JAX. The fastest measured A100, H100, and H200 results were 68.8 / 36.2 ms, 44.0 / 23.2 ms, and 39.8 / 21.2 ms, respectively.
#
Starting from an example
deciax takes an input and a set of questions, then returns structured results. Here is a duplicate-charge ticket:
import deciax
decider = deciax.load("laya")
result = decider.decide(
{"user": "I was charged twice this month. Please refund the duplicate."},
{
"department": {
"type": "choice",
"instructions": "Which department should handle this?",
"criteria": {
"billing": "payments, invoices, refunds",
"technical": "bugs, outages, system errors",
"other": "everything else",
},
},
"urgency": {
"type": "score",
"instructions": "How urgent is this?",
"criteria": ["not urgent", "soon", "blocking"],
},
"refund_requested": {
"type": "noul",
"instructions": "Does the user ask for a refund?",
},
},
)
print(result)
#
We first implement Laya by JAX
We first reimplement Laya’s inference computation in JAX: the ModernBERT encoder processes the input, and the decision heads produce results for each question. We keep Laya’s input construction and reuse its checkpoints and tokenizer. This gives us a plain JAX implementation that runs on TPU, providing the baseline for the measurements below and the later Pallas optimizations.
##
How well does the JAX implementation perform?
Measurements ran on Oct 12, 2026, across RTX 3090, A100 SXM4, RTX A6000, H100 PCIe, and H200 NVL hosts, plus single-chip TPU v5e and v6e runs.
Latency figures show warmed in-process p50 per call2, including input encoding, inference, and result handling. Solid bars show p50; dashed markers show p95.
First, compare PyTorch eager on GPU with ordinary JAX on TPU:

For English single-question calls, GPU eager p50 ranged from 13.3 to 25.8 ms, while v6e JAX took 2.27 ms. At 50 questions, v6e JAX took 76.79 ms, compared with the lowest GPU eager result of 57.5 ms on H200 NVL. Multilingual followed a similar pattern: v6e JAX grew from 1.61 ms to 41.24 ms, while H200 eager took 34.0 ms at 50 questions.
##
Time breakdown
Next, break down baseline calls using the English model3:

Single-question GPU eager calls issue many small kernels: the English model used 1,090–1,213 cudaLaunchKernel calls per inference. The large remainder outside device execution points toward both kernel fusion and reducing dispatch overhead.
At 50 questions, computation accounts for most of the call. English v6e JAX took 76.79 ms end to end, with separately measured forward-only time of 71.27 ms and encoding near 3 ms. In XProf, dot_general and sub accounted for about 38% and 21% of this device time, directing attention to matrix computation and data movement in elementwise operations.
#
What if we make it faster?
We optimize Laya on TPU with Pallas kernel fusion. For sequences up to 512 tokens, each encoder and Transformer head layer runs as a single kernel, combining normalization, projections, attention, and the MLP, with RoPE in the encoder4. Intermediate results stay in on-chip VMEM instead of being repeatedly written to and read from HBM, and each kernel reuses its resident weights across row blocks. We also use a transposed attention formulation to better fit the TPU’s matrix unit. PR #1 describes these optimizations and the three-kernel path used for longer sequences.
To make the comparison as fair as possible, we also test optimized GPU versions of Laya using TileLang, CUDA Graph, and torch.compile. For each host, model, and question count, we select the fastest measured implementation and compare it with Pallas on TPU v6e.

Single-question v6e Pallas p50 was 2.18 ms for English and 1.55 ms for multilingual. The lowest English GPU result was 4.8 ms on H100 PCIe using torch.compile with cudagraph; the lowest multilingual result was 3.2 ms. Pallas makes little difference relative to plain JAX at this shape.

At 50 questions, English v6e latency fell from 76.79 ms with JAX to 33.69 ms with Pallas; multilingual fell from 41.24 ms to 17.83 ms. These are speedups of 2.28× and 2.31×. English forward-only time fell from 71.27 ms to 28.25 ms, and multilingual from 36.54 ms to 13.36 ms.
#
Performance across batch sizes
Batch size matters because it changes how much parallel work the hardware has available. Small batches may leave compute units underutilized, while dispatch overhead accounts for a larger share of each call. Larger batches can improve utilization, reuse weights across more inputs, and spread fixed overhead over more decisions. However, they also require more computation and memory, so higher throughput can come with longer per-call latency. An implementation that performs well at a small batch size may therefore behave differently at a larger one.
In Laya, each question becomes a separate input row, so we vary the logical batch size by sending 1, 5, 10, or 50 questions per call for the same input. The TPU implementation pads these rows to supported batch buckets; the question count is the number of useful rows, not necessarily the executed tensor’s batch dimension. The figure below compares per-call latency on H100, H200, and v6e Pallas across these batch sizes, showing how the cost of processing more decisions scales:

#
Serving the model
##
HTTP serving
To call Laya from another application, we expose the same decision interface through deciax.serve: send the input and questions to POST /v1/systemone, and receive structured answers as JSON. The server loads the model at startup and reuses it across requests.
With deciax installed on a TPU host, start an HTTP server on port 8000 using the Pallas implementation:
python -m deciax.serve --model laya --impl pallas --port 8000
Once startup and warmup finish, send a request from another terminal:
curl http://127.0.0.1:8000/v1/systemone \
-H 'Content-Type: application/json' \
-d '{
"state": "I was charged twice. Please refund the duplicate charge.",
"questions": {
"refund": {
"type": "noul",
"instructions": "Does the user ask for a refund?"
}
}
}'
The response contains answers.refund.noul, the probability that the answer is true, alongside confidence, action probability, and token usage. The service also exposes GET /health and POST /v1/systemone/batch.
For single-question calls over loopback with keep-alive, we measured HTTP p50 of 3.0 ms for English and 2.4 ms for multilingual on v6e Pallas.
##
Cost: Million model input tokens per US dollar
Cost compares only optimized English-model implementations: the fastest measured GPU variant and v6e Pallas on TPU. We calculate both on-demand and preemptible / spot scenarios.
Performance and price data were collected on Oct 12, 2026.
Prices are USD per GPU-hour or TPU chip-hour.
| Hardware | Provider | On-demand | Preemptible / Spot5 |
|---|---|---|---|
| A100 SXM4 80GB | Vast.ai | $1.176 | $0.727 |
| H100 (SXM pricing) | Nebius | $4.500 | $0.790 |
| H200 (SXM pricing) | Nebius | $5.400 | $0.790 |
| TPU v6e | Google Cloud | $2.700 | $0.970 |
The calculation is6:
Million model input tokens per US dollar
= model input tokens per second × 3600 / hourly price / 1,000,000
Model input tokens include the ticket text repeated for each question.

#
Conclusion
deciax brings Laya’s structured decisions to TPU. In this experiment, plain JAX already handled single-question calls in about 2 ms, with little additional benefit from Pallas at that shape. At 50 questions per call, the fused Pallas path was roughly 2.3× faster than plain JAX. The question count changes both the dominant overhead and the benefit of optimization.
For the inputs, models, and implementations tested here, v6e Pallas had lower latency than the compared GPU implementations at both one and 50 questions.
You can try deciax in Colab or explore the code in the GitHub repository.
#
Acknowledgments
Thank you to the 2026 TPU Builders Program and TPU Research Cloud (TRC) for providing the TPU resources used in this work.
Performance data in this post comes from development commit 6f3a930. ↩︎
Inputs use upstream’s Payout failing ticket with alternating
noulandchoicequestions. Each series uses 20 warmups followed by 20 timed calls with device synchronization. ↩︎GPU p50 in the breakdown comes from the profiling companion timing series, separate from the preceding baseline figure. ↩︎
The Pallas path in this report fuses normalization, QKV projection, RoPE, attention, output projection, and the MLP. For the path with sequence length at most 512, each layer uses one
pallas_call. ↩︎Nebius Spot uses the starting price; TPU preemptible uses the report snapshot. ↩︎
English calls contain 194 model input tokens at one question and 9,975 at 50 questions. We use the report’s recorded input tokens/s, derived from token counts divided by the original p50 latency. ↩︎