Skip to content

Honor zero learning rate and weight decay in differentiable training - #672

Draft
Aurantium-47 wants to merge 1 commit into
huggingface:mainfrom
Aurantium-47:fix/honor-zero-optimizer-settings
Draft

Aurantium-47 wants to merge 1 commit into
huggingface:mainfrom
Aurantium-47:fix/honor-zero-optimizer-settings

Conversation

@Aurantium-47

Copy link
Copy Markdown

Summary

SetFitModel._prepare_optimizer uses truthiness to select defaults, so explicit zero values are silently replaced: body_learning_rate=0.0 becomes the head learning rate, and l2_weight=0.0 becomes 0.01. During end-to-end differentiable-head training this can update an encoder that the caller intended to keep fixed and apply weight decay that the caller disabled.

Select defaults only when each argument is None, preserving zero and other explicitly supplied values.

Regression coverage

The new tests use a small, locally initialized encoder and CPU classification head, without downloading model weights. They cover:

  • exact preservation of encoder weights with zero body learning rate, with both zero and nonzero head learning rates;
  • multiclass and multilabel training;
  • training updates against an explicit AdamW reference for zero, positive, and default weight decay;
  • optimizer defaults for None, while preserving explicit zero settings.

Validation

Actual training comparisons and optimizer regression checks were completed before submission. This PR creation task did not rerun those tests.

AI assistance was used for implementation and validation.

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