fix(workflow-operator): send provider-specific model id on HF text-gen chat fallback routes - #6972
Conversation
…-inference route in HF text-gen chat fallback
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6972 +/- ##
============================================
- Coverage 79.56% 79.56% -0.01%
+ Complexity 3834 3833 -1
============================================
Files 1159 1159
Lines 46145 46145
Branches 5127 5127
============================================
- Hits 36716 36714 -2
- Misses 7799 7800 +1
- Partials 1630 1631 +1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 372 | 0.227 | 26,188/34,663/34,663 us | 🔴 +16.1% / 🔴 +119.6% |
| 🟢 | bs=100 sw=10 sl=64 | 789 | 0.482 | 124,391/153,189/153,189 us | 🟢 -12.2% / 🔴 +38.9% |
| ⚪ | bs=1000 sw=10 sl=64 | 907 | 0.554 | 1,102,793/1,208,642/1,208,642 us | ⚪ within ±5% / 🔴 +14.5% |
Baseline details
Latest main b98faf4 from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 372 tuples/sec | 410 tuples/sec | 771.62 tuples/sec | -9.3% | -51.8% |
| bs=10 sw=10 sl=64 | MB/s | 0.227 MB/s | 0.25 MB/s | 0.471 MB/s | -9.2% | -51.8% |
| bs=10 sw=10 sl=64 | p50 | 26,188 us | 22,564 us | 12,626 us | +16.1% | +107.4% |
| bs=10 sw=10 sl=64 | p95 | 34,663 us | 38,570 us | 15,786 us | -10.1% | +119.6% |
| bs=10 sw=10 sl=64 | p99 | 34,663 us | 38,570 us | 19,344 us | -10.1% | +79.2% |
| bs=100 sw=10 sl=64 | throughput | 789 tuples/sec | 793 tuples/sec | 971.56 tuples/sec | -0.5% | -18.8% |
| bs=100 sw=10 sl=64 | MB/s | 0.482 MB/s | 0.484 MB/s | 0.593 MB/s | -0.4% | -18.7% |
| bs=100 sw=10 sl=64 | p50 | 124,391 us | 120,980 us | 103,463 us | +2.8% | +20.2% |
| bs=100 sw=10 sl=64 | p95 | 153,189 us | 174,409 us | 110,296 us | -12.2% | +38.9% |
| bs=100 sw=10 sl=64 | p99 | 153,189 us | 174,409 us | 118,690 us | -12.2% | +29.1% |
| bs=1000 sw=10 sl=64 | throughput | 907 tuples/sec | 904 tuples/sec | 1,001 tuples/sec | +0.3% | -9.4% |
| bs=1000 sw=10 sl=64 | MB/s | 0.554 MB/s | 0.552 MB/s | 0.611 MB/s | +0.4% | -9.4% |
| bs=1000 sw=10 sl=64 | p50 | 1,102,793 us | 1,102,398 us | 1,008,988 us | +0.0% | +9.3% |
| bs=1000 sw=10 sl=64 | p95 | 1,208,642 us | 1,168,181 us | 1,055,260 us | +3.5% | +14.5% |
| bs=1000 sw=10 sl=64 | p99 | 1,208,642 us | 1,168,181 us | 1,074,689 us | +3.5% | +12.5% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,538.01,200,128000,372,0.227,26188.19,34663.17,34663.17
1,100,10,64,20,2535.11,2000,1280000,789,0.482,124390.92,153188.56,153188.56
2,1000,10,64,20,22039.34,20000,12800000,907,0.554,1102792.62,1208642.29,1208642.29|
@carloea2 I think the need to programmatically test operators becomes higher... There are more and more efforts on editing operators logic. It will be good to have the tests in CI soon. |
|
I am working on it, I will raise a discussion about it soon. |
|
/request-review @xuang7 |
|
@xuang7 github merge bot removed the pr from merge queue, requesting to add this pr to merge queue again. Thanks! |
…odegenBase for clarity (apache#7143) ### What changes were proposed in this PR? Pure internal rename: `PythonCodegenBase` -> `HuggingFaceCodegenBase` (object, file, and spec). Despite the generic name, this object is HF-specific, it lives in `.../huggingFace/codegen/`, is used only there, and is the shared base of the Hugging Face per-task `TaskCodegen`s. The old name led a reviewer to ask whether the HF logic belonged elsewhere (comment on apache#6972); the new name matches the sibling codegens and `HuggingFaceInferenceOpDesc`. Also updated the references in `HuggingFaceInferenceOpDesc.scala`, `ImageTaskCodegen.scala`, and `TaskCodegen.scala`. Behavior-neutral: no change to the generated Python, workflow JSON, or any public API; git tracks both files as renames. ### Any related issues, documentation, discussions? Closes apache#7140 Follow-up to the review discussion on apache#6972. ### How was this PR tested? No new tests as this is a rename, and existing coverage confirms it's behavior-neutral. sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.huggingFace.*" The full HF package passes (124 tests), including `PythonCodeRawInvalidTextSpec`, which py-compiles the generated Python of all 117 operators — confirming the generated output is unchanged. scalafmt clean. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.7 in compliance with ASF.
What changes were proposed in this PR?
Fixes two related bugs in the HuggingFace inference operator's provider-fallback loop (
_post_with_fallbackin the generated Python, emitted byPythonCodegenBase.scala) that break thetext-generation/image-text-to-textpath, which is the operator's default task.Wrong model id on provider-scoped chat routes. The chat branch posted the same payload, carrying
"model": self.MODEL_ID(the HF Hub ID), to every provider's route (router.huggingface.co/{provider}/...). Provider-scoped routes require the provider's own model name (providerId, e.g. the Hub'sQwen/Qwen2.5-72B-Instructis a different string on Groq or Fireworks), which_resolve_providersalready fetches and_call_provideralready uses for the other task families. Providers whose internal name differs from the Hub ID rejected every request with 400/404, so fallback only succeeded when the names happened to match. The chat branch now posts a per-attempt copy with the model overridden:chat_payload = {**pipeline_payload, "model": provider_id}
(a copy, not in-place mutation, pipeline_payload is reused for the next provider
attempt).
Malformed hf-inference chat URL. The chat URL for hf-inference was built as
hf-inference/v1/chat/completions, but hf-inference expects the model in the URL path:hf-inference/models/{model-id}/v1/chat/completions(the form this file already uses for pipeline tasks). Since hf-inference sorts first inPROVIDER_COST_PRIORITY, the cheapest provider failed on every row, wasting a doomed request (up to the 120 s timeout) per row before falling through.Net effect: text-gen rows now succeed on the cheapest live provider instead of failing with "All inference providers failed" or silently drifting to pricier providers. No behavior change for other task families -
_call_provideralready handled them correctly.Any related issues, documentation, discussions?
Closes #6965
How was this PR tested?
Added a generated-code test to HuggingFaceInferenceOpDescSpec ("send the provider-specific model id on provider-scoped chat routes") pinning both fixes: the corrected hf-inference chat URL, and the chat branch posting the per-provider payload copy (asserted as an anchored two-line block so pipeline routes that legitimately post pipeline_payload directly stay unaffected).
Run:
sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.huggingFace.*"
Full HF package passes (123 tests, 12 suites), including PythonCodeRawInvalidTextSpec, which py_compiles the generated Python of all 117 Python operators, verifying the edited template still emits syntactically valid Python. scalafmt clean.
Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Fable 5 in compliance with ASF.