Skip to content

Modifies Hugging Face model handlers to not use ML packages... - #40541

Open
chamikaramj wants to merge 1 commit into
apache:masterfrom
chamikaramj:remove_tensorflow_submission
Open

chamikaramj wants to merge 1 commit into
apache:masterfrom
chamikaramj:remove_tensorflow_submission

Conversation

@chamikaramj

Copy link
Copy Markdown
Contributor

…during job submission.

Currently Hugging Face model handlers HuggingFaceModelHandlerTensor, HuggingFaceModelHandlerTensor and HuggingFaceModelHandlerKeyedTensor requires following packages to be available both during job submission and at workers.

  • torch
  • transformers
  • tensorflow

These packages and dependencies are extremely large. When installed via PyPI, the size for GPU versions of the packages are approximately:

Download size: 4 GB
Installed size: 8 GB

If we changed to use CPU versions of the packages the sizes are approximately.

Download size: 500 MB
Installed size: 2 GB

This change removes usage of the package for these model handlers from the job submission path so that these package do not have to be available during job submission. The packages just have to be available to workers during execution (for example, provided via a requirements file).

I ran following Dataflow pipeline to confirm that torch, transformers, sentence-transformers and tensorflow packages are not used during job submission.
These pipelines were run in a virtual environment without these packages and the packages were provided to runtime via a requirements.txt file.

https://console.cloud.google.com/dataflow/jobs/us-central1/2026-10-12_13_47_45-11445500235685626598?project=apache-beam-testing
https://console.cloud.google.com/dataflow/jobs/us-central1/2026-10-12_14_07_38-716179589100654307?project=apache-beam-testing

Similar previous change that removed the sentense-transformers package from job submission: #40439

Note that this also moves the secondary GPU availability check is_gpu_available_torch from the job submission to the runtime.

@chamikaramj

Copy link
Copy Markdown
Contributor Author

cc: @damccorm

@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.34%. Comparing base (76f6e6d) to head (193bfc3).
⚠️ Report is 139 commits behind head on master.

Files with missing lines Patch % Lines
.../apache_beam/ml/inference/huggingface_inference.py 63.33% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40541      +/-   ##
============================================
+ Coverage     56.16%   56.34%   +0.18%     
  Complexity     2288     2288              
============================================
  Files          1124     1124              
  Lines        178336   178407      +71     
  Branches       1489     1489              
============================================
+ Hits         100170   100532     +362     
+ Misses        75645    75354     -291     
  Partials       2521     2521              
Flag Coverage Δ
python 79.92% <63.33%> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @damccorm for label python.
R: @derrickaw for label yaml.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant