This is not a post with a lesson in it. It is the record of a week in which I went looking for one kind of numerical error and found a bigger one sitting underneath it, in a place I had stopped looking at years ago. The place is fp32, and the thing I had stopped looking at was the assumption that bf16 is free.
Where it started
It started with gpu-unlock. The repo is a Linux kernel module that lifts a cap NVIDIA puts on GeForce tensor cores: fp16, bf16 and tf32 matmuls with fp32 accumulation run at half the rate the silicon can do, on RTX 30xx and, experimentally, 40xx. The module flips the rate selector before the driver binds, and the README reports dense bf16 going from 75 to 125 TFLOPS on a 3090. The table I kept coming back to was the one at the bottom, where it lists what the unlock does nothing for: INT8, FP8 and INT4 models. No change. Those were never capped.
My card is a 5070 Ti, which the module does not support, so I could not use it. But the shape of the cap was the interesting part. The throttle is on fp32 accumulation. int8 accumulates into int32, and int32 is not throttled. So on a GeForce card the gap between bf16 and int8 is not the 2x the datasheet implies, it is wider, and I had never measured it. A microbench on the real block shapes of Anima's DiT, 4096 tokens, pre-quantized operands, nothing but the GEMM:
fp8 lands at 1.9x because it accumulates in fp32 and eats the same cap. int8 is 3.3x raw, 2.6x with the rotation and per-token quantization fused in. That was enough to open a project.
Accurate at the module, not end to end
LoRA training freezes the base model, so each of its large linears needs exactly two GEMMs per step: the forward and the input gradient dX. The weight gradient, the part that makes int8 training hard, is never computed. Both GEMMs can run as int8 through a kernel that already ships in comfy_kitchen, which fuses a Hadamard rotation (ConvRot), per-token quantization and a CUTLASS int8 GEMM. The rotation spreads the outlier channels so that per-token scales do not blow up on them. I converted the 252 block linears of MOSS-Image and the equivalent set in Anima, left attention, norms, modulation and the LoRA's own rank GEMMs in float, and asked how much error that added.
Measured at the module, the answer was: almost nothing. Each converted linear was scored at its own input and output against the bf16 linear it replaced, which is what the unit tests check and what the GPTQ calibration later reported per linear, and the relative output error energy sat around 1e-4. A kernel that close to bf16 at each of 252 sites should have been invisible at the end of the model.
It was not. The gate I set was relative: the int8 LoRA gradient's distance from the fp32 gradient had to stay within 2x of bf16's own distance, median over modules, at every σ. The first version of the gate had been absolute, int8 within a tenth of minibatch noise from bf16, and it was dropped the moment I measured bf16 itself: bf16 sits at 0.15 to 0.20 of minibatch noise from fp32 on Anima. That number should have been the story already, and I filed it as a footnote.
On Anima int8 came in at 1.3 to 1.5x bf16's distance. The error is all in the forward; the int8 dX GEMM adds nothing measurable, which makes sense since the backward only needs the weight and the rotation is applied to dY, where the outliers live. But a bf16-sized extra error from linears that had each measured almost nothing against bf16 did not add up for me. In every comparison I ran, the end-to-end number kept coming out larger than the per-linear numbers implied, and for a while the question was whether int8 itself, the rotation or the per-token scales, had a problem I was not seeing. Nothing in practice said so: the step ran 1.37x faster on a 848-step LoRA, loss curves overlapped, samples on the bf16 base matched. A GPTQ-calibrated weight file later took a third of int8's excess error off again. The int8 base is now the default training plan for MOSS at 1.1 s/step against bf16's 1.6. I shipped it and kept the suspicion.
Then I ported the gradient gate to MOSS, and the ratio came out at 0.53x at σ = 0.1, 1.17x at 0.5, 0.98x at 0.9. Below one. The int8 model was closer to the fp32 gradient than the bf16 model was, at the σ where diffusion models do most of their fine work.
The reference that moved
The ratio was lower on MOSS not because int8 added less error, since the prediction error grew 1.24 to 1.46x, exactly as on Anima. It was lower because the denominator was large. MOSS's bf16 gradient was already far from fp32 in blocks 0 to 27: 0.7 to 2.5 of minibatch noise, where Anima's blocks were mostly under 0.7. The same measurement at the prediction, ‖v − v_fp32‖ / ‖v_fp32‖ against a true fp32 forward with TF32 off, read 4.81% at σ = 0.1 for plain bf16 MOSS. For comparison, the whole int8 conversion added about 2% at σ = 0.5.
Up to this point every comparison I had made was int8 against bf16, because bf16 was the model as shipped and as everyone ran it. Nobody in the pipeline, upstream inference, the ComfyUI loaders, my own trainer, ran it any other way. The fp32 forward existed in my scripts only as a reference to measure int8 against. It took the int8 ratio dropping below one for me to turn the reference on bf16 itself.
MOSS runs bf16 end to end with no autocast. The weights are bf16, so the residual stream x, the modulation, the gates and the norm outputs are all bf16, and each block does x = x + gate · proj(...) twice, over 42 blocks. Every one of those adds rounds the stream to an 8-bit mantissa. I had read that line of code dozens of times. The GEMMs were the thing I was measuring, so the GEMMs were the thing I thought about.
A parameter cast
The arm is small. Cast every parameter except the 252 block linears' weights to fp32. The stream, modulation, gates, norms, embedders and head then run in fp32. The block GEMMs stay bf16 (or int8), and so do FlashAttention and the LoRA, which computes in its base output's dtype. The block forward already casts to the linear's dtype on the way in, and the bf16 output promotes back to fp32 at the add, so nothing else changes. It is about 0.6 GB of parameters and the extra work is elementwise.
Prediction error against the fp32 forward on held-out MOSS images, in %:
The fp32 stream cuts bf16's prediction error 2.4 to 3.5x, and the training loss matches the fp32 loss to the fourth decimal. Put the int8 GEMMs back inside that fp32 stream and the result is below today's bf16 at every σ. The model everyone runs, bf16 everywhere, is the least accurate column of the four when the int8 column is given the stream it deserves.
I also tried the other obvious suspect, cuBLAS's reduced-precision reduction inside the bf16 GEMM. Turning it off does nothing to the prediction, helps the gradient at σ = 0.1 and hurts it at 0.9. The GEMMs were never the main term.
Anima has the same thing at half the size. It trains under bf16 autocast with 28 blocks, and LayerNorm hands some of its linears fp32 computed from an already-rounded stream, so it was never as uniform as MOSS. A narrower arm, casting only x and the adaLN outputs to fp32 at each block:
1.5 to 2.1x around bf16 GEMMs, 21 to 36% around int8, which again lands below bf16 on 18 of 18 image-σ pairs. Why Anima's error is about half of MOSS's I have not traced. The autocast boundary is my guess, and it is only a guess.
The cost on MOSS, one run per arm: generation 21.6 s to 21.9 s per 1024² image, 10.7 to 12.3 GiB; training 1.80 to 1.85 s/step. It is a cast and a flag, and it is now the default in my trainer. In the renders the difference shows up where small errors show up first: hands and lettering come out noticeably more accurate on the fp32 stream, and a LoRA trained on it keeps that.
The myth
Here is what I actually believed, without ever having said it out loud. bf16 has fp32's exponent range, so it does not overflow where fp16 does, so it is safe, so it is a wash. Train in bf16, infer in bf16, store in bf16, cast the whole module with one .to(torch.bfloat16) and get on with the research. Mixed precision in the original sense, fp32 master weights and fp32 wherever the cost was elementwise, had become something you did in 2018 because fp16 was fragile. bf16 fixed the fragility and the habit of asking where the precision actually mattered went out with it.
But an 8-bit mantissa is an 8-bit mantissa. Three significant decimal digits. The residual stream of a 42-block DiT accumulates 84 rounded adds to a value that is then read by a head whose job is to predict a velocity to within a percent. The GEMMs that feed those adds are the expensive thing and the thing with a kernel budget, so they are what gets measured and optimized, and they turn out to have been the smaller error all along. The precision belongs where it is cheap, and where it is cheap is exactly the part nobody profiles.
I would not have found this if I had not been chasing int8. The int8 work needed an fp32 reference, the reference made bf16 a measured quantity rather than a baseline, and once it was a measured quantity it looked bad. So the moral, if there is one, is not "use fp32." It is that the reference I had been treating as the ground was itself a few percent off the ground, and the only reason I knew is that for once I had bothered to stand on the real one. fp32 is the legacy format now. It is still what everything is measured against, and it is worth remembering that the thing you measure against should occasionally be measured.
If you run a residual network in bf16 without autocast, the arm costs nothing to try. Cast everything but the block GEMMs to fp32, score ‖v − v_fp32‖ against a true fp32 forward with TF32 off, and see how much of your error was never in the GEMMs.