Skip to content

[RunInference] Pass the device to a custom inference_fn in HuggingFaceModelHandlerTensor - #41086

Merged
jrmccluskey merged 4 commits into
apache:masterfrom
sohailshk:fix/hf-tensor-inference-fn-device
Nov 11, 2026
Merged

jrmccluskey merged 4 commits into
apache:masterfrom
sohailshk:fix/hf-tensor-inference-fn-device

Conversation

@sohailshk

Copy link
Copy Markdown
Contributor

Fixes #41085

HuggingFaceModelHandlerTensor.run_inference called a custom inference_fn with (batch, model, inference_args, inference_args, model_id). TensorInferenceFn is (batch, model, device, inference_args, model_id) and the keyed handler already passes self._device, so custom functions received the inference_args dict as device. This passes self._device.

Added a regression test whose inference_fn records the device and inference_args it receives. It fails on master ({'add': True} != 'CPU') and passes with the fix; huggingface_inference_test.py: 20 passed. yapf and ruff are clean on the touched files. CHANGES.md updated.

R: @jrmccluskey

@github-actions github-actions Bot added python size/s S: 10-49 lines changed labels Nov 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR fixes a bug in HuggingFaceModelHandlerTensor.run_inference where inference_args was passed twice instead of passing self._device as the third argument to custom inference_fn callbacks. The change aligns the implementation with the TensorInferenceFn signature and HuggingFaceModelHandlerKeyedTensor, and includes a regression unit test.

🔍 General Feedback

  • The fix is clean, minimal, and well-tested.
  • CHANGES.md is appropriately updated.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label python.
Backup reviewer: damccorm (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

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).

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.54%. Comparing base (0a963fc) to head (5510d5d).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #41086      +/-   ##
============================================
- Coverage     59.25%   58.54%   -0.71%     
+ Complexity     4894     2277    -2617     
============================================
  Files          1461     1132     -329     
  Lines        186046   169707   -16339     
  Branches       3648     1485    -2163     
============================================
- Hits         110244    99362   -10882     
+ Misses        72445    67801    -4644     
+ Partials       3357     2544     -813     
Flag Coverage Δ
python 80.54% <ø> (-0.23%) ⬇️

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.

@jrmccluskey jrmccluskey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@jrmccluskey
jrmccluskey merged commit efc23d0 into apache:master Nov 11, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: HuggingFaceModelHandlerTensor passes inference_args instead of device to a custom inference_fn

2 participants