Repository navigation
ci(tests): run four workers per test shard - #5608
Conversation
Signed-off-by: oliver könig <[email protected]>
…orkers Signed-off-by: oliver könig <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
One RISK: cancellation cleanup can leave worker descendants running after their group leader exits. The inline finding describes the failure and required checks.
I completed the review of all 14 changed files and their directly affected paths, including shard selection, coverage aggregation, environment propagation, component discovery, and the changed fixtures. This was a static review; I didn't execute tests.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| deadline = monotonic() + 10 | ||
| for process in active: | ||
| try: | ||
| process.wait(timeout=max(0, deadline - monotonic())) |
There was a problem hiding this comment.
RISK — Check process-group termination independently of worker exit
Could you make cleanup check the process group rather than only its leader? A minimal trigger is a fake ng_test_all that starts a same-group child which ignores SIGTERM, waits for the child's readiness marker, then waits itself. When the launcher receives SIGTERM, stop_workers signals the group. The leader exits, so process.wait() succeeds and the SIGKILL branch never runs. The child survives the launcher. The initial poll() filter also skips surviving groups whose leaders have already exited.
Cancelled server shards can therefore leave descendants consuming runner resources or modifying installation state. The real worker creates nested processes through _test_single, run_command, and the installer wrapper.
Correction: Decouple group cleanup from leader completion in stop_workers. Retain ownership of each launched group, send SIGTERM, enforce the shared grace deadline against group liveness, then send SIGKILL to remaining groups and reap the direct workers. The invariant is that cleanup leaves no live member of an owned worker group, even when its leader exits first. Don't simply remove the poll() guard without considering reused group IDs. I haven't established a safe drop-in patch for that ownership boundary.
Preservation and acceptance: Extend the cancellation test with a ready child that ignores SIGTERM. Cover both an active leader and a leader that exits while its child remains; cancellation must return 143 within the cleanup bound and leave no live descendant. Retain the ordinary-run assertions: all four workers overlap and finish, statuses 1 and 5 make the launcher exit 1, shard membership stays unchanged, and invalid output bytes remain in raw logs while console decoding replaces them. These are proposed checks, not executed results.
…orkers Signed-off-by: oliver könig <[email protected]>
Signed-off-by: oliver könig <[email protected]>
|
/review reset=true |
…orkers Signed-off-by: oliver könig <[email protected]>
|
/review reset=true |
|
/review reset=true approve=true |
|
/review reset=true approve=true |
|
/review reset=true approve=true model=claude |
1 similar comment
|
/review reset=true approve=true model=claude |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
I found one NOTE and nothing at BLOCKER or RISK level. The earlier RISK from review 5772528498 is fixed at this head.
The earlier RISK is fixed. The concern was that cancellation cleanup could leave worker descendants running after their group leader exited. The new stop_workers fixes this:
worker_exit_statuschecks for worker exit withwaitid(WNOWAIT). It doesn't collect (reap) the exited leaders, so their PIDs keep each group ID reserved until cleanup finishes.live_groupsreads the process-group field of/proc/<pid>/statand skips zombies, so it checks whether a group is alive without relying on its leader.- All groups share one 10-second
SIGTERMgrace period. Any group still alive then getsSIGKILL, and cleanup confirms the groups are gone before it collects the leaders. - The nested
_test_single→run_commandprocesses stay in the worker's group because they don't start a new session (server_venv.py). test_cancellation_kills_term_ignoring_children_after_leader_exitcovers both the active-leader case and the exited-leader case.
What else I checked (all 14 changed files):
- Server shard split: each original shard
sofNstill runs exactly the same components. Splitting it into slicess,s+N,s+2Nands+3Nof4Nselects the same modules, because_select_shardtakes everynum_shards-th entry of a sorted list. - Core tests on four workers:
pytest-xdistis in thedevextra. The core-shard plugin loads fromtests/conftest.pyand drops the same tests on every worker. Each worker's coverage still lands in theCOVERAGE_FILEthatcombine_core_coverage.pyexpects. New test files get the median duration weight. - Shared state across the four server workers:
setup_dev.shcreates and activates the driver venv before the launcher starts.- Each server gets its own venv under
uv_venv_dir, guarded by its own lock. - JUnit files are named per entrypoint.
- Log artifacts are named per shard and don't match the coverage download pattern.
- Discovery fix: the
.egg-info/.dist-infoexclusion protects the module-count check (fail_on_total_and_test_mismatch). The newmetadata_presentcase intest_server_suite_exit_statuswould fail without it. - Test fixes: the SciCodePile readiness change closes the pidfile before it signals readiness. The fresh public getter in the token-capture test is needed because
lazy_exportskeeps its warn-once record inside the getter. The longerwait_fortimeouts leave the #4028 count assertions unchanged.
This was a static review; I didn't run any tests. I split the review into three parts and gave each to a separate reviewer. Only one of them returned a report: the one covering the CI wiring. I inspected the launcher lifecycle and the discovery and test-fixture changes myself.
NOTE — The CI contract README still says the shard entrypoints behave as before
I couldn't anchor this inline because scripts/ci/README.md isn't in this diff.
What's out of date:
- L116 says "The eight server shards and the separate on-demand
full-test-suite.ymlkeep their existing behavior." That's no longer true:server_tests.shnow starts fourng_test_allworkers and writes their logs toresults/server-workers/shard-<s>.core_unit_tests.shalways runs-n 4 --dist=loadfile, including the no-argument run the internal adapter uses.full-test-suite.ymldoes the same.- Both entrypoints now limit OpenMP, OpenBLAS, MKL and NumExpr to one thread per process.
- The entrypoint descriptions at L7–L10 don't mention any of this.
Who is affected: the internal NeMo CI adapter runs these same entrypoints under contract version 3 on the cpu_short Slurm partition (.gitlab-ci.yml). Its jobs now run four concurrent pytest or component processes whatever their allocation is, and the README doesn't tell providers. This PR already had to raise a scheduling timeout from 1 s to 5 s because of CPU contention.
Suggested fix:
- Replace L116 with a sentence like this: "Each server shard runs four disjoint
ng_test_allworkers (slicess,s+N,s+2N,s+3Nof4N) and writes per-worker logs toresults/server-workers/shard-<s>. The core and server entrypoints start four workers and limit native thread pools to one thread per process." - Add the expected per-job CPU allocation to the provider contract.
- Could you confirm that
cpu_shortjobs get four CPUs? If the adapter should opt in explicitly, acontract-versionbump may be appropriate; that's your call.
Keep: the color and JUnit statements (L12–L20), the sharding description (L98–L101), and "Tests within a file stay serial" (L102). The last one is still true with --dist=loadfile.
How to check: this is a static check. After the edit, the README's entrypoint descriptions should match core_unit_tests.sh L39, server_tests.sh L67 and L76, and full-test-suite.yml L80 and L131–L133.
Review generated by claude. This was a full review. Request a full review with /review reset=true.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41893255371 |
Background
The four core shards introduced in #5498 still run pytest serially, and each of the eight server shards tests its components serially. In run 41859920268, the core test steps took roughly 12–17 minutes and server test steps took 7–14 minutes.
Use four workers directly on the existing four-CPU runners. No separate issue is needed for this focused CI follow-up.
What changed
-n 4 --dist=loadfile, preserving file-scoped fixtures and the existing shard assignment.sofNbecomes slicess,s+N,s+2N, ands+3Nof4N, preserving exactly the original selection.waitid(WNOWAIT)so unreaped leader PIDs reserve group IDs until cleanup finishes. Check live group members independently of leader completion, use one shared ten-second TERM grace period, then KILL and verify termination before reaping leaders.Details
The shard counts, completeness checks, test selection, sandbox jobs, and coverage threshold remain unchanged. The cancellation test retains #4028's exact sampling/count assertions. Component metadata created by editable installs must not change ownership while other workers are discovering components.
flowchart LR C[4 core jobs] --> CW[4 pytest workers per job] CW --> CC[Combined coverage per job] CC --> CG[Existing 95 percent coverage gate] S[8 server jobs] --> SW[4 component workers per job] SW --> SR[Aggregate every worker result] SR --> SG[Existing server gate]There are no user-facing configuration, migration, verifier, or benchmark-result changes. A matched CI speed comparison is pending; local timings below are validation evidence.
Tested
Latest-main merge (
9dffde9602e32e751c0818ff2eb70d2495a9bf94): incorporate test: mirror nemo_gym packages in the unit test tree #5589's package-aligned test tree, including moving the new worker test intotooling/and updating its root lookup. 402 passed in 27.02 seconds; fullpre-commit run --all-filespassed.Review correction for review 5772528498, after merging
origin/mainatd56eeb5590:PYTEST_ADDOPTS='' python -m pytest -q -o addopts='' --tb=short tests/unit_tests/test_server_test_workers.py— 6 passed in 22.15 seconds. Both new cases launch four TERM-ignoring children, cover an active leader and an already-exited leader, require exit 143 within 15 seconds, and verify no live worker or child survives. The same cases fail against reviewed head7dd149d586ddfae11c0266d0bc12a5e47659a940because children remain alive.source scripts/ci/test_worker_env.sh; PYTEST_ADDOPTS='' taskset -c 0-3 python -m pytest -q -n 4 --dist=loadfile -o addopts='' --tb=short tests/unit_tests/test_server_test_workers.py tests/unit_tests/test_ci_environment.py tests/unit_tests/test_core_test_shards.py tests/unit_tests/test_cli.py— 283 passed in 29.46 seconds.pre-commit run --all-filesand focuseduv --no-config tool run --from mypy==1.17.1 mypy scripts/ci/server_test_workers.py— passed.Previous-head CI run 41871937982: all four core shards, all eight server shards, sandbox tests, combined coverage, and
Nemo_CICD_Testpassed. Fresh CI and a full review are requested for the correction.Initial integration check after merging
origin/mainatb520fed283f5663f2c7d4c42dd27ac356598888c:1,626 passed in 36.84 seconds on four CPU cores.
Real server shard:
python scripts/ci/server_test_workers.py 3 8 +fail_on_total_and_test_mismatch=true +delete_venvs_after_each_test=true— all four workers exited zero; all 31 components and their data validations passed.Changed component:
gym env test +entrypoint=resources_servers/scicodepile +delete_venvs_after_each_test=true +should_validate_data=true— 86 passed; data validation passed.Full non-sandbox core run on four CPU cores, with native thread limits and
--cov=. --cov-report= --cov-fail-under=0: 18,290 passed, 101 skipped, 343 subtests passed in 659.95 seconds. Its sole failure was the one-second cancellation-test startup timeout addressed here; the affected module then passed with the final guard. This workstation required process-local hostname resolution and unsigned synthetic Git fixture configuration; no repository or global configuration was changed. This was before the final guard change and the latest main merge, so it is not a claim of a final full-suite pass.Regression tests exercise actual xdist/coverage combination, whole-file ownership, concurrent subprocess overlap, exact server shard membership, failure propagation, raw logs, and cancellation. Synthetic coverage reached 100%; the real full run produced a combined coverage database with 568 measured files and no absolute paths.
pre-commit run --all-files;shellcheck -x scripts/ci/core_unit_tests.sh scripts/ci/server_tests.sh scripts/ci/test_worker_env.sh;actionlint -shellcheck='' -ignore 'label ".+" is unknown' .github/workflows/unit-tests.yml .github/workflows/full-test-suite.yml;uv --no-config tool run --from mypy==1.17.1 mypy scripts/ci/server_test_workers.py— passed. Actionlint ignores the repository's custom runner labels and disables shell lint for existing workflow snippets; the changed scripts are checked separately.Model rollouts: N/A; this changes CI scheduling, component discovery, and test fixtures. The other seven full server shards and sandbox checks are left to CI.