Skip to content

Conversation

@yurekami
Copy link
Contributor

@yurekami yurekami commented Dec 29, 2025

Summary

  • Add comprehensive Google-style docstrings to 17 functions in verl/utils/tensordict_utils.py
  • Improves IDE support with parameter hints, type information, and examples
  • Part of the documentation standardization effort (Issue [FR][Dev] Unify (& Complete) the docstring format #1345)

Functions Documented

Non-tensor data handling:

  • assign_non_tensor_data - Assign single non-tensor value to TensorDict
  • unwrap_non_tensor_data - Unwrap NonTensorData to get underlying value
  • get_non_tensor_data - Retrieve and unwrap non-tensor data

TensorDict concatenation/splitting:

  • concat_nested_tensors - Concatenate 2D nested tensors
  • concat_tensordict_with_none_bsz - Handle TensorDicts with empty batch size
  • concat_tensordict - Concatenate multiple TensorDicts along dim 0
  • chunk_tensordict - Split TensorDict into equal-sized chunks

Data access and manipulation:

  • index_select_tensor_dict - Select rows using indices
  • union_tensor_dict - Merge two TensorDicts
  • make_iterator - Create mini-batch iterator for training
  • assert_tensordict_eq - Assert two TensorDicts are equal
  • get / get_keys - Get values with automatic unwrapping
  • pop / pop_keys - Remove and return values

Padding utilities:

  • pad_to_divisor - Pad batch dimension for distributed training
  • unpad - Remove padding from TensorDict

Add comprehensive Google-style docstrings to 17 functions in the
tensordict utilities module for better code documentation and IDE support.

Functions documented:
- assign_non_tensor_data, unwrap_non_tensor_data, get_non_tensor_data
- concat_nested_tensors, concat_tensordict_with_none_bsz, concat_tensordict
- chunk_tensordict, index_select_tensor_dict, union_tensor_dict
- make_iterator, assert_tensordict_eq
- get, get_keys, pop, pop_keys
- pad_to_divisor, unpad

Each docstring includes:
- Clear description of function purpose
- Args section with parameter descriptions
- Returns section explaining output
- Raises section for exceptions
- Usage examples where appropriate

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive Google-style docstrings for 17 functions in verl/utils/tensordict_utils.py, significantly improving code clarity and developer experience. The new documentation is well-structured, detailed, and accurately reflects the functionality of each function, including arguments, return values, exceptions, and usage examples. These changes are a valuable contribution to the project's documentation standardization effort. The review did not identify any issues of high or critical severity.

@vermouth1992 vermouth1992 merged commit a570692 into volcengine:main Dec 30, 2025
66 of 72 checks passed
boren-ms pushed a commit to boren-ms/verl that referenced this pull request Dec 30, 2025
…) (volcengine#4732)

## Summary
- Add comprehensive Google-style docstrings to 17 functions in
`verl/utils/tensordict_utils.py`
- Improves IDE support with parameter hints, type information, and
examples
- Part of the documentation standardization effort (Issue volcengine#1345)

## Functions Documented
**Non-tensor data handling:**
- `assign_non_tensor_data` - Assign single non-tensor value to
TensorDict
- `unwrap_non_tensor_data` - Unwrap NonTensorData to get underlying
value
- `get_non_tensor_data` - Retrieve and unwrap non-tensor data

**TensorDict concatenation/splitting:**
- `concat_nested_tensors` - Concatenate 2D nested tensors
- `concat_tensordict_with_none_bsz` - Handle TensorDicts with empty
batch size
- `concat_tensordict` - Concatenate multiple TensorDicts along dim 0
- `chunk_tensordict` - Split TensorDict into equal-sized chunks

**Data access and manipulation:**
- `index_select_tensor_dict` - Select rows using indices
- `union_tensor_dict` - Merge two TensorDicts
- `make_iterator` - Create mini-batch iterator for training
- `assert_tensordict_eq` - Assert two TensorDicts are equal
- `get` / `get_keys` - Get values with automatic unwrapping
- `pop` / `pop_keys` - Remove and return values

**Padding utilities:**
- `pad_to_divisor` - Pad batch dimension for distributed training
- `unpad` - Remove padding from TensorDict

## Test plan
- [ ] Existing tests pass (documentation-only changes)
- [ ] Docstrings follow Google-style format consistent with other files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: yurekami <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants