Skip to content

Finetuner performance + robustness optimizations#11

Open
r-kellerm wants to merge 1 commit into
NVIDIA:mainfrom
r-kellerm:main
Open

Finetuner performance + robustness optimizations#11
r-kellerm wants to merge 1 commit into
NVIDIA:mainfrom
r-kellerm:main

Conversation

@r-kellerm

Copy link
Copy Markdown
  1. AMP for the full fine-tune path - added use_amp/amp_dtype args plus _is_cuda_device/_amp_available/_pick_amp_dtype helpers and a _autocast() context. Mixed precision is gated to amp_active = use_amp and not only_proj_layer, so the cached linear-probe path stays fp32 (avoids the bf16 to numpy cache crash). GradScaler is wired only for fp16; bf16 is preferred when supported and needs no scaling.
  2. zero_grad(set_to_none=True) - replaced plain zero_grad().
  3. Backbone freeze - on the probe path, backbone params are set requires_grad_(False) once and restored in a finally, replacing the per-batch no_grad()+detach().
  4. Robustness - avg_loss initialized to nan (no NameError on empty loader), and fwd_cache.clear() moved into the finally so the cache is released even on exceptions.

…_to_none=True) 3. Backbone freeze when only projection head is trained; + robustness changes - avg_loss initialized to nan and fwd_cache.clear() moved to finally block to run even in case of exceptions,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant