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

Fix evaluation code to improve performance #2421

Open
vigneshwaran opened this issue Aug 10, 2023 · 4 comments · May be fixed by #2428
Open

Fix evaluation code to improve performance #2421

vigneshwaran opened this issue Aug 10, 2023 · 4 comments · May be fixed by #2428

Comments

@vigneshwaran
Copy link

I have been experiencing llm-foundry/eval takes a lot of time compared to lm-evaluation-harness. After digging into the code, I found padding token is appended till the maximum length of the tokenizer.

inp, continuation_span = _make_padded_input(context_enc, continuation_enc, self.max_seq_len,
                                                        self.pad_tok_id)

https://github.com/bmosaicml/composer/blob/1011f90f2653dae103c3837c968071e399b1decc/composer/datasets/in_context_learning_evaluation.py#L418C1-L428C59

My proposal:

Instead of padding till max_seq_len, use the maximum length of the batch.

inp, continuation_span = _make_padded_input(context_enc, continuation_enc, max_len_of_data,
                                                        self.pad_tok_id)

This has improved latency by 400% when I used 2048 as sequence length. It would be even more for models trained with higher sequence length.

@eracah
Copy link
Contributor

eracah commented Aug 10, 2023

Hi, @vigneshwaran, thanks for discovering this! please make a pull request with your changes!

@mvpatel2000
Copy link
Contributor

Great find! If you can open a PR, we'd love to accept it :)

@vigneshwaran
Copy link
Author

I have proposed my MR #2428
@eracah @mvpatel2000

@vigneshwaran
Copy link
Author

vigneshwaran commented Aug 17, 2023

In test script, batch is always expected to have fixed size of (batch_size, max_seq_len)

assert tuple(batch['input_ids'].shape) == (batch_size, seqlen)

Test error:

image

So, we need to update test files.

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 a pull request may close this issue.

3 participants