Skip to content

fix(experiment): 🐛 Respect a Joblib launcher pinned to one job - #175

Merged
SongshGeo merged 3 commits into
devfrom
fix/joblib-n-jobs-1
Aug 19, 2026
Merged

fix(experiment): 🐛 Respect a Joblib launcher pinned to one job#175
SongshGeo merged 3 commits into
devfrom
fix/joblib-n-jobs-1

Conversation

@SongshGeo

Copy link
Copy Markdown
Collaborator

CodeRabbit 在 #173 上报的两条 review,核实后都成立,一并修掉。

1. launcher_is_paralleln_jobs: 1 判断错误(主要)

launcher_is_parallel 只看 _target_:只要不是 Hydra 内置的 BasicLauncher,就认定为并行。但 joblib 插件可以被配置成串行——Parallel(n_jobs=1) 走的是 sequential backend,在调用进程里跑完所有任务,实测:

n_jobs=1  ->  pids {33369}, 父进程也是 33369
n_jobs=2  ->  pids {33372, 33373}

所以 hydra/launcher=joblib hydra.launcher.n_jobs=1 会两层都串行:Hydra 逐个跑 job,batch_run 又以为 Hydra 在并行而跳过自己的并行分支,parallels 被忽略——和 #169 是同一个失效模式,只是配置更窄。

修复:判断时把 n_jobs 也读进来。joblib 是唯一用这个名字的 launcher(submitit 用 tasks_per_node,ray 有自己的一套),所以这一条判断不会误伤别人。行为表:

n_jobs 结果
缺省(无此键) parallel
-1(插件默认值,实测确认) parallel
4 parallel
1 serial
??? / null parallel
无法解析的插值 parallel(不抛异常)

最后一行是我自己引入的边界:OmegaConf.select 碰到解析不了的插值会抛 InterpolationKeyError,而这是通往 batch_run 的一个谓词,在这里抛异常会中断整个实验。谓词应当是全函数,所以兜底为乐观的 parallel——反正代价只是少嵌套一层。

严重程度:CodeRabbit 标的是 🟠 Major,我觉得偏 Minor。要触发得显式覆写 n_jobs=1(插件默认是 -1),后果是并行度丢失而不是结果错误。

2. back-merge job 权限过宽

backmerge-dev 只做 checkout / fetch / gh pr create--head master 用的是远端已有分支,全程不 push。contents: write 降为 contents: read

3. 顺带:uv.lock 版本漂移

uv.lock 里 abses 还记着 0.10.0,是 dev/master 版本漂移的残留,导致每次 uv run 都会把工作区弄脏。同步到 0.11.7

验证

  • 新增两条测试,先红后绿
  • 全量套件 709 passed
  • ruff check / format 干净

合并后 #173 会自动更新。

`launcher_is_parallel` classified any non-builtin launcher as concurrent
from its `_target_` alone. joblib's `Parallel(n_jobs=1)` selects the
sequential backend and runs every job in the calling process, so a run
with `hydra/launcher=joblib hydra.launcher.n_jobs=1` was serial on both
levels: Hydra ran the jobs one at a time and `batch_run` skipped its
parallel branch believing Hydra had it covered. `parallels` was ignored
exactly as in #169, only in a narrower configuration.

The check now reads `n_jobs` as well. joblib is the only launcher that
spells its concurrency knob that way; every other value, the -1 default
and an absent key all leave the launcher classified as parallel. An
`n_jobs` that cannot be resolved keeps that optimistic default rather
than raising out of a predicate and aborting the run.

Reported by CodeRabbit on #173.
The job checks out, fetches, and opens a pull request against a branch
that already exists on the remote; it never pushes. `contents: read` is
enough for the first two and `pull-requests: write` covers the third.

Reported by CodeRabbit on #173.
`uv.lock` still recorded abses 0.10.0, left over from the version drift
between dev and master. Any `uv run` regenerated it and dirtied the
working tree.
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 81e933f2-d048-40ed-ae58-60f069885d51

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SongshGeo
SongshGeo merged commit 601735c into dev Aug 19, 2026
9 of 14 checks passed
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