Journal

Engineering

Read once, ask independently: faster inference in Vej

Faster document extraction is live on CUDA and ROCm. Here is what changed, how we measured it, and what the quality checks found.

Read once, ask independently. One document prefix branches into four separate field assessments.

An invoice contains a supplier name, an invoice number, a date and a total. Extracting those four fields sounds like one task. Inside a model, it can become four separate passes over the same document.

Add line items, payment terms and delivery details, and the repeated work grows. The model processes much of the same text again for each question.

This repeated work was our largest chance to speed up inference: the work a model does to answer a request. The CUDA changes are now live. Through the public API, a sixteen-field extraction fell from 1,885 to 228 milliseconds. A longer example with mixed field types fell from 3,247 to 304 ms, about 10.7× faster. These are median times on test inputs we wrote, measured before and after the release.

The gain depends on the request. A short, single-field example moved only from 129 to 125 ms. Long documents with many fields had more repeated work to remove.

First, what Vej does

Vej uses two related models for structured questions about text. Pea handles decisions: your application supplies the possible outcomes and receives a probability for each. Pod handles extraction, using named fields such as an invoice number or a total. They share a base model.

Pod, served as pea-pod-1, finds evidence in the original document. It estimates whether a field is present and points to the relevant text. Ordinary code then converts that text to the requested type. Pod can select the wrong evidence or miss a field, so its answers still need to be checked for each task.

For example, a request might look like this:

Document
  Invoice INV-2291
  Date: 22 October 2026
  Currency: EUR
  Total due: €1,080.00

Fields to extract
  invoice_number · date · currency · total

This example shows the input format. It is not a measured model result. Each field asks a different question about the same document.

Vej uses prediction heads: small components that produce scores and evidence positions directly. It does not write an answer one token at a time. We focused on processing the input, running the model and reading the results.

Process the document once, keep the questions separate

The original extraction path paired the full document with each field’s instructions. This kept the fields separate, but processed the document again for each one.

The new path processes the shared document text, or prefix, once. It saves the model’s state for that request. Each field starts from its own copy of that state and follows its own instructions.

Each field needs a separate copy. Checking the invoice date must not change the starting state used to check the total. The saved document state is used only within that request.

Animate the document-to-field path (motion disabled) One document prefix, independent field assessments The document is encoded once. Four branches each receive a separate copy of the saved document state before evaluating a field. All retained state ends with the request. Documentencode once Field 1 · own state Field 2 · own state Field 3 · own state Field 4 · own state

This shows how data moves, not how long it takes. The branches keep fields separate; they do not show fields running at the same time. Close this panel to stop the animation.

Saving and copying state also takes time. For a short document, it can cost more than the work it saves. A rule based on document length and field count decides when to reuse the document state.

Tests that got slower helped us set that rule. Forcing reuse on a short, four-field ROCm example made it slower: 65 to 98 ms. The automatic rule skipped reuse for that case. The rule is an estimate and can miss useful cases: one short CUDA example with sixteen fields would benefit from reuse but falls below the current threshold.

What changed in the measurements

We tested two GPU software stacks: CUDA, used with NVIDIA GPUs, and ROCm, used with AMD GPUs. We compared each version with its own baseline on the same stack. The figures do not rank CUDA against ROCm.

The final CUDA test measures the live system through the public API, from sending the request to reading the full response. We ran the same eleven test cases before and after release. We cycled through the cases eight times in each period and kept the same secure connection open. The longest examples improved most: the 512-word, sixteen-field request fell from 1,885 to 228 ms; the 1,000-word, twelve-field request fell from 3,247 to 304 ms.

CUDA public-API deployment comparison: four fields on 32 words fell from 135 to 126 ms; six mixed fields on 128 words from 271 to 158 ms; eight mixed fields on 512 words from 1142 to 199 ms; sixteen fields on 512 words from 1885 to 228 ms; twelve mixed fields on 1000 words from 3247 to 304 ms.
CUDA combined-release comparison through the public API. Eight repetitions per shape in each before/after window; rounded medians. A persistent TLS connection was reused. Five of eleven shapes are shown; the full table is in the technical notes. These probes do not estimate capacity or population-wide tail latency.

The release combines document reuse with changes to number precision, GPU operations, batching and setup. These gains belong to the whole release. Earlier tests measured document reuse on its own inside the prediction process. Those results and the wider 1,497-document check are retained in the technical notes. The API test timed responses but did not save field values. We checked output quality separately, as described below.

With the ROCm release, a twenty-field, 1,200-word example fell from 2.94 seconds to 317 milliseconds, about 9.3×. This release combined document reuse with a ROCm/PyTorch runtime update. The gain belongs to both changes together. Each value is the median of five calls after warm-up.

Recorded ROCm API comparison: seven fields on 320 words fell from 294.9 to 141.6 ms; thirteen fields on 800 words from 1279.4 to 226.7 ms; twenty fields on 1200 words from 2941.1 to 317.0 ms.
Recorded ROCm deployment comparison, including API overhead. Five warmed calls per version and shape. The update combined runtime changes and document reuse; these small samples do not estimate typical user response times or service-wide tail latency.

The seven-, thirteen- and twenty-field release examples returned the same extracted answers. Their probabilities changed. The larger validation checks also found changed values. We checked speed and output quality separately.

Smaller changes needed their own experiments

Removing repeated document work had the largest effect on long extraction requests. Short requests exposed other costs.

Choose the right GPU operations. A kernel is a small program that runs on the GPU. We tested kernels designed for specific operations in place of more general code. One reduced time for the long CUDA examples by roughly 7–10%. Short examples saw almost no gain. We checked that the intended kernel ran.

Match batching to input length. A batch processes several rows together. Increasing Pea’s candidate batch from four to eight helped a short eight-option decision: 89 became 74 ms. On a longer input, the same change made it slower: 778 became 879 ms. The release uses the larger batch only for short rows.

Check changes to number precision. Pea’s adapters are small sets of learned adjustments attached to the shared base model. The extraction adapters used 32-bit arithmetic. The base model used BF16, a 16-bit number format called bfloat16. BF16 adapters took less time but changed outputs. We had to check them against labelled answers. Using the same model weights alone would not prove that the results matched.

Remove repeated setup. Setting the model’s mode and converting the same decision rows to tokens twice cost a few milliseconds per request. Removing this repeated work reduced a short CUDA decision example from 36.8 to 32.7 ms. This helps small requests, but cannot explain a tenfold gain on a long extraction.

We also tested graph replay. The CPU normally sends many separate operations to the GPU. A saved graph lets it send a prepared sequence again with less setup work. This helps only when the request’s execution shape matches the saved graph. The CUDA release leaves graph replay off until we know which shapes it covers. The diagram below explains the mechanism; its animation is not a timing measurement.

Animate eager launches and graph replay (motion disabled) Graph replay reduces repeated CPU launch work The eager example launches three GPU operations individually. The graph example submits a previously captured sequence with one replay. The same GPU operations remain. Eager execution · separate CPU launches launchlaunchlaunch GPU operation A GPU operation B GPU operation C Graph execution · one replay submission CPU · replay GPU · operation A → B → C

This shows how the CPU sends work. The animation does not show measured times. The GPU still performs the same operations. Close this panel to stop the animation.

These changes reduce different costs. Multiplying their separate speedups does not predict the final result.

Faster results still need to be useful

Changing the order of work, the GPU code or the number format can change probabilities or which text is selected as evidence. The overall accuracy score can stay the same while individual answers change.

Before release, we checked the combined CUDA version on 1,016 decisions and 9,682 extraction fields, using the existing calibration check data. Accuracy for deciding whether a field was present stayed at about 95.77%. Among fields known to be present, exact value match moved from 69.22% to 69.14%. Across all 9,682 fields, 140 returned values changed, about 1.45%. Four presence probabilities crossed the default decision threshold. These measures use different totals. A changed value does not always mean a new error.

We also checked the probabilities. Calibration asks whether predicted probabilities agree with how often outcomes occur in the test data. A separate loss measure checks the probability assigned to the labelled answers. Its changes were small, and the uncertainty intervals included zero. This does not prove that the versions are equivalent or that accuracy improved. We kept the existing calibration for the tested mix of data. Confidence in the selected evidence remains a separate score that has not been calibrated.

The detailed metrics, definitions and uncertainty calculation are in the optional notes below. Those notes also explain how repeated use of validation data limits the conclusions.

The first request is a different problem

Some GPU programs are compiled and tuned the first time they see a particular execution shape. A new process can therefore take longer than one that has handled similar requests.

In the ROCm study, a first short Pea request took 43.7 seconds; its repeat took about 70 ms. Running synthetic requests before the service reported ready moved much of that cost into startup. After a 72-second warm-up, the first short request took about 637 ms, followed by about 70 ms on its repeat. Startup became longer, and some first-request overhead remained.

The CUDA release now warms up extraction before reporting ready too. In one sequence from a new process per version, the slowest first-use test fell from 8,789 to 756 ms. This was the 512-word, sixteen-field request. Earlier cases in the sequence had already run, so this does not measure repeated, independent restarts. Both warm-up and faster model execution helped. Startup took longer: Pea warm-up took 47 seconds with no saved compiled code, followed by 63 extraction warm-up calls in 10.6 seconds. Some first-use delay remained.

Network setup also affects response time. In a corrected client test, short extraction took about 210 ms with a new HTTPS connection and 119 ms when reusing the connection. This difference came from connection handling, not a model change. We keep these observations separate from the CUDA model measurements.

What this means for applications

Document reuse helped most on long inputs with many fields. Short inputs benefited from setup, batching and kernel changes. Warm-up reduced first-use delays. The gain depends on the work in each request.

Short requests can also wait behind long ones. Pea decisions and extractions share access to the model. In the public-API test, we sent a short decision while a sixteen-field extraction ran repeatedly on another connection. The short decision’s median time fell from 1,624 to 121 ms. Tested alone in a separate ten-call run, it took 114 ms before and 110 ms after. We recorded twenty calls per version while extraction was running. Their observed 90th-percentile time fell from 1,805 to 156 ms. This small two-stream test does not measure the service’s overall tail latency or capacity.

The results reported here come from 21–22 October 2026, including the completed CUDA deployment and public-API comparison. Both CUDA and ROCm changes are deployed. Their measurements use different workloads and baselines, so the numbers should be read within each comparison.

We still need tests on representative customer inputs and sustained traffic with mixed request types. The released changes made these test requests much faster. Each application still needs to check how the changed outputs affect its own work.

Measurements and technical notes

The results and chart data below can be read without Vej’s code or weights. The CSV contains chart and table summaries and first-use measurements. It excludes the individual eight-round timings and private validation inputs. You can use it to check the figures and arithmetic. Repeating the experiments requires the original code and evaluation inputs.

Download the aggregate measurements (CSV)

How the experiments were run

How the reuse policy counts work

For F fields, a document prefix of P tokens and field suffixes of lengths Sᵢ, the reference processes about F·P + ΣSᵢ token positions. Reuse reduces this to P + ΣSᵢ, ignoring padding. This counts the work avoided. Model execution, copying and batching mean it cannot directly predict response time. The automatic reuse rule uses document length and field count. It is a heuristic, so it can miss useful cases. When reuse is selected, graph replay is skipped.

We ran the studies on 21–22 October 2026. Each comparison keeps the execution environment fixed, except where we state that it measures a combined release. CUDA and ROCm use different workloads, token budgets and runtime versions. Their response times cannot be used to rank the backends.

The CUDA test inputs repeat word patterns or invoice fragments we wrote. Word counts use spaces to separate words; they are not tokenizer token counts. “Mixed” means different field types. These inputs test specific request shapes, not a sample of customer documents.

CUDA experiments used PyTorch 2.14.0+cu130, Transformers 5.17 and PEFT 0.21. The reference used a BF16 backbone, FP32 Pod adapters and FP32 native heads. ROCm’s isolated reuse experiment used PyTorch 2.14.0+rocm10.1.0, BF16 backbone execution and FP32 adapters/heads, with graphs disabled. The earlier ROCm graph experiment used the previous runtime and reference kernels.

Study Design and sampling Quantity measured
CUDA reuse in isolation Two warm-ups per shape/version; twenty rounds, version order shuffled within each round Elapsed time for native predict, including response readout; excludes HTTP/TLS/gateway
Other isolated CUDA tests GPU kernel: 25 rounds; candidate batch size: 30; CPU cleanup and graphs: 40; adapter precision/reuse: 20 Same native timing boundary, with versions interleaved
CUDA deployed release Eight cycles through the shapes in each separate before/after period API elapsed time over a persistent verified TLS connection
ROCm isolated reuse Five warmed calls per arm and synthetic shape; same runtime Extraction wall time without HTTP or graph replay
ROCm deployed release Five warmed API calls per version/shape; consecutive before/after windows Combined ROCm-stack upgrade and reuse, including API overhead
ROCm setup/graph in isolation Twenty-four trials per version; alternating order; waited for device completion Paired backend comparison, separate from deployment periods

The CUDA benchmark ran in a separate process loaded in the same way as the service. Each isolated test used one process, not independent restarts. Test shapes stayed in a fixed order. Within each shape and round, version order was shuffled with seed 20261022. Serving counters recorded no production inference requests during these tests. The timer includes building and validating the input, running native prediction and reading the results to the host. It excludes choosing the version, loading the model and preparing the service. Ordinary calls did not explicitly wait for the device before and after timing. Reading the predictions brought the required outputs back to the host. Calls measured with a profiler were kept separate. CUDA work can run asynchronously, so time outside recorded GPU kernels cannot all be assigned to Python overhead.

We report each version’s median time. Where available, we also report the median speedup across paired rounds. These are different calculations:

arm-median ratio = median(reference) / median(candidate)
paired speedup   = median(reference_round / candidate_round)

For the earlier controlled CUDA 512-word, sixteen-field case, the paired speedup is 10.23×. Dividing the unrounded version medians gives about 10.30×. Dividing the displayed, whole-millisecond medians gives about 10.28× because of rounding. The saved timing summaries do not include the original pairs. We therefore do not calculate new timing confidence intervals or significance tests. The five-call ROCm medians describe the measured samples.

Completed CUDA deployment

The faster release went live on 22 October 2026. The client opened a verified TLS connection to the API and kept it open. A health request established the connection before timing began. The timer ran from sending a request to reading the full response. It excluded decoding the response JSON and the measurement work between calls. This includes API and network work, but no new TLS handshake for each request. We ran eight rounds before deployment and eight after it. We did not alternate versions within a round. Shapes followed a fixed cycle. We retried rate-limited calls and timed only the successful attempt.

Request Before (ms) After (ms) Speedup
Decision, 32 words, 2 options 135 112 1.20×
Decision, 32 words, 8 options 162 136 1.19×
Decision, 512 words, 8 options 816 711 1.15×
Extraction, 32 words, 1 field 129 125 1.03×
Extraction, 32 words, 4 fields 135 126 1.07×
Extraction, 32 words, 16 fields 207 178 1.16×
Mixed extraction, 128 words, 6 fields 271 158 1.71×
Extraction, 512 words, 4 fields 468 176 2.66×
Mixed extraction, 512 words, 8 fields 1,142 199 5.73×
Extraction, 512 words, 16 fields 1,885 228 8.29×
Mixed extraction, 1,000 words, 12 fields 3,247 304 10.69×

These speedups divide the unrounded version medians, then round the result. This differs from the paired calculation in the earlier controlled reuse study. We independently checked the eight accepted timings per shape and period and recalculated the medians. Process age, network conditions or background work may differ between the before and after periods. This release comparison cannot separate the effect of each change.

The separate first-use test ran through eleven shapes after starting a new process. One extra round and another interference test followed. We did not combine these measurements with the eight-round release comparison. Earlier shapes can warm code used by later ones. These are therefore not eleven independent cold starts. The slowest time in the sequence is not a worst-case guarantee. The earlier controlled empty-cache test reached about 2.4 seconds with a longer warm-up. The deployed 756 ms result uses a different combination of changes and a different timing boundary.

For each version, the interference test measured ten short decisions alone and twenty while a long extraction ran repeatedly on a second connection. To report p90, we sort the times and select index round(0.9 × (n − 1)), counting from zero. For twenty calls, that is index 17. Calls in a sequence can affect each other. This describes interference in the test; it is not a significance test on independent samples or a percentile estimate for the public service.

Earlier controlled CUDA reuse experiment

The isolated sixteen-field case fell from 1,880.8 to 182.6 ms, with a reported paired speedup of 10.23×. On the 1,000-word, twelve-field case, the stored output signature changed; its speedup does not establish exact outputs. Across 1,497 accepted validation documents, processing duration fell from 326.9 to 133.6 seconds (about 2.45×), including harness output. Three of 1,500 requested documents were skipped under the row limits in every arm. These are development checks, not population throughput estimates.

CUDA controlled document-reuse experiment: six fields on 128 words fell from 201 to 71 ms; eight mixed fields on 512 words from 1107 to 152 ms; sixteen fields on 512 words from 1881 to 183 ms; twelve mixed fields on 1000 words from 3287 to 309 ms.
Earlier CUDA prediction-path medians, excluding HTTP. Twenty interleaved repetitions per setting and shape. These isolated reuse results are separate from the completed public-API release comparison.

Same-runtime ROCm check

On the isolated ROCm reuse comparison, the 1,200-word, twenty-field request fell from 3,041.9 to 292.7 ms. Across 300 validation documents, total processing time fell from 67.5 to 37.8 seconds. This comparison holds the runtime fixed and excludes graphs; the main article’s API release comparison combines reuse with a runtime update.

ROCm isolated reuse ablation: 300.7 to 101.0 ms for seven fields, 1307.4 to 177.4 for thirteen fields, and 3041.9 to 292.7 for twenty fields.
Same-runtime ROCm ablation, warmed medians of five calls per arm. Graph replay was disabled. These samples support descriptive comparisons; they do not provide a latency-distribution or capacity estimate.
Quality metrics, uncertainty and additional results

We ask three separate questions. Did the numerical outputs change? Did task scores change on labelled data? Did the probability checks still pass? Exact-response checks answer only the first question, for the cases tested. An unchanged overall score does not prove that individual fields or customer decision thresholds behave the same way.

The ROCm reuse check used 300 validation documents and 1,729 fields. Value exact match was 79.76% with reuse off and with automatic reuse, but three presence statuses, twenty-four values and thirty spans differed. List F1 moved from 0.4504 to 0.4499. This was validation reuse, not an untouched final test.

CUDA checks reused the fixed calibration data splits. Pea had 1,016 decisions across 333 source groups, kept separate from temperature fitting. Pod’s separate check split had 9,682 measured fields across 1,275 groups. Of those fields, 6,183 were labelled as present. This is the total used to calculate exact value match. We independently recounted the groups and present fields from the fixed evaluation input.

Pea kept its previously fitted temperature. Pod kept its fitted presence calibrator. Confidence in the selected span remained uncalibrated. Pod used separate document groups to fit and check calibration. We have used these checks repeatedly during development. They are development evidence, even though the fitting and checking groups remain separate.

The combined CUDA implementation produced these pre-release quality-check results:

Metric Reference Combined candidate
Pea NLL 0.44132 0.44071
Pea top-1 accuracy 81.693% 81.890%
Pea ECE, 15 bins 0.03952 0.03658
Pod presence NLL 0.11834 0.11826
Pod presence Brier score 0.03222 0.03217
Pod presence ECE, 15 bins 0.00806 0.00853
Pod presence accuracy at 0.5 95.765% 95.765%
Pod value exact match, gold-present fields 69.222% 69.141%

NLL is the mean negative natural logarithm of the probability assigned to the labelled answer. Lower is better. Pod presence uses binary NLL. The Brier score is mean squared probability error. ECE groups predictions into fifteen equal-width probability ranges. Pea compares its top confidence with correctness. Pod compares presence probability with the present-or-absent label. These checks do not calibrate whether the selected evidence is correct. Exact value match counts only fields labelled as present. Presence accuracy counts both present and absent fields. These measures answer different questions.

Paired NLL differences for the combined CUDA candidate: Pea −0.00062 with 95% group-bootstrap interval −0.00147 to +0.00015; Pod presence −0.00008 with interval −0.00030 to +0.00014.
Candidate-minus-reference mean NLL differences and reported 95% group-bootstrap intervals. Negative values favour the candidate within each task. Both intervals include zero.

The quality analysis first calculates the NLL difference for each paired observation. It then creates 1,000 bootstrap samples by drawing source groups with replacement, using seed 20261022. It takes the 2.5th and 97.5th percentiles of the resampled means. All observations in a sampled group stay together. Each resampled mean still weights observations equally. This keeps related fields in the same bootstrap unit. The intervals apply to NLL. No uncertainty intervals were reported for ECE or exact value match.

The measured NLL differences favour the candidate, but both intervals cross zero. They do not establish improved NLL, equivalence or formal non-inferiority. The checks supported keeping the existing calibration on the tested mix of data. Pea’s earlier 0.01 NLL/ECE tolerance was a check for that task, not a general acceptance margin for Pod. Pod ECE increased slightly, and exact value match fell by 0.081 percentage points.

Two Pea top answers changed. Across all 9,682 Pod fields, 140 values and 194 spans changed, with four presence-threshold flips. The changed-value fraction is approximately 1.45% of all fields; this differs from the gold-present denominator used for exact-match accuracy. The original Pod presence fit itself also traded improved aggregate probability scores for lower present recall and did not improve every field-type or source slice. Custom null thresholds therefore need their own recheck. Across ROCm process restarts, numerical drift was observed even on the reference path; retaining the autotune cache did not remove it. Same-process graph exactness does not establish cross-restart or cross-backend bit identity.

In the combined pre-release quality checks, total processing time was 237 → 209 seconds for Pea and 327 → 121 seconds for Pod. These give approximately 1.13× and 2.70× by ratios of totals.

Additional dispatch and decoder measurements

The earlier ROCm paired experiment separated setup cleanup from graph replay: 149.902 ms with original eager setup, 142.804 ms with startup-only setup, and 136.306 ms with startup-only setup plus graphs. The graph-only reduction was about 4.55%; the combined reduction was 9.07%. Twenty-four trials per arm alternated order, synchronized device completion and required exact full responses. These measurements preceded the later kernel and runtime updates.

ROCm setup and graph-replay medians: 149.902, 142.804 and 136.306 ms.
Twenty-four trials per arm; same-process comparison. Graph replay alone compares the final two bars. Other request shapes retained eager execution.

A banded span decoder reduced scalar-span decoding from 1.834 to 0.669 ms on six rows of 2,048 tokens, with ten warmed samples per arm. Additional peak allocated memory fell from 40.03 to 3.77 MiB. Complete API measurements did not establish a corresponding latency improvement: sequential p50 was nearly unchanged and mixed-request p50 increased. This is a component result.

More from the journal

Older · Release

Pea extraction is now in hosted Beta

Pea now extracts typed fields from text by pointing directly to evidence spans, live on /v1beta/extract.