Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for transformers>=4.40.2 to avoid crash with mbpp #244

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

meher-m
Copy link
Contributor

@meher-m meher-m commented Jun 11, 2024

Description

  • Since transformers 4.38, the library will raise an exception if max_length is set to a value that doesn't include the input size. This means that bigcode will fail when running mbpp with a max_length < 2048.
  • In the test split of mbpp, the largest tokenized prompt has length 1748. I verified that setting max_length = 2048 does succeed. However, this results in more than a 3x slow down in running the evaluation (from 1min 3secs to 3 min 30 seconds for 20 data points on 4 H100s).

Change

  • Added support to handle this exception if the length of input_ids equals the max_length.
  • Allows running mbpp with bigcode with much smaller values of max_length (512) and maintaining behavior consistent with transformers < 4.38.

Testing

Upgrading transformers package to version 4.40.2 and testing the following command succeeds.

accelerate launch main.py \
  --model ~/models/hf-code-llama-7b-instruct \
  --tasks mbpp \
  --max_length_generation 512 \
  --allow_code_execution \
  --precision bf16 \
  --do_sample False

Verify that the results of evaluation are the same as running mbpp before the package upgrade. Both provide results

"mbpp": {
    "pass@1": 0.388
}

Further, the below two files show the generations resulting from the above command before and after the package upgrade. Asserted that the generations were equivalent for each task_id.

@meher-m
Copy link
Contributor Author

meher-m commented Jun 17, 2024

cc @loubnabnl Please let me know what you think of this change!

Copy link
Collaborator

@loubnabnl loubnabnl left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the PR!

bigcode_eval/utils.py Outdated Show resolved Hide resolved
Update warning message for value error when len input==max_len

Co-authored-by: Loubna Ben Allal <[email protected]>
@meher-m
Copy link
Contributor Author

meher-m commented Jun 21, 2024

@loubnabnl Yes! I have added the change.

@loubnabnl loubnabnl merged commit 334efb7 into bigcode-project:main Jun 24, 2024
1 check passed
phuonglvh pushed a commit to phuonglvh/bigcode-evaluation-harness that referenced this pull request Nov 15, 2024
Adding support for transformers>=4.40.2 to avoid crash with mbpp
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.

2 participants