Debiasing omission in Adam
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9k
- Forks
- 1.5k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 3
Description
A new paper: Revisiting Few-sample BERT Fine-tuning claims that bias in standard Adam makes the training process harder. (especially in low-data + fine-tuning)
https://www.youtube.com/watch?v=lWzo8CajF5s
So I wondered if debiasing had been implemented in the toolchains I was using.
-
Huggingface optimizer has an official option for debiasing Adam.

-
Pytorch also implemented debiasing in their Adam implementation.

- Nvidia FusedKernel doesn't implement 'debiasing'.

I also found that Huggingface's implementation was just scaling step_size according to the bias, so the impact of the omission of debiasing might be negligible. (Someone might compensate the learning rate setting.) But Huggingface's simple scaling approach simply ignores the role of epsilon, I think PyTorch's implementation is more desirable.
Sketch code for the debias might be like below:
// these two coef's might be given as extra arguments.
const float bias_correction1 = 1 - pow(b1, step);
const float bias_correction2 = 1 - pow(b2, step);
for (int j = i; j < tsize; j+=totThreads) {
T scaled_grad = g[j]/grad_scale;
m[j] = b1*m[j] + (1-b1)*scaled_grad;
v[j] = b2*v[j] + (1-b2)*scaled_grad*scaled_grad;
float denom;
if (mode == ADAM_MODE_0)
denom = bias_correction1 * sqrtf(v[j]/bias_correction2 + eps);
else // Mode 1
denom = bias_correction1 * sqrtf(v[j]/bias_correction2) + eps;
float update1 = (m[j]/denom) + (decay*p[j]);
p[j] = p[j] - (step_size*update);
if (p_copy != NULL) p_copy[j] = (GRAD_T) p[j];
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apex/contrib/csrc/optimizers/fused_adam_cuda_kernel.cu at the linked line and compare its Adam update with the linked PyTorch implementation. Check how the kernel receives optimizer parameters and represents its two modes; done means the fused optimizer handles the requested bias correction consistently with the chosen semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100