Hacker News new | ask | show | jobs
Bf16 might be freezing your weight updates (lacuna.tiptreesystems.com)
19 points by martincsweiss 32 days ago
5 comments

From the guidelines: "Please don't use HN primarily for promotion. It's ok to post your own stuff part of the time, but the primary use of the site should be for curiosity."

Every link submitted by the author seems to be self promotion...

I wrote this essay out of curiosity for finetuning, and as part of my Postdoc. I thought folks here who are finetuning models might find it interesting.

And thanks for your feedback, I'll try to post more of what I'm reading, too.

> bf16 can only represent changes to weights if the change is at least ~1/512 of the weight itself, so at small learning rates only the smallest weights can update.

Isn't the standard numeric fix for this to probabilistically update the weight? That is, if the desired change is current_value * 1.0014, it should have a 70% chance of going to the successor, and a 30% chance of staying unchanged. Over a number of steps, this will adjust it appropriately over time.

Yep, Stochastic Rounding [1]. I actually had "round-to-nearest" in the title of the piece originally. Usually people do that if they don't have the space for fp32 master weights, but it doesn't fix the second moment part of the learning process.

[1] What is New in Stochastic Rounding: a Survey on Theory, Hardware, and Applications, https://arxiv.org/pdf/2603.06060v2

If you fine-tune a model with weights stored in bf16 and let torch.optim.AdamW write to them directly, you get interesting behaviour. bf16 can only represent changes to weights if the change is at least ~1/512 of the weight itself, so at small learning rates only the smallest weights can update.

As a result, you have a sparse fine-tuner that trains the small-magnitude weights and freezes the rest, with the cutoff set by your learning rate. This is a thing - I found half a dozen peer-reviewed papers (with thousands of citations) that fine-tune this way, but none of them reference this behaviour.

I dug into one called Quiet-STaR, because (a) it's a cool paper, (b) they released their weights, and (c) their code works! So I diffed their base model and saw that indeed the small-magnitude weights were the only ones updated during their training. Then I reran its recipe with an optimizer that applies every update, and watched it diverge. A higher-precision optimizer needs a 3 to 10 times smaller learning rate to get the same result, and I couldn't achieve a better result.

This started with Barron, Gnanapragasam & Tschannen's "A Fix for Softmax and Cross-Entropy" (Oct 2026). They show that the standard way of computing cross-entropy rounds the correct answer's gradient to exactly zero once the model is confident enough (past a margin of about 5.5 in bf16, which they call the precision cliff), and that this, interacting with Adam, is what produces the "slingshot" loss spikes seen during grokking. Fix the rounding and the spikes go away: something people had studied as training dynamics was rounding.

That made me wonder what else out there is weird like this. This is one, and it runs the other way: their rounding bug adds instability to training; this one hides it.

The code, logs and evaluation results are in mweiss17/quietstar-bf16-adamw, in case you want to check the receipts.

semi-related: https://unsloth.ai/docs/get-started/reinforcement-learning-r...

i personally do finetuning in FP16 because then the LoRA merge at the end has less rounding error.

for most models it's lossless as well (when coming from a BF16 source), it's very quick to scan the weights and make sure they're all in range if you're concerned.

Yea that's pretty related. In this case, I'm looking at full finetunes (although we don't end up actually finetuning the whole model, just the small weights!)
There's a reason we keep around an fp32 copy of the weights?

This issue was recognized a decade ago when we first started training with fp16.

Thanks for the comment - you're right, of course.

I read a bit more into the history of fp32 master copies, like in Mixed Precision Training (Micikevicius et al., ICLR 2018, https://arxiv.org/abs/1710.03740), it says that an fp16 update is lost once the weight is ~2048× larger than it. I've updated the post with a citation to that paper.

bf16's shorter mantissa moves that to ~512×, which is significant.

The point of the post is narrower: a lot of published fine-tuning code doesn't keep a master copy at all. So what does that do? It gives you a magnitude mask where only the smallest weights (those under 512xlr) are updating. Which I thought was an interesting inductive bias that wasn't really noted.

I think the finding that lots of people are ignoring best practices and it's working anyway due to a mechanism those authors didn't intend or realise is cool!

The title and a skim of the beginning didn't give me an idea that's where the article was going and I stopped reading further at first.

That's useful feedback. I added introductory material in response to feedback from a colleague, but I suppose that didn't help "get to the point". I think the audience for my work is experts + experience practitioners, so the accessibility / novelty tradeoff was not a good one.