Skip to content

Conversation

@BenjaminBossan
Copy link
Member

@BenjaminBossan BenjaminBossan commented May 23, 2024

Description

With only a few changes, I managed to get DoRA running with FSDP.

Implementation

The first secret ingredient was to not use lora_B.weight @ lora_A.weight, as this sidesteps the __call__ of the module, which is required for FSDP to do some magic, thanks @pacman100 for sharing this secret knowledge with me. Instead, we now do:

x_eye = torch.eye(lora_A.weight.shape[1], device=lora_A.weight.device)
lora_weight = lora_B(lora_A(x_eye)).T

This should have the same output but uses __call__. It is probably a little bit slower though.
(I ran all DoRA tests with an added assert that the two expressions return the same results to make sure.)

The second necessary step, required to make DoRA work with bitsandbytes (QDoRA), was to initialize the DoRA parameters lazily. This means: Normally, we initialize all the parameters when we initialize the layer. However, DoRA initialization requires us to dequantize the bnb weights. FSDP doesn't like that for some reason, as this results in FSDP trying to flatten int params.

Instead of eagerly initializing the DoRA weights, they are now lazily initialized during the forward step. This is not ideal, but at least it works.

Apart from this, only some minor changes were required. It was apparently not necessary to use ModuleDict instead of ParamDict, which was my first attempt (which also works but is a much bigger refactor and changes the state_dict).

Note: The change is only implemented for lora.Linear, not yet for lora.Conv2d.

TODOs

more of a reminder for myself

One problem still with this implementation is the lazy init of the DoRA weight, which is required as explained above. We need to put a placeholder value there, otherwise, we cannot successfully load trained DoRA models. However, if this placeholder value has requires_grad=True, we get an error because requires_grad is not consistent when params are flattened by FSDP. When we set requires_grad=False, it makes it so that even if we later set the real value with requires_grad=True, it is still not updated.

We could try updating fsdp_auto_wrap_policy so that the DoRA weight is not included in the same unit as the non-trainable weights. This works and allows us to initialize the FSDP model, but then we later get RuntimeError: CUDA error: an illegal memory access was encountered.

Changes to the scripts in examples/sft for this experiment:

I could successfully run FSDP training with DoRA on a 2xT4 machine based on the PEFT examples in the sft folder. I made a few small changes to the scripts:

  • run_peft_qlora_fsdp.sh
3c3
< --model_name_or_path "meta-llama/Llama-2-70b-hf" \
---
> --model_name_or_path "facebook/opt-125m" \
9c9
< --max_seq_len 2048 \
---
> --max_seq_len 256 \
16,19c16
< --push_to_hub \
< --hub_private_repo True \
< --hub_strategy "every_save" \
< --bf16 True \
---
> --bf16 False \
26c23
< --output_dir "llama-sft-qlora-fsdp" \
---
> --output_dir "/tmp/llama-sft-qlora-fsdp" \
33c30
< --use_flash_attn True \
---
> --use_flash_attn False \
41,42c38,39
< --bnb_4bit_compute_dtype "bfloat16" \
< --bnb_4bit_quant_storage_dtype "bfloat16"
\ No newline at end of file
---
> --bnb_4bit_compute_dtype "float32" \
> --bnb_4bit_quant_storage_dtype "float32"
  • utils.py
141a142,143
>         use_dora = bool(int(os.environ.get("USE_DORA"))) 
>         print("*"*20, "use dora:", use_dora)
147a150
>             use_dora=use_dora,

Training log

***** Running training *****
  Num examples = 48,106
  Num Epochs = 1
  Instantaneous batch size per device = 2
  Total train batch size (w. parallel, distributed & accumulation) = 8
  Gradient Accumulation steps = 2
  Total optimization steps = 6,013
  Number of trainable parameters = 663,552
{'loss': 2.8955, 'grad_norm': 0.8952780365943909, 'learning_rate': 9.999982939289716e-05, 'epoch': 0.0}                                                  
{'loss': 2.7834, 'grad_norm': 0.9351043105125427, 'learning_rate': 9.999931757275294e-05, 'epoch': 0.0}                                                  
{'loss': 2.8371, 'grad_norm': 0.9547858834266663, 'learning_rate': 9.999846454306009e-05, 'epoch': 0.0}                                                  
{'loss': 2.6302, 'grad_norm': 0.8862084150314331, 'learning_rate': 9.999727030964001e-05, 'epoch': 0.0}                                                  
{'loss': 2.8222, 'grad_norm': 1.0635148286819458, 'learning_rate': 9.999573488064242e-05, 'epoch': 0.0}                                                  
{'loss': 2.8932, 'grad_norm': 0.9164345860481262, 'learning_rate': 9.999385826654554e-05, 'epoch': 0.0}                                                  
{'loss': 2.7997, 'grad_norm': 0.9818331599235535, 'learning_rate': 9.999164048015593e-05, 'epoch': 0.01}                                                 
{'loss': 2.8716, 'grad_norm': 1.1899254322052002, 'learning_rate': 9.998908153660838e-05, 'epoch': 0.01}                                                 
{'loss': 2.7126, 'grad_norm': 0.914239227771759, 'learning_rate': 9.998618145336587e-05, 'epoch': 0.01}                                                  
{'loss': 2.7325, 'grad_norm': 1.0930601358413696, 'learning_rate': 9.998294025021936e-05, 'epoch': 0.01}                                                 
{'loss': 2.6289, 'grad_norm': 0.9594664573669434, 'learning_rate': 9.997935794928776e-05, 'epoch': 0.01}                                                 
{'loss': 2.7155, 'grad_norm': 1.0767607688903809, 'learning_rate': 9.997543457501773e-05, 'epoch': 0.01}                                                 
{'loss': 2.6928, 'grad_norm': 1.0032813549041748, 'learning_rate': 9.997117015418345e-05, 'epoch': 0.01}                                                 
{'loss': 2.645, 'grad_norm': 1.168573260307312, 'learning_rate': 9.996656471588657e-05, 'epoch': 0.01}                                                   
{'loss': 2.6361, 'grad_norm': 1.0172500610351562, 'learning_rate': 9.996161829155588e-05, 'epoch': 0.01}                                                 
{'loss': 2.8198, 'grad_norm': 1.0332210063934326, 'learning_rate': 9.995633091494722e-05, 'epoch': 0.01}                                                 
{'loss': 2.72, 'grad_norm': 1.0368295907974243, 'learning_rate': 9.995070262214313e-05, 'epoch': 0.01}                                                   
{'loss': 2.7599, 'grad_norm': 1.1201494932174683, 'learning_rate': 9.994473345155267e-05, 'epoch': 0.01}                                                 
{'loss': 2.5562, 'grad_norm': 1.09053373336792, 'learning_rate': 9.993842344391118e-05, 'epoch': 0.02}                                                   
{'loss': 2.7267, 'grad_norm': 1.0421711206436157, 'learning_rate': 9.993177264227992e-05, 'epoch': 0.02}                                                 
{'loss': 2.7317, 'grad_norm': 1.1445740461349487, 'learning_rate': 9.992478109204589e-05, 'epoch': 0.02}                                                 
{'loss': 2.7285, 'grad_norm': 1.1827253103256226, 'learning_rate': 9.991744884092137e-05, 'epoch': 0.02}                                                 
{'loss': 2.6398, 'grad_norm': 1.0205488204956055, 'learning_rate': 9.990977593894374e-05, 'epoch': 0.02}                                                 
{'loss': 2.599, 'grad_norm': 1.026229977607727, 'learning_rate': 9.990176243847507e-05, 'epoch': 0.02}                                                   
{'loss': 2.6922, 'grad_norm': 1.0691609382629395, 'learning_rate': 9.989340839420176e-05, 'epoch': 0.02}                                                 
{'loss': 2.6191, 'grad_norm': 1.0511975288391113, 'learning_rate': 9.988471386313418e-05, 'epoch': 0.02}                                                 
{'loss': 2.8006, 'grad_norm': 1.0725524425506592, 'learning_rate': 9.987567890460628e-05, 'epoch': 0.02}                                                 
{'loss': 2.6992, 'grad_norm': 1.1552668809890747, 'learning_rate': 9.98663035802752e-05, 'epoch': 0.02}                                                  
{'loss': 2.6909, 'grad_norm': 1.0143084526062012, 'learning_rate': 9.985658795412079e-05, 'epoch': 0.02}                                                 
{'loss': 2.5932, 'grad_norm': 1.0270745754241943, 'learning_rate': 9.984653209244525e-05, 'epoch': 0.02}                                                 
{'loss': 2.6703, 'grad_norm': 1.142627477645874, 'learning_rate': 9.983613606387265e-05, 'epoch': 0.03}                                                  
{'loss': 2.5607, 'grad_norm': 1.0679482221603394, 'learning_rate': 9.982539993934844e-05, 'epoch': 0.03}                                                 
{'loss': 2.6616, 'grad_norm': 1.0160728693008423, 'learning_rate': 9.981432379213898e-05, 'epoch': 0.03}                                                 
{'loss': 2.6676, 'grad_norm': 1.163256049156189, 'learning_rate': 9.980290769783103e-05, 'epoch': 0.03}                                                  
{'loss': 2.7486, 'grad_norm': 1.0142438411712646, 'learning_rate': 9.979115173433128e-05, 'epoch': 0.03}                                                 
{'loss': 2.5851, 'grad_norm': 1.120428442955017, 'learning_rate': 9.977905598186578e-05, 'epoch': 0.03}                                                  
{'loss': 2.7134, 'grad_norm': 1.0812691450119019, 'learning_rate': 9.976662052297935e-05, 'epoch': 0.03}                                                 
{'loss': 2.6443, 'grad_norm': 1.1822906732559204, 'learning_rate': 9.97538454425351e-05, 'epoch': 0.03}                                                  
{'loss': 2.4838, 'grad_norm': 1.39701247215271, 'learning_rate': 9.974073082771382e-05, 'epoch': 0.03}                                                   
{'loss': 2.6165, 'grad_norm': 1.145723581314087, 'learning_rate': 9.972727676801338e-05, 'epoch': 0.03}                                                  
{'loss': 2.7184, 'grad_norm': 1.1211601495742798, 'learning_rate': 9.971348335524808e-05, 'epoch': 0.03}                                                 
{'loss': 2.6372, 'grad_norm': 1.024659276008606, 'learning_rate': 9.969935068354807e-05, 'epoch': 0.03}                                                  
{'loss': 2.6092, 'grad_norm': 1.1009517908096313, 'learning_rate': 9.968487884935878e-05, 'epoch': 0.04}                                                 
{'loss': 2.5787, 'grad_norm': 1.0226079225540161, 'learning_rate': 9.967006795144006e-05, 'epoch': 0.04}                                                 
{'loss': 2.6843, 'grad_norm': 1.041178822517395, 'learning_rate': 9.96549180908657e-05, 'epoch': 0.04}                                                   
{'loss': 2.6676, 'grad_norm': 1.0906169414520264, 'learning_rate': 9.963942937102269e-05, 'epoch': 0.04}                                                 
{'loss': 2.5395, 'grad_norm': 1.0848253965377808, 'learning_rate': 9.962360189761041e-05, 'epoch': 0.04}                                                 
{'loss': 2.6135, 'grad_norm': 1.0817619562149048, 'learning_rate': 9.960743577864004e-05, 'epoch': 0.04}                                                 
{'loss': 2.7096, 'grad_norm': 1.1412609815597534, 'learning_rate': 9.959093112443378e-05, 'epoch': 0.04}                                                 
{'loss': 2.664, 'grad_norm': 1.0265809297561646, 'learning_rate': 9.957408804762409e-05, 'epoch': 0.04}                                                  
{'loss': 2.5626, 'grad_norm': 1.040503978729248, 'learning_rate': 9.955690666315289e-05, 'epoch': 0.04}                                                  
{'loss': 2.6042, 'grad_norm': 1.0967168807983398, 'learning_rate': 9.953938708827086e-05, 'epoch': 0.04}                                                 
{'loss': 2.5536, 'grad_norm': 1.0510889291763306, 'learning_rate': 9.952152944253651e-05, 'epoch': 0.04}                                                 
{'loss': 2.5904, 'grad_norm': 1.0969544649124146, 'learning_rate': 9.950333384781552e-05, 'epoch': 0.04}                                                 
{'loss': 2.6716, 'grad_norm': 1.1797243356704712, 'learning_rate': 9.94848004282798e-05, 'epoch': 0.05}                                                  
{'loss': 2.5291, 'grad_norm': 1.082594633102417, 'learning_rate': 9.946592931040666e-05, 'epoch': 0.05}                                                  
{'loss': 2.5242, 'grad_norm': 1.0399702787399292, 'learning_rate': 9.944672062297795e-05, 'epoch': 0.05}                                                 
  5%|█████▎                                                                                                         | 286/6013 [08:50<2:49:19,  1.77s/it]

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@pacman100 pacman100 left a comment

Choose a reason for hiding this comment

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

Thank you, @BenjaminBossan, the fix is neat and doesn't involve a lot of code changes! ✨

We need to init the dora params with dummy values at the start.
tis was a silly idea
@BenjaminBossan
Copy link
Member Author

Update: Unfortunately, I could not get past the last few issues mentioned above. Therefore, I'll close this PR in favor of #1806. That PR has more code changes, so it would have been nice to get this one working, but I did not succeed.

BenjaminBossan added a commit that referenced this pull request May 31, 2024
This PR moves all the DoRA functionality into a separate module class.
Essentially, this is necessary because otherwise, the DoRA parameter
lives on the lora.Linear layer as a parameter, not a separate module.
Since FSDP auto wrap policy operates on the level of modules, not
parameters, there is no way to modify the auto wrap policy to wrap the
DoRA parameter, it must be its own module.

If not for this reason, #1797 would be preferable, since the number of
code changes is smaller overall. In this PR, there are more numerous
changes, but the majority only involves moving code around, not any
actual code changes.

Since we introduce a new submodule, an extra steps are required to
ensure that old DoRA state dicts can still be loaded correctly. This
involves a fairly trivial extra remapping step in
set_peft_model_state_dict. The test for this is performed via the new
regression DoRA tests introduced in #1792.

Similarly, there is a remapping step involved in
get_peft_model_state_dict to ensure that when new state dicts with DoRA
are saved, they still conform to the old format.

An additional required change was to make a defensive copy of the base
layer before dequantizing its weight in order to calculate the weight
norm for DoRA. Without this defensive copy, some side-effect is
triggered in FSDP that results in

> ValueError: Cannot flatten integer dtype tensors

even though the compute dtype of bnb is correctly set to float.

Creating a fully functioning deepcopy does currently not work with 8bit
BNB but there is a fix. Once the next BNB release is out, 8bit BNB will
be tested and enabled.

While working on this, I also noticed a small bug that dropout was not
correctly applied when using QDoRA. This is now also fixed.

This PR was tested successfully with FSDP and (Q)DoRA using the scripts
in examples/sft/ with a modification to enable DoRA.
Guy-Bilitski pushed a commit to Guy-Bilitski/peft that referenced this pull request May 13, 2025
This PR moves all the DoRA functionality into a separate module class.
Essentially, this is necessary because otherwise, the DoRA parameter
lives on the lora.Linear layer as a parameter, not a separate module.
Since FSDP auto wrap policy operates on the level of modules, not
parameters, there is no way to modify the auto wrap policy to wrap the
DoRA parameter, it must be its own module.

If not for this reason, huggingface#1797 would be preferable, since the number of
code changes is smaller overall. In this PR, there are more numerous
changes, but the majority only involves moving code around, not any
actual code changes.

Since we introduce a new submodule, an extra steps are required to
ensure that old DoRA state dicts can still be loaded correctly. This
involves a fairly trivial extra remapping step in
set_peft_model_state_dict. The test for this is performed via the new
regression DoRA tests introduced in huggingface#1792.

Similarly, there is a remapping step involved in
get_peft_model_state_dict to ensure that when new state dicts with DoRA
are saved, they still conform to the old format.

An additional required change was to make a defensive copy of the base
layer before dequantizing its weight in order to calculate the weight
norm for DoRA. Without this defensive copy, some side-effect is
triggered in FSDP that results in

> ValueError: Cannot flatten integer dtype tensors

even though the compute dtype of bnb is correctly set to float.

Creating a fully functioning deepcopy does currently not work with 8bit
BNB but there is a fix. Once the next BNB release is out, 8bit BNB will
be tested and enabled.

While working on this, I also noticed a small bug that dropout was not
correctly applied when using QDoRA. This is now also fixed.

This PR was tested successfully with FSDP and (Q)DoRA using the scripts
in examples/sft/ with a modification to enable DoRA.
cyyever pushed a commit to cyyever/peft that referenced this pull request Sep 4, 2025
* llava support dpo

* add_special_tokens=False only when possible

* format

* pali gemma

* refactor size

* remove image resize

---------

Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>
cyyever pushed a commit to cyyever/peft that referenced this pull request Sep 4, 2025
* Add WinRateCallback

* Enable PairRM

* Refactor

* Streamline

* Add HF judge

* Add base judge

* Use better prompt

* Clean

* Add max tokens

* Use logging

* Add batched inference

* Squashed commit of the following:

commit 9e9dc96
Author: Maxim Kopecki <kopecki.maxim@gmail.com>
Date:   Wed Jul 10 19:11:13 2024 +0200

    Added missing token kwarg in Peft model loading (huggingface#1825)

commit 7ddef5c
Author: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Date:   Wed Jul 10 18:26:11 2024 +0200

    Make use of `trust_remote_code` consistent (huggingface#1806)

    Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>

commit a9cddf8
Author: Adnan Khan <AdnaneKhan@users.noreply.github.com>
Date:   Wed Jul 10 11:25:07 2024 -0400

    Delete unused benchmark.yml workflow. (huggingface#1822)

commit 2860ce5
Author: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Date:   Tue Jul 9 09:22:52 2024 +0200

    DPO Llava 1.5 and PaliGemma support (huggingface#1797)

    * llava support dpo

    * add_special_tokens=False only when possible

    * format

    * pali gemma

    * refactor size

    * remove image resize

    ---------

    Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>

commit 30e33bd
Author: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Date:   Tue Jul 9 05:37:12 2024 +0200

    upgrade gh actions (huggingface#1818)

    Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>

commit d5a0d2d
Author: Costa Huang <costa.huang@outlook.com>
Date:   Mon Jul 8 11:12:41 2024 -0400

    Set dev version (huggingface#1817)

commit 314e8eb
Author: Puneet Singh Bhooi <puneetb@iiitd.ac.in>
Date:   Mon Jul 8 19:11:36 2024 +0530

    fix broken url in `docs\source\index.mdx` (huggingface#1813)

commit e107920
Author: Costa Huang <costa.huang@outlook.com>
Date:   Mon Jul 8 09:38:09 2024 -0400

    0.9.6 release (huggingface#1816)

commit 78045de
Author: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com>
Date:   Mon Jul 8 01:59:26 2024 +0200

    Fix `TRL_USE_RICH` environment variable handling (huggingface#1808)

    * Add `strtobool` custom implementation from `distutils`

    * Fix `TRL_USE_RICH` handling via `strtobool`

    * Run `make precommit`

commit 747612f
Author: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com>
Date:   Fri Jul 5 16:28:59 2024 +0200

    Fix `torch_dtype` handling in `{DPO,SFT}Trainer` when provided via CLI (huggingface#1807)

    * Fix `torch_dtype` handling through CLI

    The `torch_dtype` is not properly handled when provided via the TRL CLI
    since it's provided initially as a string, but is then casted to
    `torch.dtype` before providing it to the `{DPO,SFT}Trainer`, which means
    that those trainers should handle the scenario where `torch_dtype` is a
    `torch.dtype` too.

    * Add `torch_dtype` tests in `test_{dpo,sft}_trainer.py`

    * Forward contribution credits

    * Run `make precommit`

    ---------

    Co-authored-by: Tash Srivastava <yash-srivastava19@users.noreply.github.com>

commit 9e3a35b
Author: Michael <mnoukhov@gmail.com>
Date:   Fri Jul 5 07:29:48 2024 -0400

    Remove extra print in reward_trainer.py (huggingface#1799)

    `print_rich_table` is called twice and the first call doesn't restrict to `num_print_samples`. Remove the first, extra call

commit 4402b36
Author: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Date:   Thu Jul 4 14:29:25 2024 +0200

    clean examples (huggingface#1791)

    Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>

commit 78f8228
Author: Noah Tye <hi@noahtye.com>
Date:   Wed Jul 3 11:10:50 2024 -0700

    Bugfix: Preserve token fields when converting TrainingArguments to SFTConfig (huggingface#1794)

    * Preserve token fields when converting TrainingArguments to SFTConfig

    TrainingArguments.to_dict() redacts token fields, so we have to
    individually copy them over when converting to SFTConfig to avoid
    breaking push_to_hub functionality.

    Also adds a test.

    * run precommit

    * one-line args_as_dict definition per suggestion from kashif

    * generalize token copying to match TrainingArguments behavior

    * unwrap |= on dict, to support python 3.8

    * use .update instead of |= or for-loop

commit b6af2ed
Author: Kashif Rasul <kashif.rasul@gmail.com>
Date:   Wed Jul 3 08:29:16 2024 +0200

    add model_init_kwargs to training_args (#1787)

commit cd85b14
Author: Tommaso Buonocore <buonocore.tms@gmail.com>
Date:   Sat Jun 29 15:35:48 2024 +0200

    Fixed typo in SFT trainer docs (#1788)

    'STFConfig' instead of 'SFTConfig' appears multiple times in the doc, causing error when running the code snippets.

commit a57544f
Author: Kashif Rasul <kashif.rasul@gmail.com>
Date:   Thu Jun 27 15:47:58 2024 +0200

    fix docs and examples (huggingface#1780)

commit b68ff96
Author: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Date:   Wed Jun 26 16:26:37 2024 +0200

    Visual DPO (huggingface#1647)

    * Remove extra whitespaces

    * idefics

    * vdpo

    * sft idefics

    * pad with test

    * use prompt instead of tokenizer

    * rm name main

    * support vlm in tokenize row

    * temp fix for regex in lora_target_module

    * format

    * vdpo

    * tmp float16 hard code

    * concatenated_forward support for vision

    * style and new command line

    * all-linear

    * format

    * delete old examples

    * get image

    * upcast

    * new test

    * modified test

    * new strat for tokenizer

    * rm token transfer

    * integrate vision in dpo example

    * format

    * add FDivergenceType back

    * precommit

    * pillow test dep

    * optional prompt

    * `evaluation_strategy` to `eval_strategy`

    * revert vsft change (oos)

    * update test

    * test

    * comment and support more in process

    * update process

    * update doc for vdpo

    * caution about limited support

    * Update docs/source/dpo_trainer.mdx

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * revert DPO example changes

    * cleaner way to check if a model is vision

    * comment

    * update vdpo example

    * rename

    ---------

    Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>
    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

commit c8c01cc
Author: Mubin Manasia <48038715+Mubin17@users.noreply.github.com>
Date:   Wed Jun 26 03:23:36 2024 -0600

    Fix Documentation Overflow Issues for Long URLs in SFTConfig (huggingface#1774)

    * Update sft_config.py

    * Update sft_config.py

commit 3479606
Author: Costa Huang <costa.huang@outlook.com>
Date:   Wed Jun 26 03:18:22 2024 -0400

    Remove the leading space in the tldr preference dataset (huggingface#1773)

commit 7965b78
Author: Haozhe Ji <jihaozhe@gmail.com>
Date:   Tue Jun 25 22:47:32 2024 +0800

    add Efficient Exact Optimization (EXO) (huggingface#1735)

    * add exo

    * fix a detail

    * Update trl/trainer/dpo_trainer.py

    * Update trl/trainer/dpo_trainer.py

    * Update trl/trainer/dpo_trainer.py

    ---------

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

commit 56bd1bb
Author: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Date:   Tue Jun 25 16:14:26 2024 +0200

    `evaluation_strategy` to `eval_strategy` (huggingface#1771)

    Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>

commit 94d53e6
Author: Clara Pohland <54847419+claralp@users.noreply.github.com>
Date:   Mon Jun 24 21:27:00 2024 +0200

    MoE Models: option to add load balancing loss (#1765)

    * KTO: add aux loss

    * use router_aux_loss_coef in KtoTrainer when aux_loss enabled

    * align optional aux_loss in DPO, KTO, CPO, ORPO

    * precommit changes

    * fix KL forward kwargs

    * add aux_loss doku entry

    * apply docs suggestions

    ---------

    Co-authored-by: Clara Luise Pohland <clara-luise.pohland@telekom.de>

commit b5be100
Author: Mihir Prabhudesai <mihirp1998.mp@gmail.com>
Date:   Mon Jun 24 12:05:44 2024 -0400

    Added Reward Backpropogation Support  (huggingface#1585)

    * added alignprop template

    * added alignprop support

    * Update alignprop_trainer.mdx

    * Update alignprop_trainer.mdx

    * added better why statement

    * fixed inference code

    * changed self to pipeline

    * removed aesthetic classifier

    * added aesthetic to auxiliary models

    * added unseen prompt logging

    * removed unseen prompt log

    * fixed minor

    * remove not needed import in trl/__init__.py

    Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>

    * fixed styling

    * updated _toctree

    ---------

    Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>

commit 6e1652b
Author: Haoran Xu <45837851+fe1ixxu@users.noreply.github.com>
Date:   Sun Jun 23 09:54:30 2024 -0700

    Add CPO-SimPO method (huggingface#1760)

    * enable cpo-simpo

    * highlight SimPO and CPO-SimPO

    * add test for cpo_alpha

    * formatting

    * Update docs/source/cpo_trainer.mdx

    ---------

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

commit 65374c6
Author: Costa Huang <costa.huang@outlook.com>
Date:   Fri Jun 21 11:20:54 2024 -0400

    New sentiment and descriptiveness dataset (huggingface#1757)

    * push changes

    * handle edge cases where the chosen and the rejected are the same

commit 9956091
Author: Juyoung Suk <scottsuk0306@gmail.com>
Date:   Fri Jun 21 18:01:08 2024 +0900

    Add dataset_text_field in examples/scripts/sft.py (huggingface#1758)

commit 34d273f
Author: Costa Huang <costa.huang@outlook.com>
Date:   Thu Jun 20 13:16:43 2024 -0400

    Support num_train_epochs (huggingface#1743)

    * add a test case for num_train_epochs

    * fix ci

    * quick change

    * disable push to hub

    * debug windows ci

    * try another fix

    * skip subprocess tests on windows

commit 3bf9449
Author: Mert Sayar <mert.sayar@gmail.com>
Date:   Thu Jun 20 18:22:20 2024 +0300

    Fix masking of response tokens (huggingface#1718)

    Current handling of `response_masks` inside `batch_forward_pass`
    function does not take padding into consideration which results with
    shape unmatch during masking. Since response mask is a mask tensor of
    response tokens, response tokens should not be concatenated with a
    `torch.zeros(query_length)` and masking operation should be done without
    slicing.

    Remove the concatenation of the response mask, remove the slicing from
    the response mask since response mask already has the length of `end -
    start + 1`, which is equal to length of `masks[j, start:end]`.

commit ba6abee
Author: idanshen <49375140+idanshen@users.noreply.github.com>
Date:   Thu Jun 20 09:14:16 2024 -0400

    Support for returning past_key_values from the model (huggingface#1742)

    * add support for returning past_key_values from the model

    * change order of  keys

commit a57e759
Author: 1485840691 <110707330+1485840691@users.noreply.github.com>
Date:   Wed Jun 19 18:02:51 2024 +0800

    Integrate f-divergence to DPO (Follow up) (huggingface#1610)

    * Step 1: update ppo_trainer and hello_world example

    * Step 2: Refine comments and add parameter type

    * Step 2: Add missing parameter comments

    * Step 1: Organize ptx loss into a function and add ptx_loss to train_stats

    * Step 1 updates: add comment to ptx_loss function, fix a bug and add warning message

    * Step 2: 1) Add ppo_ptx trainig example as ppo; 2) separate pretrain data fetch and iterate

    * Step 2: Remove loss from columns_to_log in ppo_ptx example

    * Remove data set revision in load imbd dataset

    * Run pre-commit and fix format issues

    * Initial draft of f-divergence fn

    * Update f-divergence to avoid overflow

    * fix test errors and comments

    * Add Unit tests for dpo loss with alpha and js div f

    * Adjust format

    * Fix test error

    * Reverse this update

    * Add test cases

    * Reverse un-needed updates

    * Update code style

    * Try to fix code fmt error

    * remove extra end line

    ---------

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

commit ae23d40
Author: Shihyueh Hsu <66808901+AIR-hl@users.noreply.github.com>
Date:   Tue Jun 18 22:07:24 2024 +0800

    change the `process` function in the example of DPO (huggingface#1753)

    * change the `process` function in the example of DPO

    * fix

commit 83b367b
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Tue Jun 18 11:31:17 2024 +0200

    CI / `KTOTrainer`: Remove old tests (huggingface#1750)

    * remove old tests

    * remove datasets

    * Update test_dpo_trainer.py

    * Update test_dpo_trainer.py

commit d1ed730
Author: Michael <mnoukhov@gmail.com>
Date:   Mon Jun 17 10:50:21 2024 -0400

    prepare deepspeed accomodate fp16 and bf16 (huggingface#1728)

    * prepare deepspeed accomodate fp16 and bf16

    * precommit

commit 8f8e95e
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Mon Jun 17 16:49:00 2024 +0200

    CPO / DPO: Fix red CI (huggingface#1749)

    * fix red CI

    * precommit

commit 4e23d95
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Mon Jun 17 16:41:36 2024 +0200

    fix red CI

commit 50c4620
Author: Kawin <kawin.ethayarajh@gmail.com>
Date:   Mon Jun 17 07:14:44 2024 -0700

    small KTO fixes (huggingface#1734)

    * add warning for imbalanced data

    * update documentation

    * update script commands to be same as in dpo

    * use batch_size KL examples and batch_size target examples to calculate batch_size losses

    * fix deepspeed issue

    * speed up forward with no_grad for KL

    * add some removed metrics

    * Update trl/trainer/kto_trainer.py

    * Update trl/trainer/kto_trainer.py

    * Update trl/trainer/kto_trainer.py

    add reference to paper

    Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * add more detailed comments

    * convert assert to ValueError

    * Update kto_trainer.py

    * precommit formatting

    * remove nans in metrics by gathering across machines

    * fix formatting

    * fix choice of mismatched examples for KL term

    * describe weights

    * fix hanging issue in distributed training

    * linting

    * move metrics to cpu

    * Update trl/trainer/kto_trainer.py

    Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>

    * Update trl/trainer/kto_trainer.py

    * Update trl/trainer/kto_trainer.py

    * remove kto_pair

    * speed up data processing

    * move bco code inside

    * raise error for kto_pair argument

    * fix formatting

    ---------

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>
    Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
    Co-authored-by: Winnie Xu <winnie.xu97@gmail.com>

commit 6105d03
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Mon Jun 17 16:01:06 2024 +0200

    `TrlParser`: Add ignore extra args option (huggingface#1748)

    * add ignore extra args option

    * Update trl/commands/cli_utils.py

commit e247bbd
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Mon Jun 17 15:16:07 2024 +0200

    CI / core: Pin `numpy` to `!=2.0.0` for CI and to users (huggingface#1747)

    * Update setup.py

    * Update setup.py

    * Update setup.py

    * Update test_best_of_n_sampler.py

    dummy commit

    * pin numpy

    * Update tests/test_best_of_n_sampler.py

    * Update setup.py

commit 3d04496
Author: Michael <mnoukhov@gmail.com>
Date:   Mon Jun 17 08:43:33 2024 -0400

    better trl parser with yaml config (huggingface#1739)

    * working trl parser with config

    correctly overrides yaml config with command line arguments
    adds return_remaining_strings
    when return_remaining_strings is False, raises error if yaml contains
    extra args that are not in the dataclasses
    simpler and cleaner than previous yaml parsing and merging
    addresses huggingface#1733

    * lowercase trlparser

commit 2d244f8
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Mon Jun 17 11:56:13 2024 +0200

    Workflow: Notify tests results on slack channel (huggingface#1744)

    * Update tests-main.yml

    * Update docker-build.yml

commit f5168fd
Author: Igor Melnyk <igoraries@gmail.com>
Date:   Wed Jun 12 05:54:54 2024 -0400

    adds AOT (huggingface#1701)

    * adds AOT

    * Applied format changes

    * added docs and tests

    ---------

    Co-authored-by: Igor Melnyk <igor.melnyk@ibm.com>

commit 79686e1
Author: jetlime <paul.houssel@yahoo.de>
Date:   Wed Jun 12 00:35:31 2024 +1000

    ktotrainer: Refuse datasets which contain only one class of labels (huggingface#1724)

    * ktotrainer: refuse dataset which contain only one class of labels

    * ktotrainer: document new dataset constraint

commit 34ebc4c
Author: Luc Georges <McPatate@users.noreply.github.com>
Date:   Mon Jun 10 11:17:54 2024 +0200

    feat(ci): add trufflehog secrets detection (huggingface#1721)

    * feat(ci): add trufflehog secrets detection

    * fix(ci): remove unnecessary permissions

commit 1d84e2b
Author: Michael <mnoukhov@gmail.com>
Date:   Fri Jun 7 11:42:08 2024 +0200

    Fix default padding_value in dpo_config.py (huggingface#1692)

    dpo_config default padding value should be None, not 0, otherwise it by default overrides the padding value of any tokenizer to 0

commit 2f71b8b
Author: Michael <mnoukhov@gmail.com>
Date:   Fri Jun 7 10:37:27 2024 +0200

    fix yaml parser for derived config classes (huggingface#1713)

    fixes huggingface#1712
    reformatted cli_utils with ruff

commit 5bcb8ad
Author: Kashif Rasul <kashif.rasul@gmail.com>
Date:   Fri Jun 7 08:48:17 2024 +0100

    RDPO fix nll loss (huggingface#1705)

commit b8b972f
Author: Haoran Xu <45837851+fe1ixxu@users.noreply.github.com>
Date:   Thu Jun 6 14:06:47 2024 -0700

    Add a variant of CPO, SimPO (huggingface#1703)

    * add a variant of cpo: simpo

    * correct cpo-simpo loss

    * avoid 0 int error in logging

    * add simpo description

    * Update trl/trainer/cpo_trainer.py

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * fix formatting

    * add test for simpo

    * Update docs/source/cpo_trainer.mdx

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    * add a docstring for simpogamma

    * move simpo description to the above docstring

    * change simpo description in the doc

    * formatting

    ---------

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

commit 3eb9ccb
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Thu Jun 6 19:33:20 2024 +0200

    set dev version (huggingface#1710)

    * Update setup.py

    * Update __init__.py

commit 974b0d3
Author: Costa Huang <costa.huang@outlook.com>
Date:   Thu Jun 6 10:13:00 2024 -0400

    0.9.4 release (huggingface#1708)

commit 39a7d1c
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Thu Jun 6 15:50:17 2024 +0200

    SFTTrainer: Fix backward Compatibility issue with `TrainingArguments` (huggingface#1707)

    * fix BC

    * fixup

commit 0bdc638
Author: Guilherme Freire <guilhermebfreire@gmail.com>
Date:   Thu Jun 6 14:42:58 2024 +0100

    Fixed doc string and docs for the SFTConfig update (huggingface#1706)

commit 275d33b
Author: Costa Huang <costa.huang@outlook.com>
Date:   Wed Jun 5 14:34:59 2024 -0400

    0.9.3 release (huggingface#1699)

commit c0819ee
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Wed Jun 5 17:29:03 2024 +0200

    Update sft_trainer.py (huggingface#1698)

commit a03e7cc
Author: Costa Huang <costa.huang@outlook.com>
Date:   Wed Jun 5 11:00:19 2024 -0400

    Release 0.9.2 (huggingface#1697)

    * Release: 0.9.0

    * Release

commit a13cb89
Author: Costa Huang <costa.huang@outlook.com>
Date:   Wed Jun 5 10:20:54 2024 -0400

    Quick fix on GPT4-eval (huggingface#1696)

    * quick fix

    * precommit

commit 84156f1
Author: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Date:   Mon Jun 3 20:09:05 2024 +0200

    Fix typo in DPOTrainer's warnings (huggingface#1688)

commit 4eb0b90
Author: Alex Brooks <alex.brooks@ibm.com>
Date:   Mon Jun 3 10:24:32 2024 -0600

    Skip packing validation (huggingface#1673)

    * Add test for skipping preproc if packing=True

    Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>

    * Allow skipping of validation for packing=True

    Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>

    * Use dummy dataset in no packing preproc test

    Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>

    ---------

    Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>

commit 6c203f9
Author: Alexey Rozhkov <alexisrozhkov@gmail.com>
Date:   Mon Jun 3 10:16:22 2024 +0100

    Fix overriding optimize_device_cache with optimize_cuda_cache in PPOConfig (huggingface#1690)

    * Don't override optimize_device_cache when optimize_cuda_cache is not provided
    Raise an exception when both optimize_cuda_cache and optimize_device_cache are set

    * Minor fix

commit f18253b
Author: Kashif Rasul <kashif.rasul@gmail.com>
Date:   Mon Jun 3 09:43:02 2024 +0100

    intial RPO loss (huggingface#1686)

    * intial RPO loss

    * fix sign

    * clean up

commit 151a452
Author: Samuel <s.kiegeland@gmx.de>
Date:   Wed May 29 20:29:38 2024 +0200

    Fix max completion length (huggingface#1588)

commit 488b502
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Wed May 29 20:19:26 2024 +0200

    fix (huggingface#1678)

commit 3c0a10b
Author: Wang, Yi <yi.a.wang@intel.com>
Date:   Mon May 27 20:52:20 2024 +0800

    fix dataset load error (huggingface#1670)

    Signed-off-by: Wang, Yi <yi.a.wang@intel.com>

commit b031adf
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Fri May 24 15:20:16 2024 +0200

    FIX / PPO: Fix `enable_input_require_grads` issues with PPO models (huggingface#1664)

    * Update modeling_base.py

    * Update ppo_config.py

    * Update ppo_trainer.py

    * style

commit e7cb597
Author: Costa Huang <costa.huang@outlook.com>
Date:   Thu May 23 11:37:16 2024 -0400

    Fix ppov2 test case (huggingface#1661)

    * Fix PPOv2 / RLOO refactor's stuff

    * update terminology to use stop token

commit bc8dfbf
Author: Kashif Rasul <kashif.rasul@gmail.com>
Date:   Thu May 23 15:28:04 2024 +0200

    update eval_strategy (huggingface#1662)

commit e4ed7a3
Author: Sourab Mangrulkar <13534540+pacman100@users.noreply.github.com>
Date:   Thu May 23 18:34:22 2024 +0530

    do not upcast adapters when using FSDP+QLoRA (huggingface#1654)

commit 9a7efbd
Author: syrn1k <85796210+syrn1k@users.noreply.github.com>
Date:   Thu May 23 15:58:49 2024 +0300

    🤫 TR-DPO implementation (huggingface#1593)

    * 🤫 TR-DPO implementation baseline

    * fix comments

    * docs

    * fix linters

    * test added

    * move configs to DPOConfig

    * fix typo

    * add docs

    * fix import

    * use state.global_step

    * fix order of arguments

    * make sure plugins are not none

    * Update trl/trainer/utils.py

    Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>

    * Update trl/trainer/utils.py

    Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>

    * checking that reference model weights have changed

    * sync_target_model as staticmethod

    * set reference model

    ---------

    Co-authored-by: Nikita Surnachev <n.surnachev@tinkoff.ru>
    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>
    Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>

commit b344bce
Author: Anush Kini <33577829+Abilityguy@users.noreply.github.com>
Date:   Thu May 23 18:27:25 2024 +0530

    [DPO] Add 'robust' loss_type (huggingface#1653)

    * Initial commit

    * pre-commit fix

    * Minor change to comments

    * Added some documentation on how to use Robust DPO

commit 35e12dc
Author: Nicolinho <Nicolinho@users.noreply.github.com>
Date:   Thu May 23 14:36:15 2024 +0200

    Fix inheritance order in PPOv2Config (huggingface#1659)

    * fix inheritance order in PPOv2Config

    * fix inheritance order in rloo_config

commit 1da6be1
Author: Ali Bakly <anbakly@gmail.com>
Date:   Thu May 23 14:10:29 2024 +0200

    docs: correct cDPO usage in DPOTrainer (huggingface#1655)

commit e249cd8
Author: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Date:   Thu May 23 14:10:05 2024 +0200

    add support for training collator (huggingface#1658)

commit a02513c
Author: Zach Mueller <muellerzr@gmail.com>
Date:   Thu May 23 06:48:00 2024 -0400

    Apply deprecated `evaluation_strategy` (huggingface#1559)

    * Deprecate

    * Update tests/test_dpo_trainer.py

    ---------

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

commit 13454d2
Author: Costa Huang <costa.huang@outlook.com>
Date:   Wed May 22 08:31:10 2024 -0400

    PPO / Reinforce Trainers (huggingface#1540)

    * Add ppov2 trainer

    * make eos trick optional, remove unused args

    * quick fix

    * precommit

    * update debugging script

    * fix out of bound `drop_last=True`; use built-in scheduler

    * Add PPO examples

    * push changes

    * quick change

    * quick change

    * various bug fixes

    * remove unnecessary grad accumulation setting

    * push new changes

    * fix DS3 model saving

    * update ppo.py

    * refactor

    * quick change

    * refactor

    * update ppo trainer

    * refactor

    * quick test

    * add ds2 /ds3 7 processes config

    * add vllm trainer

    * quick change

    * experiment with reward normalization

    * push changes

    * quick push

    * push changes

    * push various changes

    * refactor to use ModelConfig

    * quick change

    * refactor

    * refactor

    * Simplify DS logic

    * quick update

    * remove unnecessary files

    * precommit

    * deepspeed fix; handle edge case when eos_token_id = 0

    * add PPO tldr example

    * add TL;DR example

    * fix undefined var

    * utilize all samples in rloo

    * quick setting

    * remove the unnecessary `value_model`

    * use exact_div

    * allow saving the deepspeed model

    * refactor

    * remove dead code

    * Use some shared utilities

    * add some end-to-end test cases

    * add PPOv2 docs and RLOO docs / tests

    * update docs

    * quikc push

    * fix ci

    * fix type annotation for ci

    * quick update

    * update trainer docs

commit 99f2c94
Author: Sourab Mangrulkar <13534540+pacman100@users.noreply.github.com>
Date:   Wed May 15 19:55:46 2024 +0530

    don't cast the trainable lora layers to half precision (huggingface#1644)

    * don't cast the trainable lora layers to half precision

    * quality

commit 6401d08
Author: Wing Lian <wing.lian@gmail.com>
Date:   Tue May 14 09:41:07 2024 -0400

    Pairwise Noise Contrastive Alignment (huggingface#1632)

    * add NCA paired preference loss

    * chore: lint

    * set more lenient tolerance for integration tests

    * Update tests/test_dpo_trainer.py

    * skip test

    * fix

    ---------

    Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
    Co-authored-by: younesbelkada <younesbelkada@gmail.com>

commit d632a5b
Author: bartoszzuk <57541034+bartoszzuk@users.noreply.github.com>
Date:   Tue May 14 12:25:54 2024 +0200

    Fixed wrong logs prefixes in KTOTrainer (huggingface#1641)

    * Fixed wrong logs prefixes in KTOTrainer

    * Pre-commit formating

commit 5aeb752
Author: Tiezhen WANG <38108242+xianbaoqian@users.noreply.github.com>
Date:   Fri May 10 23:19:15 2024 +0800

    Update sft_llama2.py to work with the latest API (huggingface#1637)

    * Update sft_llama2.py to work with the latest API

    SFTTrainer now takes a STFConfig argument

    * Update dpo_llama2.py

    * precommit

commit b8b8978
Author: Ilya Gusev <phoenixilya@gmail.com>
Date:   Fri May 10 15:43:13 2024 +0200

    [ORPO] Correct label mask for pad tokens (huggingface#1625)

    * [ORPO] Correct label mask for pad tokens

    Recent [fix](huggingface/trl@57aebe9) for calculating NLL loss for a whole sequence introduced a bug. When input_ids are copied to labels, pad tokens are not masked.

    This PR aims to path this by masking labels based on the attention mask.

    * -100 -> label_pad_token_id

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

    ---------

    Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>

commit 8799952
Author: Costa Huang <costa.huang@outlook.com>
Date:   Fri May 10 09:32:20 2024 -0400

    visualize rm prediction (huggingface#1636)

    * visualize rm prediction

    * quick update

    * quick check

    * quick fix

    * update eval steps

commit 3b4c249
Author: Xiao Yu <39458711+jasonyux@users.noreply.github.com>
Date:   Fri May 3 18:19:35 2024 -0400

    fixed adding bos and eos token unconditionally (huggingface#1591)

    * fixed adding bos and eos token unconditionally

    * fixed typo of tokenizer -> self.tokenizer. Also added update to ORPO

    * fixed code quality, and added BOS/EOS fix to KTO

    * code reformatting with pre-commit run --all-files

    * bug fix: check input id length before checking for EOS/BOS

commit 0347f58
Author: lewtun <lewis.c.tunstall@gmail.com>
Date:   Fri May 3 15:59:59 2024 +0200

    Fix ZeRO-3 generation context manager (huggingface#1617)

* judge refactoring and unittest

* format

* init

* doc

* format

* improve doc

* basejudge

* improve doc and add BaseAPIJudge

* Doc

* style

* refactor callback

* remove openai and pairrm judge from test

* doc

* rm dpo online example

* new prompts and completions

* skip hf judge and add hf token

---------

Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
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