fix: replace Manager().list() with plain list to prevent GC crash#266
fix: replace Manager().list() with plain list to prevent GC crash#266saschabuehrle wants to merge 2 commits intopymc-devs:mainfrom
Conversation
|
Please, check locally before pushing. Also, notice that mypy is failing. |
|
Fixed — added the type annotation mypy wanted. pre-commit should pass now. |
|
Did you run the tests locally? |
|
Haven't run the full suite locally yet, setting it up now. The change itself is straightforward though - Manager().list() creates a multiprocessing ListProxy backed by a server process, which gets GC'd after predict() returns. A plain list doesn't have that lifecycle issue. |
|
The tests should fail, you need Manager().list() so different chains can add the trees to the same list. |
|
Can we maybe try fix1 from #265? |
|
Good point, agreed on Manager().list() for cross-chain aggregation. I'll rework this toward the fix1 direction from #265 so we keep shared writes without the GC failure path, then push an updated patch. Greetings, saschabuehrle |
|
Closing for now instead of keeping a broken approach open. I can send a fresh PR with the fix1 direction from #265 once I have it validated. Greetings, saschabuehrle |
Fixes #265
The
Manager()inBART.__new__is a local variable that gets garbage-collected after the method returns. Once its server process dies,all_trees(aListProxy) becomes a dangling reference — any access to it (e.g. duringsample_posterior_predictivewith new data) raisesTypeError: only integer scalar arrays can be converted to a scalar index.Since nothing in the sampling step actually needs cross-process shared state (each chain gets its own copy of the step method), a plain
list()works fine here and avoids the lifetime issue entirely.— saschabuehrle