Skip to content

fix(dev): support current torchao and torchrl releases - #2982

Open
n-dlms wants to merge 1 commit into
meta-pytorch:mainfrom
n-dlms:fix/current-releases-compat
Open

fix(dev): support current torchao and torchrl releases#2982
n-dlms wants to merge 1 commit into
meta-pytorch:mainfrom
n-dlms:fix/current-releases-compat

Conversation

@n-dlms

@n-dlms n-dlms commented Aug 3, 2026

Copy link
Copy Markdown

Summary

torchtune currently fails to import and its CI is red against current releases of its two unmanaged dependencies:

  • torchao >= 0.17 moved the NF4 API (NF4Tensor, to_nf4, linear_nf4, implements) from torchao.quantization / torchao.quantization.quantize_.workflows.nf4.nf4_tensor to torchao.dtypes.nf4tensor. All CI workflows (unit_test, gpu_test, regression_test, rl_test, build_docs) install torchao unpinned, so import torchtune breaks on the latest release.
  • torchrl >= 0.13 removed SyncDataCollector, WeightUpdateReceiverBase, WeightUpdateSenderBase, and LLMEnv, which the async RL data path subclasses/imports. The async_rl extra still pins two stale git commits with the note "We will update this to a stable release soon!".

Changes

  1. Import the NF4 symbols with a try/except fallback to torchao.dtypes.nf4tensor in the seven modules that use them (keeps older torchao 0.7-0.16 working).
  2. New torchtune/dev/rl/utils/_torchrl_compat.py: imports the torchrl collector classes when available, otherwise provides import-compatible stand-ins so the RL data path can be imported and unit-tested against released torchrl.
  3. pyproject.toml: the async_rl extra now pins torchrl==0.13.3 / tensordict==0.13.0 instead of the stale git commits.
  4. .github/workflows/rl_test.yaml: drop Python 3.9 from the matrix (torchrl >= 0.13 requires Python >= 3.10).

Notes

  • The full distributed vLLM collector runtime (SyncLLMCollector, VLLMHFWeightUpdateReceiver) still requires torchrl < 0.13 with the original collector classes; the stand-ins intentionally raise NotImplementedError there rather than pretending to work.
  • Verified against torchao 0.17.0 + torchrl 0.13.3 + tensordict 0.13.0: pytest tests/torchtune/dev/rl passes 43, skips 1 (GPU-gated), including when combined with fix(grpo): replay buffer contract corruptions advantages (#2943) #2981's data-path tests.

torchao >= 0.17 moved the NF4 API (NF4Tensor, to_nf4, linear_nf4,
implements) from torchao.quantization / quantize_.workflows.nf4 to
torchao.dtypes.nf4tensor, breaking `import torchtune` against the
latest torchao, which the CI workflows install unpinned. torchrl >= 0.13
removed SyncDataCollector, WeightUpdateReceiverBase,
WeightUpdateSenderBase, and LLMEnv, breaking the async RL data path
against released torchrl.

- Import the NF4 symbols with a fallback to torchao.dtypes.nf4tensor
- Add dev/rl/utils/_torchrl_compat.py with import-compatible stand-ins
  for the removed torchrl collector classes
- Pin the async_rl extra to torchrl 0.13.3 / tensordict 0.13.0 instead of
  stale git commits (the extra's own 'update to a stable release soon' TODO)
- Drop Python 3.9 from the RL CI matrix (torchrl >= 0.13 requires 3.10+)

Verified against torchao 0.17.0 + torchrl 0.13.3 + tensordict 0.13.0:
tests/torchtune/dev/rl passes 43, skips 1 (GPU-gated).
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant