Skip to content

feat(token-capture): read Gym manifests directly from local ledgers - #4247

Draft
pthombre wants to merge 2 commits into
mainfrom
pranav/manifest_fetch_fix
Draft

pthombre wants to merge 2 commits into
mainfrom
pranav/manifest_fetch_fix

Conversation

@pthombre

@pthombre pthombre commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do ?

Read completed-rollout manifests directly from the colocated Gym policy proxy's ledger, avoiding manifest HTTP connector waits while keeping uvloop enabled.

The actor uses a small thread pool and one semaphore, capped at manifest_read_workers + manifest_queue_size. Threads snapshot the ledger and build the existing receipt; asyncio.as_completed() streams ready receipts to the controller/finalizer. Timed-out or cancelled jobs retain capacity until their executor future finishes. Stream cleanup cancels pending work and releases delivered payloads promptly. Existing rollout timing metrics include manifest_read_total.

There is no custom queue/consumer scheduler, ticket/result layer, histogram service, or private HTTP pool. The shared HTTP control code and sequential HTTP mode remain unchanged. Startup verifies the writer's host/device/inode; local mode never silently falls back to HTTP.

Issues and dependency

Companion reader: NVIDIA-NeMo/Gym#3646. No separate issue is needed for this focused timeout workaround. RL pins the companion Gym commit; merge Gym first and update the pin if its merge rewrites the SHA.

Usage

token_capture:
  enabled: true
  capture_dir: /dev/shm/gym_token_capture/my-run
  manifest_transport: local_file
  manifest_read_workers: 2
  manifest_queue_size: 256
  control_timeout_s: 60.0

Use a unique directory shared by actor and proxy on the same node. The schema default remains http; GRPO/PPO examples select local_file. Transport/resource knobs are excluded from checkpoint compatibility fingerprints. Receipt schema, finalizer behavior, and TransferQueue token transport are unchanged.

Validation

Container: /lustre/fsw/portfolios/nemotron/projects/nemotron_sw_post/users/pthombre/enroot-images/nvcr.io+nvidian+nemo-rl+nightly.squashfs. Python 3.13.14, uvloop 0.22.1; RAY_USE_UVLOOP=1.

Slurm 3940605: 1,430 tests passed (47 manifest/receipt, 1,129 controller/lifecycle, 254 Gym token capture), using:

uv run --no-project --python /opt/nemo_rl_venv/bin/python python -m pytest -q --nemo-gym-only tests/unit/environments/test_nemo_gym_manifest.py tests/unit/environments/test_nemo_gym_token_capture.py
uv run --no-project --python /opt/nemo_rl_venv/bin/python python -m pytest -q tests/unit/single_controller tests/unit/environments/test_nemo_gym_health.py tests/unit/environments/test_nemo_gym_utils.py
# From Gym:
uv run --no-project --python /opt/nemo_rl_venv/bin/python python -m pytest -q -o addopts= tests/unit_tests/test_token_capture*.py

Scoped Ruff lint/import/format checks, focused Pyrefly, Gym full pre-commit, and diff checks passed. The Gym pin's lock metadata was checked with uv 0.11.21; dependency versions remain unchanged.

Reader benchmark 3940558: median of three alternating 4,096-receipt tmpfs bursts, two threads, 512 concurrent requests, same container and uvloop. Includes receipt assembly; no model or concurrent writer load:

Calls per manifest Previous receipts/s Simplified receipts/s Change
1 3,352 4,383 +30.8%
8 2,828 2,943 +4.0%
32 1,452 1,365 -6.0%

The 32-call case is 6% slower; no full-training throughput claim is made. OS reads cannot be forcibly interrupted, and deadline delivery depends on event-loop scheduling.

Before ready for review

  • Contributor guidelines, DCO, tests, documentation, and config examples.
  • Full functional training/scale validation; remains a draft.

@pthombre pthombre added the CI:L0 Run doctests and unit tests label Sep 23, 2026
@copy-pr-bot

copy-pr-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Sep 23, 2026
@pthombre

Copy link
Copy Markdown
Contributor Author

/ok to test 9043c8a

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 9043c8a (PR #4247 from pranav/manifest_fetch_fix)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@pthombre

Copy link
Copy Markdown
Contributor Author

/ok to test a9ac244

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: a9ac244 (PR #4247 from pranav/manifest_fetch_fix)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@terrykong terrykong added CI:L1 Run doctests, unit tests, and functional tests and removed CI:L0 Run doctests and unit tests labels Nov 5, 2026
@terrykong terrykong removed the Documentation Improvements or additions to documentation label Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L1 Run doctests, unit tests, and functional tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants