Skip to content

Preserve log scaling when merging choice parameters - #5307

Closed
ltiao wants to merge 1 commit into
facebook:mainfrom
ltiao:export-D126675426
Closed

ltiao wants to merge 1 commit into
facebook:mainfrom
ltiao:export-D126675426

Conversation

@ltiao

@ltiao ltiao commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary:

Why

Transfer learning combines parameter definitions from the target and auxiliary experiments. Rebuilding a choice parameter can silently replace its logarithmic or linear scale with a default inferred from the combined values. Preserve the existing scale so that adding source data does not change the model's input transform.

Changes

  • Preserve the first choice parameter's log_scale when merging two choice parameters, following the existing attribute precedence rule.
  • Preserve the choice parameter's log_scale when merging it with a fixed parameter, in either argument order.
  • Cover explicit logarithmic and linear scales with values for which automatic inference would choose the opposite scale.

Examples

Input:

choice = ChoiceParameter(
    "x", ParameterType.INT, values=[1, 2],
    is_ordered=True, sort_values=True, log_scale=True,
)
fixed = FixedParameter("x", ParameterType.INT, value=3)
merged = merge_parameters(choice, fixed, reverse_param_config={})

Before

merged.values     # [1, 2, 3]
merged.log_scale  # False: inferred again from the merged values

After

merged.values     # [1, 2, 3]
merged.log_scale  # True: preserved from the choice parameter

Likewise, merging an explicitly linear choice [1, 2] with fixed value 4 now preserves False instead of inferring True from [1, 2, 4].

Differential Revision: D126675426

Summary:
# Why

Transfer learning combines parameter definitions from the target and auxiliary experiments. Rebuilding a choice parameter can silently replace its logarithmic or linear scale with a default inferred from the combined values. Preserve the existing scale so that adding source data does not change the model's input transform.

# Changes

- Preserve the first choice parameter's `log_scale` when merging two choice parameters, following the existing attribute precedence rule.
- Preserve the choice parameter's `log_scale` when merging it with a fixed parameter, in either argument order.
- Cover explicit logarithmic and linear scales with values for which automatic inference would choose the opposite scale.

# Examples

Input:
```python
choice = ChoiceParameter(
    "x", ParameterType.INT, values=[1, 2],
    is_ordered=True, sort_values=True, log_scale=True,
)
fixed = FixedParameter("x", ParameterType.INT, value=3)
merged = merge_parameters(choice, fixed, reverse_param_config={})
```

## Before

```python
merged.values     # [1, 2, 3]
merged.log_scale  # False: inferred again from the merged values
```

## After

```python
merged.values     # [1, 2, 3]
merged.log_scale  # True: preserved from the choice parameter
```

Likewise, merging an explicitly linear choice `[1, 2]` with fixed value `4` now preserves `False` instead of inferring `True` from `[1, 2, 4]`.

Differential Revision: D126675426
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Oct 21, 2026
@meta-codesync

meta-codesync Bot commented Oct 21, 2026

Copy link
Copy Markdown

@ltiao has exported this pull request. If you are a Meta employee, you can view the originating Diff in D126675426.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.60%. Comparing base (80694ce) to head (0df11cc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5307   +/-   ##
=======================================
  Coverage   96.60%   96.60%           
=======================================
  Files         621      621           
  Lines       71085    71095   +10     
=======================================
+ Hits        68674    68684   +10     
  Misses       2411     2411           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@meta-codesync meta-codesync Bot closed this in add8500 Oct 21, 2026
@meta-codesync meta-codesync Bot added the Merged label Oct 21, 2026
@meta-codesync

meta-codesync Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request has been merged in add8500.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. Merged meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants