Skip to content

Conversation

@mohammedahmed18
Copy link
Contributor

@mohammedahmed18 mohammedahmed18 commented Aug 4, 2025

User description

in experiment mode EXP0 valid_optimizations are not cleared before starting the EXP1 optimization


PR Type

Bug fix


Description

  • Reset valid_optimizations each experiment iteration

  • Prevent stale optimizations carryover across experiments


File Walkthrough

Relevant files
Bug fix
function_optimizer.py
Reset valid_optimizations per experiment iteration             

codeflash/optimization/function_optimizer.py

  • Added reset of valid_optimizations inside loop
  • Clears stale optimizations before determining best candidate
+1/-0     

@github-actions
Copy link

github-actions bot commented Aug 4, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Reset placement

The reset of valid_optimizations happens after a continue, so if candidates is None the stale list isn’t cleared. Consider moving the reset to the top of the loop body to ensure it runs for every experiment.

for _u, (candidates, exp_type) in enumerate(
    zip([optimizations_set.control, optimizations_set.experiment], ["EXP0", "EXP1"])
):
    if candidates is None:
        continue

    self.valid_optimizations = []  # reset for each experiment

@github-actions
Copy link

github-actions bot commented Aug 4, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Clear list in-place

Use an in-place clear operation to reset valid_optimizations to preserve any
existing references and avoid unexpected side-effects from reassigning the list.

codeflash/optimization/function_optimizer.py [1031]

-self.valid_optimizations = []  # reset for each experiment
+self.valid_optimizations.clear()  # reset for each experiment
Suggestion importance[1-10]: 5

__

Why: Using .clear() preserves the list identity and any external references to valid_optimizations, reducing unintended side-effects, although the change is a minor enhancement.

Low

@mohammedahmed18 mohammedahmed18 merged commit b13f218 into main Aug 5, 2025
18 checks passed
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.

2 participants