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

Make tokenize tests readable #1868

Merged
merged 12 commits into from
Nov 18, 2024
Merged

Make tokenize tests readable #1868

merged 12 commits into from
Nov 18, 2024

Conversation

krammnic
Copy link
Contributor

Context

What is the purpose of this PR? Is it to

  • add a new feature
  • fix a bug
  • update tests and/or documentation
  • clean up

Please link to any issues this PR addresses.

Changelog

What are the changes made in this PR?

Test plan

Please make sure to do each of the following if applicable to your PR. If you're unsure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.

  • run pre-commit hooks and linters (make sure you've first installed via pre-commit install)
  • add unit tests for any new functionality
  • update docstrings for any new or updated methods or classes
  • run unit tests via pytest tests
  • run recipe tests via pytest tests -m integration_test
  • manually run any new or modified recipes with sufficient proof of correctness
  • include relevant commands and any other artifacts in this summary (pastes of loss curves, eval results, etc.)

UX

If your function changed a public API, please add a dummy example of what the user experience will look like when calling it.
Here is a docstring example
and a tutorial example

  • I did not change any public API
  • I have added an example to docs or docstrings

Will require changes in CI(pre-commit run makes expected_tokens lists unreadable)

Copy link

pytorch-bot bot commented Oct 19, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/1868

Note: Links to docs will display an error until the docs builds have been completed.

❗ 2 Active SEVs

There are 2 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit cc60b25 with merge base d5c54f3 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 19, 2024
@krammnic
Copy link
Contributor Author

cc: @RdoubleA @joecummings What do you think? With current lint formatting working with this tests is really awful. Pretty minor fix

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 24.77%. Comparing base (d0aa871) to head (cc60b25).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/torchtune/models/llama3/test_llama3_tokenizer.py 0.00% 6 Missing ⚠️
...s/torchtune/models/llama2/test_llama2_tokenizer.py 60.00% 2 Missing ⚠️
...torchtune/models/mistral/test_mistral_tokenizer.py 66.66% 2 Missing ⚠️
tests/torchtune/models/phi3/test_phi3_tokenizer.py 66.66% 2 Missing ⚠️
...sts/torchtune/models/qwen2/test_qwen2_tokenizer.py 0.00% 2 Missing ⚠️
...sts/torchtune/models/gemma/test_gemma_tokenizer.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1868       +/-   ##
===========================================
- Coverage   67.27%   24.77%   -42.50%     
===========================================
  Files         318      318               
  Lines       17648    17633       -15     
===========================================
- Hits        11873     4369     -7504     
- Misses       5775    13264     +7489     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@krammnic
Copy link
Contributor Author

krammnic commented Oct 20, 2024

Lint CI at this point should be changed, if not the formating will be still really bad in case of expected_tokens

Copy link
Contributor

@joecummings joecummings left a comment

Choose a reason for hiding this comment

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

Looks good - I will look into the linter issue. My naive assumption was that noqa should work.

Couple questions about possibly unintended formatting errors

messages = [
Message(
role="user",
content="Below is an instruction that describes a task. Write a response "
"that appropriately completes the request.\n\n### Instruction:\nGenerate "
"a realistic dating profile bio.\n\n### Response:\n",
"that appropriately completes the request.\n\n### Instruction:\nGenerate "
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or, something change from my local linter changes probably, will fix

@@ -311,21 +147,17 @@ def test_tokenizer_vocab_size(self, tokenizer):
assert tokenizer.vocab_size == 128257

def test_tokenize_text_messages(
self, tokenizer, user_text_message, assistant_text_message
self, tokenizer, user_text_message, assistant_text_message
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same is here

@krammnic
Copy link
Contributor Author

I assume that fixed

@joecummings
Copy link
Contributor

I assume that fixed

Grr still failing. Mind if I take a look?

@krammnic
Copy link
Contributor Author

Isn't it about lines with # noqa?

@krammnic
Copy link
Contributor Author

Ah, I see:
tests/torchtune/models/llama3/test_llama3_tokenizer.py:226:183: B950 line too long (182 > 120 characters)

@krammnic
Copy link
Contributor Author

Fixed

@krammnic
Copy link
Contributor Author

One more...

@krammnic
Copy link
Contributor Author

fixed with flake

@krammnic
Copy link
Contributor Author

@joecummings Sorry for such lint failures, but I could not able to run pre-commit run --all-files due to current fixes

@krammnic
Copy link
Contributor Author

@joecummings Probably I found solution we need to use both # noqa and # fmt: skip. But I really don't like it

@krammnic
Copy link
Contributor Author

Oh, I broke something...

@krammnic
Copy link
Contributor Author

I don't know what is it, this tests are passing on my local and branch is up to date

@krammnic
Copy link
Contributor Author

Isn't it related too #1886? Some weird fail with torchao

@krammnic
Copy link
Contributor Author

Can we restart CI here? Or I'm not sure how to fix some torchao unrelated stuff

@krammnic
Copy link
Contributor Author

@felipemello1 @RdoubleA Maybe you can comment how to fix this torchao thing? Really strange and probably just CI rerun can't help

@RdoubleA
Copy link
Contributor

@krammnic have you merged from main after this PR was checked in? #1886

@krammnic
Copy link
Contributor Author

@krammnic have you merged from main after this PR was checked in? #1886

Oh, I see. Let me merge it, yes.

@krammnic
Copy link
Contributor Author

Fixed

@krammnic
Copy link
Contributor Author

Can someone restart CI?

@krammnic
Copy link
Contributor Author

resolved

@krammnic
Copy link
Contributor Author

krammnic commented Nov 5, 2024

@RdoubleA Can we fix Qwen2 and Qwen2.5 tests in separate PR? I will open it immediately after we merge this without other models

@RdoubleA
Copy link
Contributor

@krammnic Sorry for the delay, that sounds good to me. Looks like we just need to resolve merge conflicts and we can land this.

@RdoubleA RdoubleA merged commit f31754f into pytorch:main Nov 18, 2024
17 checks passed
@RdoubleA
Copy link
Contributor

@krammnic Went ahead and did the merge with main, thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants