[misc] fix: validate DataProtoItem consistency - #7450
Open
0z5a wants to merge 1 commit into
Open
Conversation
Assisted-by: OpenAI Codex Signed-off-by: 0z5a <dinadegttyarenko6@gmail.com>
8 tasks
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.
What does this PR do?
Validate
DataProtoIteminvariants at construction time and expose the same validation throughcheck_consistency(). ADataProtoItemnow requires an unbatchedTensorDict(num_batch_dims == 0) plus dictionary-valuednon_tensor_batchandmeta_infofields.This resolves the existing consistency-check TODO with a narrow correctness change and targeted CPU tests. Invalid items now fail at their construction boundary instead of propagating into later protocol operations.
This PR was prepared with AI assistance. The human submitter reviewed every changed line, understands the implementation and tests, and can defend the change end to end.
Duplicate-work check: searches for
DataProtoItem consistencyandprotocol consistencyfound no matching open PR. The only protocol-related result, #4030, addressesDataProto.concattiming metadata and is unrelated.Checklist Before Starting
[{modules}] {type}: {description}.Test
uvx --with hydra-core pre-commit run --files verl/protocol.py tests/test_protocol_on_cpu.pypython -m pytest -q tests/test_protocol_on_cpu.pyAPI and Usage Example
No new API is introduced. Construction now fails early for inconsistent values instead of allowing an invalid
DataProtoItemto propagate. Existing valid construction remains unchanged.Design & Code Changes
DataProtoItem.__post_init__()so validation always runs after dataclass construction.check_consistency()for explicit revalidation after mutation.TensorDictand non-dictionary metadata failures.Checklist Before Submitting
AGENTS.md.