8000 feat(ess): add Experiment.experiment_type with migration 018 by VLukiantsev · Pull Request #1608 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

feat(ess): add Experiment.experiment_type with migration 018 - #1608

Draft
VLukiantsev wants to merge 3 commits into
mainfrom
feat/hpo-experiment-type-b580925123
Draft

VLukiantsev wants to merge 3 commits into
mainfrom
feat/hpo-experiment-type-b580925123

Conversation

@VLukiantsev
Copy link
Copy Markdown
Collaborator

Summary

Adds Experiment.experiment_type (nested enum Experiment.ExperimentType: EXPERIMENT_TYPE_UNSPECIFIED, STANDARD, STUDY; field 14, IMMUTABLE) with migration 018 on Spanner and PostgreSQL. This is PR 1/2 of a stack for hyperparameter optimization (HPO) study ingestion; STUDY is rejected with Unimplemented until PR 2 adds component-requirement validation.

Motivation & Context

HPO studies need to be distinguishable from regular experiments so that CreateExperiment can enforce their component requirements (hpo + its dependencies) and later accept study configuration. Introducing the type first, behind a reject-all guard, keeps every change reachable without ever accepting a study that skipped the component check.

Design choices:

  • Nested enum mirrors WorkUnit.WorkUnitType, so filters use names on both backends (experiment_type = "STUDY"), like work_unit_type.
  • "Standard" has one meaning: the server stores UNSPECIFIED as STANDARD; experiments created before this field existed read and filter as STANDARD on both backends.
  • Unknown enum numbers are rejected (InvalidArgument) because the field is create-only and cannot be corrected later.

Key Changes

  • api/protos/experiment/experiment.proto: ExperimentType enum + experiment_type = 14 [IMMUTABLE].
  • Spanner migration 018: enum added to the proto bundle; nullable enum-typed column (no DEFAULT, see Assumptions). Reads map NULL → STANDARD; the filter uses IFNULL(e.ExperimentType, STANDARD).
  • PostgreSQL migration 018: BIGINT NOT NULL DEFAULT 1 (STANDARD); query field maps enum names via EnumValues.
  • Schema dumps, column lists and row converters on both backends; value written on insert, returned by Get/List; never written by update paths (MergeExperiments rejects an experiment_type mask).
  • CreateExperiment: normalizes UNSPECIFIED → STANDARD; temporary STUDY → Unimplemented guard before any XID or storage write.
  • internal/validator: rejects unknown ExperimentType values.

Assumptions

  • Spanner column is nullable without DEFAULT — the Spanner emulator re-applies DEFAULT values to columns omitted from partial Update mutations on tables with a generated primary key (observed in the emulator integration test: a title update reset STUDY). Production Spanner does not do this — impact if wrong: none functionally; a later migration could backfill and add NOT NULL.
  • api/testdata/protos_baseline.binpb is not refreshed — adding a field and nested enum is non-breaking, so //api:protos_breaking_test passes unchanged.
  • The STUDY guard is intentionally temporary and is replaced in PR 2 of this stack.

Verification & Testing

  • Commands Executed: ./.githooks/pre-commit (linters + ./tools/run_affected_tests.py, 149/149 affected targets pass with the Spanner emulator and PostgreSQL in Docker); targeted bazel test for Spanner data/experiment/migrations packages, //internal/storage/migrations/... (schema synchronization, up/down consistency, version parity), //internal/storage/postgres/experiment:experiment_test, //cmd/experiment_state_server/server:server_test.
  • Coverage & Test Status: all pass. New tests: round-trip of STANDARD/STUDY on both backends; legacy rows (Spanner NULL, PostgreSQL default) read as STANDARD and match = "STANDARD" / != "STUDY" but not = "STUDY"; experiment_type update mask rejected; title update keeps STUDY (emulator); CreateExperiment(UNSPECIFIED) persists STANDARD; CreateExperiment(STUDY) returns Unimplemented with no XID or storage write; validator rejects unknown values.
  • Live GKE verification will be done once for the whole stack (with PR 2), where the end-to-end study accept/reject path becomes reachable.

Related Issues / Bugs

Bug: 580925123

TAG=agy
CONV=4c70456d-44cd-499c-a69d-9c5e775028d7

Introduce Experiment.ExperimentType {EXPERIMENT_TYPE_UNSPECIFIED, STANDARD,
STUDY} as immutable field 14 so that hyperparameter optimization studies can
be distinguished from regular experiments. "Standard" has a single meaning:
the server stores UNSPECIFIED as STANDARD, and experiments created before the
field existed read and filter as STANDARD.

Storage (dual backend, migration 018):
- Spanner: enum-typed column cloud.xmanager.v1.Experiment.ExperimentType
  (added to the proto bundle), matching WorkUnits.WorkUnitType. The column
  is nullable without a DEFAULT, because the Spanner emulator re-applies
  DEFAULT values to columns omitted from Update mutations on tables with a
  generated primary key, which would reset the type on every update. Legacy
  NULL rows read as STANDARD, and the experiment_type filter uses
  IFNULL(e.ExperimentType, STANDARD) while selecting the raw column.
- PostgreSQL: BIGINT NOT NULL DEFAULT 1 (STANDARD), so legacy rows get
  STANDARD; the query field maps enum names via EnumValues.
- experiment_type = "STUDY" / "STANDARD" / != "STUDY" filters behave the same
  on both backends. The value is written on insert and returned by
  Fetch/List. Update paths never write it, and MergeExperiments rejects an
  experiment_type update mask path, so the field stays immutable.

CreateExperiment normalizes UNSPECIFIED to STANDARD, rejects unknown enum
values with InvalidArgument (the field is create-only), and rejects STUDY
with Unimplemented before any XID or storage write. The STUDY guard is
temporary until CreateExperiment validates the components a study requires.

Bug: 580925123

TAG=agy
CONV=e35676e1-16d8-41b8-a81d-8654c90d18f6
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an ExperimentType field (supporting STANDARD and STUDY types) to the Experiment proto and integrates it across the application, including validation, PostgreSQL, and Spanner storage layers. It handles legacy database rows by defaulting them to STANDARD, ensures the field is immutable, and temporarily rejects the unsupported STUDY type with an unimplemented error. Feedback on the changes suggests improving a Spanner unit test by explicitly setting Valid: false in NullProtoEnum to represent a database NULL value more robustly.

The Spanner client requires a typed nil with Valid: true to represent NULL
for NullProtoEnum; Valid: false is rejected by spanner.NewRow.

Bug: 580925123

TAG=agy
CONV=4c70456d-44cd-499c-a69d-9c5e775028d7
Cloud Spanner rejects inserting cloud.xmanager.v1.Experiment.ExperimentType
into the proto bundle unless its parent message cloud.xmanager.v1.Experiment
is bundled too ("references type ... which is not included in the proto
bundle"). The Spanner emulator does not enforce this, so it surfaced only
when applying migration 018 to a live Cloud Spanner instance. Bundle both,
matching WorkUnit / WorkUnit.WorkUnitType.

Bug: 580925123

TAG=agy
CONV=4c70456d-44cd-499c-a69d-9c5e775028d7

This branch has not been deployed

No deployments
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

0