79750956

Date: 2025-08-30 06:03:09
Score: 0.5
Natty:
Report link

What’s really happening?

That’s why:

How to fix it

Instead of running trials in threads, you need to run them in separate processes (so they don’t share memory/state).

There are two simple ways:

Keep n_jobs=1 in Optuna, but run multiple copies of your script

# terminal 1
python tune.py
# terminal 2
python tune.py

Both processes will write their results into the same Optuna storage (e.g., a SQLite database).
Example in code:

import optuna

def objective(trial):
    # your Hugging Face model code here
    ...

if __name__ == "__main__":
    study = optuna.create_study(
        storage="sqlite:///optuna.db",  # shared DB file
        study_name="gpt2_tuning",
        load_if_exists=True
    )
    study.optimize(objective, n_trials=10, n_jobs=1)  # <- keep n_jobs=1

Now you can run as many parallel processes as you want, and they won’t interfere.

In short

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): What
  • Low reputation (1):
Posted by: Marwan Shamsan