Skip to content

Use xdist for faster multi-processing-based tests#102

Closed
jbcoe wants to merge 3 commits intoNetHack-LE:mainfrom
jbcoe:jbcoe/pytest-xdist
Closed

Use xdist for faster multi-processing-based tests#102
jbcoe wants to merge 3 commits intoNetHack-LE:mainfrom
jbcoe:jbcoe/pytest-xdist

Conversation

@jbcoe
Copy link

@jbcoe jbcoe commented Mar 8, 2026

Requires #104 to be merged first.

Some issues around benchmarks need investigating (they are currently auto-disabled).

jbcoe added 2 commits March 8, 2026 23:38
This commit resolves a non-determinism issue in `TtyrecDataset` where
the order of loaded games could vary between runs.

The previous implementation used a single data loading function with a shared
lock (`threading.Lock`) for all workers. This created a race condition
where multiple threads competed to fetch the next game, resulting in an
unpredictable data order.

The fix introduces a deterministic assignment of games to each worker:

- A new `_make_load_fns` method creates a separate, dedicated data loading
  function for each batch dimension.
- Each function is assigned a unique, non-overlapping sequence of games
  by striding over the global `gameids` list. This eliminates the need
  for a shared lock and guarantees a deterministic loading order.

The corresponding tests in `test_minibatches` have also been updated to
validate this new, deterministic behavior.
@jbcoe jbcoe force-pushed the jbcoe/pytest-xdist branch from 51d1a4a to 7438848 Compare March 9, 2026 00:09
@jbcoe
Copy link
Author

jbcoe commented Mar 14, 2026

This disables benchmarks which was the slow bit.

@jbcoe jbcoe closed this Mar 14, 2026
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