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

Unit tests #83

Merged
merged 17 commits into from
Mar 12, 2024
Merged

Conversation

tharapalanivel
Copy link
Collaborator

@tharapalanivel tharapalanivel commented Mar 7, 2024

Description of the change

Adding unit tests for pt and lora tuning method using dummy model, edge cases, invalid requests, etc.

Cont. of PR #79

Related issue number

Closes #74

How to verify the PR

Was the PR tested

  • I have added >=1 unit test(s) for every new method I have added.
  • I have ensured all unit tests pass

tharapalanivel and others added 11 commits March 7, 2024 09:48
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Anh-Uong <anh.uong@ibm.com>
@Ssukriti
Copy link
Collaborator

Ssukriti commented Mar 8, 2024

This PR looks good to me. Before we add edge cases, @tharapalanivel can we also add a unit test for fine tuning? there will not be any peft type associated with it
We can also merge the PR once ft is added and reviewed with the status at the time. Any other edge cases can go in subsequent PRs as well

requirements.txt Outdated
@@ -1,7 +1,7 @@
numpy
accelerate>=0.20.3
packaging
transformers>=4.34.1
transformers>=4.34.1,<4.38.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

#53 is merged so you shouldnt need this cap, thanks

Copy link
Collaborator

@tedhtchang tedhtchang Mar 11, 2024

Choose a reason for hiding this comment

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

@Ssukriti Should we keep the cap(or a static version) for the transformers package avoid un intended errors like xla_fsdp_v2. We could create github workflow to run tests and then update the cap regularly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we dont need to keep static version , but yes in optional dependencies PR , @gkumbhat is looking into how to cap and we may cap to next major release. Now that CI/CD with automatically pull new release versions , if we see failing builds, we will update accordingly
the errors we were seeing with xla_fsdp_v2 was actually due to code we wrote , which was good to catch and fix . It was not a API change from transformers, but we were setting env variables incorrectly

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general if there is a specific version that doesn't work, or has a bug ,then we can also ask pip to ignore that particular version.

#54 (comment)

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
@tharapalanivel tharapalanivel marked this pull request as ready for review March 11, 2024 20:41
Copy link
Collaborator

@Ssukriti Ssukriti left a comment

Choose a reason for hiding this comment

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

I think some more tests can be i:

  1. if num_epocs and num_gradient_acc steps is 0 , valueerror is returned
  2. prompt tuning test can test with "prompt_tuning_init": "RANDOM", and TEXT (only Random is tested)

tests/test_sft_trainer.py Outdated Show resolved Hide resolved
tests/test_sft_trainer.py Outdated Show resolved Hide resolved
assert "Simply put, the theory of relativity states that" in output_inference


def test_run_train_lora_target_modules():
Copy link
Collaborator

Choose a reason for hiding this comment

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

whats the difference between this and above test? can we combine to 1?

Copy link
Collaborator Author

@tharapalanivel tharapalanivel Mar 12, 2024

Choose a reason for hiding this comment

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

My understanding is that first we check that default target modules are used, then the next one is for custom target modules specified by user and the last for all-linear. I've parameterized it but worth confirming with Anh.

tests/test_sft_trainer.py Outdated Show resolved Hide resolved
tests/test_sft_trainer.py Show resolved Hide resolved
Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
@@ -0,0 +1,22 @@
# Copyright The IBM Tuning Team
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious about the copyright notice..Where is this coming from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IBM Tuning Team was suggested by Raghu, the rest is from caikit

invalid_params
)

with pytest.raises(ValueError, match=exc_msg):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I generally avoid matching exact error message and just check for valueError with a comment explaining why, but will let this go and I dont think we will update the message much

Copy link
Collaborator

@Ssukriti Ssukriti left a comment

Choose a reason for hiding this comment

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

Thanks so much!!

@Ssukriti Ssukriti merged commit a716cd7 into foundation-model-stack:main Mar 12, 2024
3 checks passed
jbusche pushed a commit to jbusche/fms-hf-tuning that referenced this pull request Mar 25, 2024
* Set up fixtures and data for tests

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Add basic unit tests

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Setting upper bound for transformers

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Ignore aim log files

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Include int num_train_epochs

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Fix formatting

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Add copyright notice

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Address review comments

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Run inference on tuned model

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Trainer downloads model

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* add more unit tests and refactor

Signed-off-by: Anh-Uong <anh.uong@ibm.com>

* Fix formatting

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Add FT unit test and refactor

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Removing transformers upper bound cap

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Address review comments

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

---------

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Anh-Uong <anh.uong@ibm.com>
Co-authored-by: Anh-Uong <anh.uong@ibm.com>
anhuong added a commit to anhuong/fms-hf-tuning that referenced this pull request Apr 3, 2024
* Set up fixtures and data for tests

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Add basic unit tests

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Setting upper bound for transformers

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Ignore aim log files

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Include int num_train_epochs

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Fix formatting

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Add copyright notice

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Address review comments

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Run inference on tuned model

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Trainer downloads model

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* add more unit tests and refactor

Signed-off-by: Anh-Uong <anh.uong@ibm.com>

* Fix formatting

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Add FT unit test and refactor

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Removing transformers upper bound cap

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

* Address review comments

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>

---------

Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com>
Signed-off-by: Anh-Uong <anh.uong@ibm.com>
Co-authored-by: Anh-Uong <anh.uong@ibm.com>
@tharapalanivel tharapalanivel deleted the unit_tests2 branch April 9, 2024 20:44
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.

Add unit tests for tuning/sft_trainer.py
5 participants