Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/reducing_memory_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ Padding-free batching is an alternative approach for reducing memory usage. In t
<hfoptions id="padding-free">
<hfoption id="DPO">

> [!WARNING]
> Padding-free is temporarily unavailable in DPO since the refactor in [#3906](https://github.com/huggingface/trl/pull/3906). Setting `padding_free=True` in [`DPOConfig`] logs a warning and falls back to standard padding. It is planned to return in a future update, tracked in [#2469](https://github.com/huggingface/trl/issues/2469).

```python
from trl import DPOConfig

Expand Down
6 changes: 5 additions & 1 deletion trl/trainer/dpo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class DPOConfig(_BaseConfig):
Whether to perform forward passes without padding by flattening all sequences in the batch into a single
continuous sequence. This reduces memory usage by eliminating padding overhead. Currently, this is only
supported with the FlashAttention 2 or 3, which can efficiently handle the flattened batch structure.
Temporarily unavailable since the DPO refactor in [#3906](https://github.com/huggingface/trl/pull/3906):
setting it to `True` logs a warning and falls back to standard padding. It is planned to return in a future
update.
pad_to_multiple_of (`int`, *optional*):
If set, the sequences will be padded to a multiple of this value.
precompute_ref_log_probs (`bool`, *optional*, defaults to `False`):
Expand Down Expand Up @@ -207,7 +210,8 @@ class DPOConfig(_BaseConfig):
"help": "Whether to perform forward passes without padding by flattening all sequences in the batch into "
"a single continuous sequence. This reduces memory usage by eliminating padding overhead. Currently, this "
"is only supported with the FlashAttention 2 or 3, which can efficiently handle the flattened batch "
"structure."
"structure. Temporarily unavailable since the DPO refactor in #3906: setting it to `True` logs a warning "
"and falls back to standard padding. It is planned to return in a future update."
},
)
pad_to_multiple_of: int | None = field(
Expand Down
Loading