From a loss function to a GPU training step
A classifier with three weights is small enough to check by hand. It also makes a good test of whether the loss, backward pass and optimizer agree across processors.
Start with a prediction of one half
Set four logits to zero and give them targets of zero, one, zero and one. Each predicted probability is one half. All four binary cross-entropy losses should equal the natural logarithm of two, about 0.693147. The gradients have alternating signs. They should be 0.5, −0.5, 0.5 and −0.5. A wrong sign sends the optimizer in the wrong direction even when the reported loss looks plausible.
The Flightdeck exporter is written in Blyx. It emits a StableHLO graph for the two dimensions you select. IREE compiles that graph for CPU or Vulkan. Install the exporter and IREE 3.14.0, then run these commands in a UTF-8 shell.
flightdeck logistic-loss 1 4 > loss.mlir iree-compile loss.mlir --iree-hal-target-backends=vulkan-spirv -o loss.vmfb iree-run-module --device=vulkan --module=loss.vmfb --function=main --input="1x4xf32=0 0 0 0" --input="1x4xf32=0 1 0 1"
Make the axis explicit
A row can represent a token’s hidden features, a classifier’s output scores or a filter’s gradients. Layer normalization needs the statistics from that row. Mixing two rows changes the result. Flightdeck preserves the batch axis and reduces across width. A row statistic is repeated across the width in the output, which makes it easy to combine with the next element-wise operation. That convenience also costs memory if you retain the expanded tensor.
Attention has another boundary case. With every key in a row masked out, the denominator of a direct softmax is zero. The masked-attention workflow gives an all-zero probability row and an all-zero input gradient for that case. Its input consists of scores, a binary mask and an upstream derivative. Forming the scores from queries and keys is a separate operation. Compare the mask and shape conventions when integrating another runtime. PyTorch attention reference.
What ran on the hardware
Each of the 50 workflows ran with two deterministic input sets at three shapes. Width seven exercises an irregular row. Width 64 exercises a wider reduction. A 1 × 1 input checks single-element behavior. We compared FP32 outputs on CPU and Intel UHD Graphics through Vulkan against the same formulas evaluated in NumPy float64.
| Check | Observed result |
|---|---|
| Backend executions | 600 workflow invocations |
| Output arrays checked | 1,416 |
| Scalar values checked | 97,704 |
| Acceptance tolerance | 4 × 10⁻⁵ absolute and relative |
The numerical tests exercise the compiler lowering and device execution. They also cover edge inputs such as an entirely masked row, all-zero quantization inputs and logits of opposite sign at magnitude 75. CPU and GPU timing depends on shape, memory traffic and hardware. This experiment measured agreement. A performance study would need representative batch sizes and timing that separates compilation, transfers and steady-state execution. NVIDIA matrix multiplication guide.
Join the pieces and train
For an end-to-end check, we generated 32 two-feature observations and added a constant bias feature. A fixed linear rule assigned the labels. We began with three zero weights, formed a batch of logits, applied the logistic-loss workflow, multiplied its errors by the transposed feature matrix and divided by 32. A momentum-step workflow then updated the weights and velocity. The learning rate was 0.08 and momentum was 0.9.

After 80 updates, both backends reported mean loss of 0.131449 and correctly classified 230 of 256 separately generated observations. The example measures a small synthetic task on one integrated GPU. It gives developers a reproducible path from graph export through an optimizer update. CUDA, TPU, multi-device training and large language model throughput remain outside these measurements.
Choose a workflow for your project
For a transformer backward pass, start with SwiGLU or RMS normalization. To compare compression schemes, inspect the codes, scales and reconstructions from the quantization workflows. Those simulations retain FP32 storage, so an actual memory-saving deployment needs a packed integer representation. KV caching is another distinct inference concern that involves retaining keys and values between generation steps. Hugging Face cache strategies.
All 172 previously cataloged package examples also ran with Blyx CLI 0.2.2 and matched their published output. That check covers one documented example per framework or library. The dataset, inputs, ordered output contracts and reproduction scripts are available alongside the source.