Repository navigation
fix(data): handle NestedTensor values from TransferQueue - #286
Merged
NINGBENZHE merged 3 commits intoAug 26, 2026
Merged
NINGBENZHE merged 3 commits into
NINGBENZHE merged 3 commits into
Conversation
Member
Author
|
@Yangruipis @NINGBENZHE The PR is ready for review, all CI checks have passed. thx! |
Contributor
|
Thank you for your attention and contribution to this issue. Are you a beginner in Infra or have you been deeply researching it for some time? Perhaps we can have an opportunity to exchange ideas. |
Member
Author
Thx! I’m still new to infra, but I’ve been spending quite a bit of time recently on LLM systems and training/inference infra. Would be happy to exchange ideas sometime! |
NINGBENZHE
reviewed
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
thx for building and open-sourcing Relax — I've been using it to get the fully async training path running, and ran into this while looking into #283.
What
This PR fixes the TransferQueue consumer-side conversion when length/reward fields are restored as jagged
NestedTensors.It also adds regression coverage for:
NestedTensorrows;get_data_from_transfer_queue()length/reward conversion path.Why
Fixes #283.
get_data_from_transfer_queue()currently assumes length/reward-style fields are always regular dense tensors:TransferQueue may restore sampled tensor fields as jagged
NestedTensors. Calling.tolist()on the wholeNestedTensorisn't supported by PyTorch, so the consumer fails while reconstructing the rollout batch.Before the fix, the regression test reproduces the same failure reported in #283:
Simply doing
unbind()+sample.tolist()isn't quite enough either, since scalar-per-sample fields such asresponse_lengthswould become:instead of:
which breaks the downstream length semantics.
How
I added a small conversion helper at the TransferQueue consumer boundary.
For a regular dense tensor, it keeps the existing
.tolist()behavior.For a nested tensor, it iterates over the rows with
unbind():.item()and become Python scalars;.tolist()and keep their row boundary.So, for example:
is restored as:
while a genuinely ragged value such as:
stays:
I kept this PR intentionally small and limited to the existing
lengths/rewardconversion path. A field-schema/normalizer approach would probably be a nicer long-term hardening, but IMO that's better handled separately rather than mixing a broader refactor into this bug fix.Testing
Before the fix
The consumer-boundary regression test fails with the original #283 error:
Result:
After the fix
Same regression test:
Focused regression coverage:
pytest -q \ tests/utils/data/test_streaming_tq_iterator.py \ -k "tensor_to_python_values or converts_nested_length_and_reward_fields"Full
StreamingTQIteratortest file:All data utility tests:
pre-commit run --all-filespassespytest tests/)Type of Change
Screenshots / Logs
The relevant before/after failure and test results are included above.