Skip to content

Conversation

@hvarfner
Copy link

Summary:
Issue:
N8887885

Previously, when using Experiment.clone_with() in Ax to clone a subset of trials, the cloned trials were assigned new auto-incremented indices (e.g., 0, 1, 2...) rather than preserving their original indices from the source experiment. This led to downstream issues in extraction methods (_extract_arm_data / _extract_observation_data) which rely on trial indices being consistent between the experiment and its associated data. As a result, extracted arm and observation data would be incomplete.

Fix:
Modified both Trial.clone_to() and BatchTrial.clone_to() so that when cloning to a different experiment, the original trial index is preserved (index=self.index).
When cloning to the same experiment, a new index is auto-assigned to avoid index collision (maintaining previous behavior for this use case).

Differential Revision:
D89661997

Privacy Context Container: L1307644

@meta-codesync
Copy link

meta-codesync bot commented Dec 26, 2025

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

@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Dec 26, 2025
hvarfner pushed a commit to hvarfner/Ax that referenced this pull request Dec 26, 2025
Summary:

**Issue:**
Explanatory notebook by me & mate: N8907563
In practice: N8887885

Previously, when using Experiment.clone_with() in Ax to clone a subset of trials, the cloned trials were assigned new auto-incremented indices (e.g., 0, 1, 2...) rather than preserving their original indices from the source experiment. This led to downstream issues in extraction methods (_extract_arm_data / _extract_observation_data) which rely on trial indices being consistent between the experiment and its associated data. As a result, extracted arm and observation data would be incomplete.


**Fix:**
Modified both Trial.clone_to() and BatchTrial.clone_to() so that when cloning to a different experiment, the original trial index is preserved (index=self.index).
When cloning to the same experiment, a new index is auto-assigned to avoid index collision (maintaining previous behavior for this use case).

Differential Revision:
D89661997

Privacy Context Container: L1307644
hvarfner pushed a commit to hvarfner/Ax that referenced this pull request Dec 26, 2025
Summary:

**Issue:**
Explanatory notebook by me & mate: N8907563
In practice: N8887885

Previously, when using Experiment.clone_with() in Ax to clone a subset of trials, the cloned trials were assigned new auto-incremented indices (e.g., 0, 1, 2...) rather than preserving their original indices from the source experiment. This led to downstream issues in extraction methods (_extract_arm_data / _extract_observation_data) which rely on trial indices being consistent between the experiment and its associated data. As a result, extracted arm and observation data would be incomplete.


**Fix:**
Modified both Trial.clone_to() and BatchTrial.clone_to() so that when cloning to a different experiment, the original trial index is preserved (index=self.index).
When cloning to the same experiment, a new index is auto-assigned to avoid index collision (maintaining previous behavior for this use case).

Differential Revision:
D89661997

Privacy Context Container: L1307644
Summary:

**Issue:**
Explanatory notebook by me & mate: N8907563
In practice: N8887885

Previously, when using Experiment.clone_with() in Ax to clone a subset of trials, the cloned trials were assigned new auto-incremented indices (e.g., 0, 1, 2...) rather than preserving their original indices from the source experiment. This led to downstream issues in extraction methods (_extract_arm_data / _extract_observation_data) which rely on trial indices being consistent between the experiment and its associated data. As a result, extracted arm and observation data would be incomplete.


**Fix:**
Modified both Trial.clone_to() and BatchTrial.clone_to() so that when cloning to a different experiment, the original trial index is preserved (index=self.index).
When cloning to the same experiment, a new index is auto-assigned to avoid index collision (maintaining previous behavior for this use case).

Differential Revision:
D89661997

Privacy Context Container: L1307644
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.69%. Comparing base (d1d20a4) to head (e5a99a7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4712      +/-   ##
==========================================
- Coverage   96.69%   96.69%   -0.01%     
==========================================
  Files         580      580              
  Lines       60714    60731      +17     
==========================================
+ Hits        58708    58723      +15     
- Misses       2006     2008       +2     

☔ View full report in Codecov by Sentry.
📢 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.

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.

2 participants