Skip to content

[DPOTrainer] Fix DPO trainer + mistral + FA2#1290

Merged
kashif merged 1 commit into
mainfrom
fix-dpo-fa2
Jan 30, 2024
Merged

[DPOTrainer] Fix DPO trainer + mistral + FA2#1290
kashif merged 1 commit into
mainfrom
fix-dpo-fa2

Conversation

@younesbelkada

@younesbelkada younesbelkada commented Jan 30, 2024

Copy link
Copy Markdown
Contributor

Fixes: #1217
Fixes: huggingface/transformers#26877
Fixes: #1266

Simply setting use_cache=False circumvents all issues with FA-2 + DPO + Mistral. in fact we should bypass that check since we are not in text generation mode when computing the loss function. use_cache is retrieved from the model config by default which falls back always to True. The cache is not used anyway when purely computing the logits so this change is fully BC

cc @kashif @vwxyzjn

To test that, I managed to repro the issue by adding --attn_implementation "flash_attention_2" in the dpo shell script on a A100 machine, and I confirm this PR fixes it. Unfortunately our CI runners are not compatible with FA2 so we cannot add a slow test to test that

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@kashif

kashif commented Jan 30, 2024

Copy link
Copy Markdown
Collaborator

thank you great help!

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.

Padding bug in Mixtral modeling code when running DPO Padding side incorrect for Mistral DPO Mistral with flash attention 2 and right padding

3 participants