damccorm opened a new pull request, #41668:
URL: https://github.com/apache/beam/pull/41668
Note: this PR was auto-generated by tooling. Before moving it out of draft,
the author has done a full review of the PR, specifically evaluating it on the
following criteria:
- The PR is an appropriate fix for the issue (e.g. we're not changing a test
to avoid a bug)
- The PR is a simple fix to the issue (e.g. we're not adding infra when we
could just modify a test)
- The PR is not covering for other problems (e.g. if we're bumping timeouts,
it is not because we're covering for a performance problem)
Full details of the methodology of generation and review can be found here -
https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing
If you have concerns with the PR or with the underlying methodology used to
generate this, please comment below - they will be addressed by the author not
the tooling :)
### Summary
1. Add an `autouse=True` pytest fixture (`cleanup_spawned_children`) in
`sdks/python/apache_beam/ml/conftest.py` that snapshots
`multiprocessing.active_children()` before each ML test and terminates/joins
any newly spawned live child processes on teardown.
2. Update
`MultiProcessSharedSpawnProcessTest.test_unsafe_hard_delete_missing_tag_is_noop`
and `test_unsafe_hard_delete_terminates_server_during_inflight_blocked_call`
in `sdks/python/apache_beam/utils/multi_process_shared_test.py` to compare
`multiprocessing.active_children()` relative to the test's starting PIDs so
unrelated pre-existing child processes cannot break assertions or select the
wrong server process.
### Root Cause
PR #40816 (`027f6191a92`) enabled `spawn_process=True` for
`MultiProcessShared` models in `RunInference` and added `active_children()`
teardown only to `RunInferenceBaseTest.tearDown()`. Other ML test classes that
exercise `share_model_across_processes()` (`TFRunInferenceTest` with
`large_model=True`, `SkLearnRunInferenceTest` with `large_model=True`,
`VLLMInferenceTest`, etc.) never terminated their spawned `MultiProcessShared`
child processes until the `pytest-xdist` worker exited.
This caused two immediate `master` CI failures:
- **OOM kills / silent `EOFError` in `PreCommit Python ML` (3.12 & 3.13)**:
Leaked TensorFlow and SkLearn `MultiProcessShared` child processes accumulated
alongside 6 `pytest-xdist` workers until a freshly spawned child process on
`[gw5]` was silently killed, raising `RuntimeError: EOFError` in
`multiprocessing/managers.py` (`conn.recv()`).
- **Leaked `SpawnProcess` failure in `Python tests` (Windows 3.13)**:
`MultiProcessSharedSpawnProcessTest.test_unsafe_hard_delete_missing_tag_is_noop`
asserted `self.assertEqual(multiprocessing.active_children(), [])` and failed
with **8 leaked `SpawnProcess` children** left alive on `[gw3]` from earlier
`apache_beam/ml/inference/` tests.
### Recent Occurrences
2 occurrences on `master` in the last 24 hours:
- [45525815916](https://github.com/apache/beam/actions/runs/45525815916)
(`2026-11-25`) — `PreCommit Python ML tests with ML deps installed` (3.12
`test_run_inference_impl_simple_examples_multi_process_shared_multi_copy` &
3.13 `test_run_inference_impl_with_keyed_examples_many_mhs_max_models_hint`
silent `EOFError`)
- [45535145094](https://github.com/apache/beam/actions/runs/45535145094)
(`2026-11-25`) — `Python tests` (Windows 3.13
`MultiProcessSharedSpawnProcessTest.test_unsafe_hard_delete_missing_tag_is_noop`
found 8 leaked `SpawnProcess` children)
### Verification
- Verified formatting with `yapf==0.43.0 --style setup.cfg`.
- Ran `pytest -v apache_beam/ml/inference/vllm_inference_test.py
apache_beam/utils/multi_process_shared_test.py -k "VLLMInferenceTest or
MultiProcessSharedSpawnProcessTest"` locally (22/22 passed).
- Verified `multiprocessing.active_children() == []` immediately after
`pytest.main(['apache_beam/ml/inference/vllm_inference_test.py'])` (10/10
passed, 0 leaked children).
- Triggered `beam_PreCommit_Python_ML.yml` on this PR branch.
### Verification
- Triggered `beam_PreCommit_Python_ML.yml` workflow run on branch:
[`45629461128`](https://github.com/apache/beam/actions/runs/45629461128)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]