search: change to use "spawn" and limit the number of tasks per child #3862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
also clean up some examples to use main and not initialize resources outside of main
This limits the amount of memory leaked in the child processes. For very large kernels, you might need to limit the tasks per child to even less by setting
BEAM_MAX_TASKS_PER_CHILD
to a lower number.For this run
PYTHONPATH=. HSA=1 GPUS=6 LATEWINO=1 LATEBEAM=64 BEAM_UPCAST_MAX=16384 BEAM_LOCAL_MAX=512 BEAM_MIN_PROGRESS=5 BEAM_MAX_TASKS_PER_CHILD=32 STEPS=10 DEBUG=2 HALF=1 BS=1536 python3 ./examples/hlb_cifar10.py
, the parent process still leaked up to 30GB by the end of a 4.5hr run, but this is not addressed here. The total memory usage peaked at 80GB during one late WINO kernel, so in hindsight, I should've run with lower max tasks.Tested in HSA and CUDA. Trying to do beam inside of the rocm/pytorch docker container didn't seem to work (hangs) but that might be due to other issues.