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

Huggingface model wrapper update #2300

Merged

Conversation

GiulioZizzo
Copy link
Collaborator

Description

Currently, the HF estimator expects a HF model that is on the cpu: if a user moves the model to the GPU before giving it to the estimator there will be a crash to to a mismatch between the tensors created for the forward hooks in the HF model wrapper and the model. This small update ensures that the correct device is used between model and hook inputs.

Fixes # TO CREATE

Type of change

Please check all relevant options.

  • Improvement (non-breaking)
  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing

As the CI tests are CPU limited we have tested this via updating the notebook to shift the models to GPU devices in a few places before feeding to the estimator.

Test Configuration:

  • OS: Linux and Mac
  • Python version: 3.9
  • ART version or commit number: 1.16
  • TensorFlow / Keras / PyTorch / MXNet version: torch 2.0

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My changes have been tested using both CPU and GPU devices

Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2023

Codecov Report

Merging #2300 (e896821) into dev_1.17.0 (ab389e7) will decrease coverage by 1.76%.
Report is 4 commits behind head on dev_1.17.0.
The diff coverage is 0.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.17.0    #2300      +/-   ##
==============================================
- Coverage       85.60%   83.84%   -1.76%     
==============================================
  Files             324      324              
  Lines           29326    29982     +656     
  Branches         5407     5538     +131     
==============================================
+ Hits            25104    25138      +34     
- Misses           2840     3448     +608     
- Partials         1382     1396      +14     
Files Coverage Δ
art/estimators/classification/hugging_face.py 90.59% <0.00%> (-2.39%) ⬇️

... and 7 files with indirect coverage changes

@beat-buesser beat-buesser self-assigned this Oct 10, 2023
@beat-buesser beat-buesser self-requested a review October 10, 2023 08:38
@beat-buesser beat-buesser added bug Something isn't working improvement Improve implementation labels Oct 10, 2023
@GiulioZizzo GiulioZizzo mentioned this pull request Nov 21, 2023
13 tasks
@beat-buesser beat-buesser added this to the ART 1.17.0 milestone Nov 30, 2023
@beat-buesser beat-buesser changed the base branch from main to dev_1.17.0 November 30, 2023 16:49
Copy link
Collaborator

@beat-buesser beat-buesser left a comment

Choose a reason for hiding this comment

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

Hi @GiulioZizzo Thank you very much for your pull request! Looks good to me.

@beat-buesser beat-buesser merged commit dec5ddf into Trusted-AI:dev_1.17.0 Dec 14, 2023
35 checks passed
@beat-buesser beat-buesser added this to Pull request done in ART 1.17.0 Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working improvement Improve implementation
Projects
No open projects
ART 1.17.0
Pull request done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants