Skip to content

fix #161: XQA cubin generation ignores resolved output dir under spawn/forkserver - #177

Open
Hi5808 wants to merge 1 commit into
NVIDIA:mainfrom
Hi5808:fix-xqa-cubin-multiprocessing-scope
Open

fix #161: XQA cubin generation ignores resolved output dir under spawn/forkserver#177
Hi5808 wants to merge 1 commit into
NVIDIA:mainfrom
Hi5808:fix-xqa-cubin-multiprocessing-scope

Conversation

@Hi5808

@Hi5808 Hi5808 commented Aug 15, 2026

Copy link
Copy Markdown

Summary

Fixes the latent bug identified in #161 (separate from the permissions/OS-specific
failure discussed there). gen_cubins.py's worker pool reads the module-scope
cubin_dir / nvcc_bin / clean_cubin globals, which are only rebound to their
CLI-resolved values inside if __name__ == "__main__":. Worker processes never
execute that block when the multiprocessing start method re-imports the module
(spawn/forkserver) instead of forking, so they silently fall back to the
relative module-level default for cubin_dir instead of the resolved
--output_dir.

Under fork (Linux's current default) this is masked because child processes
inherit the parent's post-__main__ state — which is why it hasn't caused
visible failures so far. It will start affecting fork-based setups too once
Python 3.14 switches Linux's default start method to forkserver.

Changes

  • Added init_cubin_gen_worker() and pass it to multiprocessing.Pool via
    initializer=/initargs=, so each worker gets the resolved
    cubin_dir/nvcc_bin/clean_cubin explicitly rather than relying on
    inherited module state.

kernelSrcs/ is excluded from this repo's pre-commit hooks, so no formatting
changes were needed beyond the diff itself.

Test plan

  • python3 -m py_compile kernelSrcs/xqa/gen_cubins.py
  • Maintainer/CI: run XQA cubin generation under a non-fork multiprocessing
    start method (e.g. multiprocessing.set_start_method("spawn")) to confirm
    the fix, since I don't have a repro environment for that start method on
    this hardware (Python 3.12.3 on Jetson Orin NX defaults to fork).

…r spawn/forkserver

gen_cubins.py's worker pool (multiprocessing.Pool.map) reads the
module-scope `cubin_dir`/`nvcc_bin`/`clean_cubin` globals. These are only
rebound to their CLI-resolved values inside `if __name__ == "__main__":`,
which worker processes never execute when the multiprocessing start
method re-imports the module (spawn/forkserver) instead of forking. Under
fork (Linux's current default) this is masked because children inherit
the parent's post-__main__ state, but it silently falls back to the
relative module-level default elsewhere, matching the ptxas "could not
be opened" failure reported in NVIDIA#161.

Pass the resolved values into each worker explicitly via
Pool(initializer=...) so behavior no longer depends on the start method.

Signed-off-by: Kino <hanauma5@gmail.com>
@Hi5808
Hi5808 requested a review from a team August 15, 2026 03:06
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