Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add/remove HPs when creating experiment through HP search #9610

Merged
merged 6 commits into from
Jul 12, 2024

Conversation

gt2345
Copy link
Contributor

@gt2345 gt2345 commented Jul 5, 2024

Ticket

MD-402

Description

Allow user to add or remove hyperparameters when creating experiment through HP search

Test Plan

Navigate to Hyperparameters tab of an experiment, click on the Hyperparameters Search button
When selecting hyperparameters, add and remove hyperparameters
Click on the Run Experiment button to create a experiment
Verify that the new experiment is using the updated hyperparameters

Screen.Recording.2024-07-09.at.1.48.24.PM.mov

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

@gt2345 gt2345 requested a review from a team as a code owner July 5, 2024 16:48
@gt2345 gt2345 requested a review from EmilyBonar July 5, 2024 16:48
@gt2345 gt2345 marked this pull request as draft July 5, 2024 17:11
@cla-bot cla-bot bot added the cla-signed label Jul 5, 2024
Copy link

netlify bot commented Jul 5, 2024

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit c427329
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/66900905251cf60008bb9b21
😎 Deploy Preview https://deploy-preview-9610--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 87.69231% with 8 lines in your changes missing coverage. Please review.

Project coverage is 46.31%. Comparing base (98d574e) to head (c427329).
Report is 29 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (98d574e) and HEAD (c427329). Click for more details.

HEAD has 9 uploads less than BASE
Flag BASE (98d574e) HEAD (c427329)
harness 9 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9610      +/-   ##
==========================================
- Coverage   51.37%   46.31%   -5.06%     
==========================================
  Files        1252      929     -323     
  Lines      152174   123093   -29081     
  Branches     3023     3026       +3     
==========================================
- Hits        78181    57015   -21166     
+ Misses      73835    65920    -7915     
  Partials      158      158              
Flag Coverage Δ
harness ?
web 48.01% <87.69%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...react/src/components/HyperparameterSearchModal.tsx 89.54% <87.69%> (-0.38%) ⬇️

... and 323 files with indirect coverage changes

@gt2345 gt2345 marked this pull request as ready for review July 7, 2024 17:29
Comment on lines 120 to 125
const [currentHPs, setCurrentHPs] =
useState<{ hyperparameter: Hyperparameter; name: string }[]>();
useEffect(() => {
!currentHPs && hyperparameters && setCurrentHPs(hyperparameters);
}, [hyperparameters, currentHPs]);

Copy link
Contributor

Choose a reason for hiding this comment

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

can we use the form state for this instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might be wrong, but I don't think the state for this form is explicitly defined due to complexity

Copy link
Contributor

@EmilyBonar EmilyBonar left a comment

Choose a reason for hiding this comment

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

Deleting a hyperparameter causes ripple effects to non-constant hps later in the list.
https://www.loom.com/share/1c4bc85dfa5c43dcaa9d13a63119d2ad?sid=37875841-aac9-4ba4-8ac6-a8909ce58abb

const hpName = hp[0];
if (!currentHPs?.map((h) => h.name).includes(hpName)) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could simplify to one loop with something like !currentHPs?.some((h) => h.name === hpName)

Comment on lines 120 to 125
const [currentHPs, setCurrentHPs] =
useState<{ hyperparameter: Hyperparameter; name: string }[]>();
useEffect(() => {
!currentHPs && hyperparameters && setCurrentHPs(hyperparameters);
}, [hyperparameters, currentHPs]);

Copy link
Contributor

Choose a reason for hiding this comment

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

sugg: this useEffect is only being used to set the initial state, and since hyperparameters isn't referred to elsewhere, I believe this whole section can be rewritten to something like:

const calculateInitialHyperparameters = useCallback(() => {
    return Object.entries(experiment.hyperparameters).map((hp) => {
      const hpObject = { hyperparameter: hp[1], name: hp[0] };
      if (trialHyperparameters?.[hp[0]]) {
        hpObject.hyperparameter.val = trialHyperparameters[hp[0]];
      }
      return hpObject;
    });
  }, [experiment.hyperparameters, trialHyperparameters]);

const [currentHPs, setCurrentHPs] =
    useState<{ hyperparameter: Hyperparameter; name: string }[]>(calculateInitialHyperparameters);

@gt2345 gt2345 requested a review from EmilyBonar July 8, 2024 22:34
Copy link
Contributor

@EmilyBonar EmilyBonar left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment on lines 419 to 421
prev
? [...prev, { hyperparameter: emptyHP, name: `hp_${prev.length}` }]
: [{ hyperparameter: emptyHP, name: 'hp_0' }],
Copy link
Contributor

@EmilyBonar EmilyBonar Jul 10, 2024

Choose a reason for hiding this comment

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

sugg: you could do [...(prev ?? []), { hyperparameter: emptyHP, name: `hp_${prev?.length ?? 0}` }]

Copy link
Contributor

Choose a reason for hiding this comment

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

But that's personal taste, up to you.

<p>Select hyperparameters and define the search space.</p>
<p>
Select hyperparameters and define the search space. <br />
The experiment code needs to be able to handle hyperparameters for them to take effect.{' '}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: don't need the {' '}

@gt2345 gt2345 merged commit 8379b13 into main Jul 12, 2024
81 of 94 checks passed
@gt2345 gt2345 deleted the gt/402-HP-search-UI branch July 12, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants