Skip to content

fix: auto-fix deprecated AdamW import and handle BrokenProcessPool#87

Open
YihanJIANG-lab wants to merge 1 commit intoSakanaAI:mainfrom
YihanJIANG-lab:fix/deprecated-adamw-and-broken-pool
Open

fix: auto-fix deprecated AdamW import and handle BrokenProcessPool#87
YihanJIANG-lab wants to merge 1 commit intoSakanaAI:mainfrom
YihanJIANG-lab:fix/deprecated-adamw-and-broken-pool

Conversation

@YihanJIANG-lab
Copy link
Copy Markdown

LLM-generated experiment code frequently uses from torch.optim import AdamW which triggers deprecation warnings (and errors in future PyTorch versions). This adds:

  • _sanitize_imports() to auto-replace deprecated import patterns before execution
  • Import guidelines in the system prompt to prevent the issue at generation time
  • RuntimeError wrapping for unpicklable exceptions in multiprocessing workers
  • BrokenProcessPoolError recovery with automatic pool restart

Three related fixes for BFTS experiment execution reliability:

1. Add _sanitize_imports() that auto-replaces deprecated
   'from transformers import AdamW' with 'from torch.optim import AdamW'
   in LLM-generated code before execution. Handles both standalone and
   mixed import forms. (transformers >= 4.30 removed AdamW)

2. Wrap exceptions in _process_node_wrapper() as RuntimeError before
   re-raising, because openai.APIStatusError and similar exceptions are
   not picklable, which causes BrokenProcessPool in the parent process.

3. In step(), catch BrokenProcessPool errors gracefully and recreate the
   executor instead of crashing the entire experiment. The journal records
   fewer nodes but the stage completion checks handle retry logic.

4. Add CRITICAL LIBRARY IMPORT GUIDELINES to _prompt_impl_guideline to
   steer LLM code generation away from deprecated imports.

5. Relax code extraction: accept completion even when nl_text is empty
   (return a default string), preventing unnecessary retries when the
   model produces valid code without a natural-language preamble.

Root cause chain: LLM generates 'from transformers import AdamW' ->
ImportError -> no .npy output -> metric=None -> Metric?(nan) -> infinite
retry loop in BFTS stage 12.
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