Fix IterablePackingDataset workers to use spawn - #9876
Conversation
|
Thanks for the contribution! Based on your code, we've attempted a fix for both the template pickling and CUDA initialization issues — could you check whether this works for your use case: https://github.com/modelscope/ms-swift/pull/9979/changes |
|
Thanks — I tested #9979 at For the original Qwen3.5 streaming-packing use case, the fix works: with parent CUDA initialized, Qwen3.5-0.8B multimodal packing using I found one generic regression and two lifecycle gaps, though:
The current tests also do not exercise So #9979 fixes the original Qwen3.5 case, but I would not yet call it a complete replacement for all |
PR type
PR information
Fixes #9649.
IterablePackingDatasetcurrently creates worker queues and processes from the platform default multiprocessing context. On Linux this defaults tofork, so workers can inherit already-initialized CUDA or distributed state and deadlock during training.This change uses a dedicated
spawncontext for the queues and workers. The worker entry point receives only the template, queues, and strict-mode flag, which keeps multiple spawned workers from serializing previously startedProcessobjects. A two-worker regression test checks both the start method and CUDA isolation.Experiment results
fork; Python 3.12 also emitted the multiprocessing deadlock warning.python -m unittest -v tests.general.test_packing(Python 3.10): passed.python -m pytest -q tests/general/test_packing.py(Python 3.12): passed.pre-commit run --all-files: all hooks passed.fork, packed sequence lengths[116, 116]spawn, packed sequence lengths[116, 116]spawnpacking workers, produced[116, 116], and exited successfully.