Skip to content

Enable json serialization of ScalarizedOutcomeConstraint (#5025)#5025

Open
metactc wants to merge 1 commit intofacebook:mainfrom
metactc:export-D96486632
Open

Enable json serialization of ScalarizedOutcomeConstraint (#5025)#5025
metactc wants to merge 1 commit intofacebook:mainfrom
metactc:export-D96486632

Conversation

@metactc
Copy link

@metactc metactc commented Mar 13, 2026

Summary:

Adds JSON serialization/deserialization support for ScalarizedOutcomeConstraint in Ax's JSON storage.

= Background

ScalarizedOutcomeConstraint differs from OutcomeConstraint in that it holds a list of metrics and weights instead of a single metric. Accessing .metric on a ScalarizedOutcomeConstraint raises NotImplementedError, so the existing outcome_constraint_to_dict encoder cannot be reused.

= Solution

This diff implements a dedicated encoder (scalarized_outcome_constraint_to_dict) following the same pattern as ScalarizedObjective.

= Motivation

This issue was discovered when serializing an experiment loaded from the Ax DB via object_to_json. The experiment's historical GeneratorRun objects contained ScalarizedOutcomeConstraint instances (set by Bayesian optimization), which caused serialization to fail.

Note: The SQA (database) store already handles this type; the JSON store was the only gap.

Reviewed By: bletham

Differential Revision: D96486632

@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Mar 13, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 13, 2026

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

@meta-codesync meta-codesync bot changed the title Enable json serialization of ScalarizedOutcomeConstraint Enable json serialization of ScalarizedOutcomeConstraint (#5025) Mar 19, 2026
metactc added a commit to metactc/Ax that referenced this pull request Mar 19, 2026
Summary:

Adds JSON serialization/deserialization support for ScalarizedOutcomeConstraint in Ax's JSON storage.

= Background

ScalarizedOutcomeConstraint differs from OutcomeConstraint in that it holds a list of metrics and weights instead of a single metric. Accessing .metric on a ScalarizedOutcomeConstraint raises NotImplementedError, so the existing outcome_constraint_to_dict encoder cannot be reused.

= Solution

This diff implements a dedicated encoder (scalarized_outcome_constraint_to_dict) following the same pattern as ScalarizedObjective.

= Motivation

This issue was discovered when serializing an experiment loaded from the Ax DB via object_to_json. The experiment's historical GeneratorRun objects contained ScalarizedOutcomeConstraint instances (set by Bayesian optimization), which caused serialization to fail.

**Note:** The SQA (database) store already handles this type; the JSON store was the only gap.

Reviewed By: bletham

Differential Revision: D96486632
metactc added a commit to metactc/Ax that referenced this pull request Mar 19, 2026
Summary:
Pull Request resolved: facebook#5025

Adds JSON serialization/deserialization support for ScalarizedOutcomeConstraint in Ax's JSON storage.

= Background

ScalarizedOutcomeConstraint differs from OutcomeConstraint in that it holds a list of metrics and weights instead of a single metric. Accessing .metric on a ScalarizedOutcomeConstraint raises NotImplementedError, so the existing outcome_constraint_to_dict encoder cannot be reused.

= Solution

This diff implements a dedicated encoder (scalarized_outcome_constraint_to_dict) following the same pattern as ScalarizedObjective.

= Motivation

This issue was discovered when serializing an experiment loaded from the Ax DB via object_to_json. The experiment's historical GeneratorRun objects contained ScalarizedOutcomeConstraint instances (set by Bayesian optimization), which caused serialization to fail.

**Note:** The SQA (database) store already handles this type; the JSON store was the only gap.

Reviewed By: bletham

Differential Revision: D96486632
metactc added a commit to metactc/Ax that referenced this pull request Mar 19, 2026
Summary:

Adds JSON serialization/deserialization support for ScalarizedOutcomeConstraint in Ax's JSON storage.

= Background

ScalarizedOutcomeConstraint differs from OutcomeConstraint in that it holds a list of metrics and weights instead of a single metric. Accessing .metric on a ScalarizedOutcomeConstraint raises NotImplementedError, so the existing outcome_constraint_to_dict encoder cannot be reused.

= Solution

This diff implements a dedicated encoder (scalarized_outcome_constraint_to_dict) following the same pattern as ScalarizedObjective.

= Motivation

This issue was discovered when serializing an experiment loaded from the Ax DB via object_to_json. The experiment's historical GeneratorRun objects contained ScalarizedOutcomeConstraint instances (set by Bayesian optimization), which caused serialization to fail.

**Note:** The SQA (database) store already handles this type; the JSON store was the only gap.

Reviewed By: bletham

Differential Revision: D96486632
metactc added a commit to metactc/Ax that referenced this pull request Mar 19, 2026
Summary:
Pull Request resolved: facebook#5025

Adds JSON serialization/deserialization support for ScalarizedOutcomeConstraint in Ax's JSON storage.

= Background

ScalarizedOutcomeConstraint differs from OutcomeConstraint in that it holds a list of metrics and weights instead of a single metric. Accessing .metric on a ScalarizedOutcomeConstraint raises NotImplementedError, so the existing outcome_constraint_to_dict encoder cannot be reused.

= Solution

This diff implements a dedicated encoder (scalarized_outcome_constraint_to_dict) following the same pattern as ScalarizedObjective.

= Motivation

This issue was discovered when serializing an experiment loaded from the Ax DB via object_to_json. The experiment's historical GeneratorRun objects contained ScalarizedOutcomeConstraint instances (set by Bayesian optimization), which caused serialization to fail.

**Note:** The SQA (database) store already handles this type; the JSON store was the only gap.

Reviewed By: bletham

Differential Revision: D96486632
Summary:

Adds JSON serialization/deserialization support for ScalarizedOutcomeConstraint in Ax's JSON storage.

= Background

ScalarizedOutcomeConstraint differs from OutcomeConstraint in that it holds a list of metrics and weights instead of a single metric. Accessing .metric on a ScalarizedOutcomeConstraint raises NotImplementedError, so the existing outcome_constraint_to_dict encoder cannot be reused.

= Solution

This diff implements a dedicated encoder (scalarized_outcome_constraint_to_dict) following the same pattern as ScalarizedObjective.

= Motivation

This issue was discovered when serializing an experiment loaded from the Ax DB via object_to_json. The experiment's historical GeneratorRun objects contained ScalarizedOutcomeConstraint instances (set by Bayesian optimization), which caused serialization to fail.

**Note:** The SQA (database) store already handles this type; the JSON store was the only gap.

Reviewed By: bletham

Differential Revision: D96486632
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant