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

[Forkless SparseML Transformers] [Feature Branch] Setting Up The modification module #2046

Closed
wants to merge 21 commits into from

Conversation

dbogunowicz
Copy link
Contributor

@dbogunowicz dbogunowicz commented Feb 8, 2024

Summary

This pull request addresses the removal of the dependency on nm-transformers in favor of the original HF transformers. The primary motivation for this change is to simplify maintenance by eliminating the challenges associated with keeping a fork.

The scope of this PR was defined by running a diff between nm-transformers and transformers and identifying the elements that need to be included in sparseml to account for the differences.

For more details refer to the appropriate documentation in the internal docs repository.

Changes made:

  • adding a dependency on "transformers<4.37", removing the dependency on our fork
  • creating src/sparseml/transformers/sparsify/modification submodule, that is responsible for modifying the transformers models, as the fork did in the past
  • moving the appropriate scripts from sparseml.transformers.utils to sparseml.transformers.sparsification
  • updating the source code to support the new transformers version (e.g. accounting for renaming SiLUActivation to SiLU
  • adding exhaustive, new unit tests
  • fixed the issue of failing transformers test in GHA. Refactored and optimized the tests.

Manual Testing

Tested both Mistral and LlaMa on our end-to-end flows:

  1. Sparsification (one shot + sparse fine-tuning + quantization)
  2. Loading the sparsified model and inference
  3. Export of the sparsified model

Tested a single BERT QA recipe:

  1. Run the sparse fine-tuning
  2. Export the model

Note manual testing asserts that the pathways are working. The testing did not check the correctness of the resulting models.

Relevant PRs:

:param model: The original HuggingFace transformers model
:return: The potentially modified model
"""
model_name = model.__class__.__name__
Copy link
Contributor

Choose a reason for hiding this comment

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

consider using the classes themselves as keys instead of name

@dbogunowicz dbogunowicz changed the base branch from main to investigation/damian/open_files March 5, 2024 16:27
@dbogunowicz dbogunowicz changed the base branch from investigation/damian/open_files to main March 5, 2024 16:27
dbogunowicz and others added 15 commits March 11, 2024 13:06
…2047)

* working demo

* beautification

* [Forkless SparseML Transformers] [Feature Branch] Modding LLaMa (#2050)
* working demo

* beautification

* initial commit

* initial commit

* Fix typing mistakes

* [Forkless SparseML Transformers] [Feature Branch] Modding DistilBert(#2052)

* [Forkless SparseML Transformers] [Feature Branch] Modding `Bert` (#2054)

* initial commit

* initial commit

* [Forkless SparseML Transformers] [Feature Branch] Modding MobileBert (#2056)

* [Forkless SparseML Transformers] Hardening unit tests (#2088)

* initial commit

* bring back the original file

* initial commit
working on transformers tests (fixing out of space error) 2

working on transformers tests (fixing out of space error) 3

working on transformers tests (fixing out of space error) 4

fixing tests...

disable test_consecutive_runs

fix mistral

update integration tests
@dbogunowicz dbogunowicz force-pushed the feature/damian/forkless_transformer_feature branch from 9d47ad0 to fcb04a6 Compare March 11, 2024 12:08
setup.py Outdated Show resolved Hide resolved
@dbogunowicz dbogunowicz requested a review from bfineran March 11, 2024 19:25
@dbogunowicz
Copy link
Contributor Author

Closing, this PR is replaced by #2199 and #2204

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