fix(workflow-operator): read chat-provider responses for the image question-answering tasks - #7920
fix(workflow-operator): read chat-provider responses for the image question-answering tasks#7920PG1204 wants to merge 1 commit into
Conversation
…estion-answering tasks
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7920 +/- ##
============================================
+ Coverage 92.43% 92.46% +0.03%
- Complexity 4590 4605 +15
============================================
Files 1173 1173
Lines 47347 47355 +8
Branches 5306 5302 -4
============================================
+ Hits 43764 43787 +23
+ Misses 1995 1992 -3
+ Partials 1588 1576 -12
*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 | 428 | 0.261 | 22,685/29,605/29,605 us | 🟢 -12.7% / 🔴 +110.5% |
| ⚪ | bs=100 sw=10 sl=64 | 957 | 0.584 | 104,898/122,463/122,463 us | ⚪ within ±5% / 🔴 +26.9% |
| ⚪ | bs=1000 sw=10 sl=64 | 1,106 | 0.675 | 899,427/1,002,962/1,002,962 us | ⚪ within ±5% / 🔴 +7.8% |
Baseline details
Latest main 84e2d7d from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 428 tuples/sec | 443 tuples/sec | 863.81 tuples/sec | -3.4% | -50.5% |
| bs=10 sw=10 sl=64 | MB/s | 0.261 MB/s | 0.27 MB/s | 0.527 MB/s | -3.3% | -50.5% |
| bs=10 sw=10 sl=64 | p50 | 22,685 us | 21,558 us | 11,488 us | +5.2% | +97.5% |
| bs=10 sw=10 sl=64 | p95 | 29,605 us | 33,931 us | 14,067 us | -12.7% | +110.5% |
| bs=10 sw=10 sl=64 | p99 | 29,605 us | 33,931 us | 17,591 us | -12.7% | +68.3% |
| bs=100 sw=10 sl=64 | throughput | 957 tuples/sec | 948 tuples/sec | 1,127 tuples/sec | +0.9% | -15.1% |
| bs=100 sw=10 sl=64 | MB/s | 0.584 MB/s | 0.578 MB/s | 0.688 MB/s | +1.0% | -15.1% |
| bs=100 sw=10 sl=64 | p50 | 104,898 us | 103,445 us | 89,893 us | +1.4% | +16.7% |
| bs=100 sw=10 sl=64 | p95 | 122,463 us | 127,292 us | 96,506 us | -3.8% | +26.9% |
| bs=100 sw=10 sl=64 | p99 | 122,463 us | 127,292 us | 104,915 us | -3.8% | +16.7% |
| bs=1000 sw=10 sl=64 | throughput | 1,106 tuples/sec | 1,102 tuples/sec | 1,156 tuples/sec | +0.4% | -4.3% |
| bs=1000 sw=10 sl=64 | MB/s | 0.675 MB/s | 0.673 MB/s | 0.705 MB/s | +0.3% | -4.3% |
| bs=1000 sw=10 sl=64 | p50 | 899,427 us | 907,952 us | 886,448 us | -0.9% | +1.5% |
| bs=1000 sw=10 sl=64 | p95 | 1,002,962 us | 964,714 us | 930,093 us | +4.0% | +7.8% |
| bs=1000 sw=10 sl=64 | p99 | 1,002,962 us | 964,714 us | 963,104 us | +4.0% | +4.1% |
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,467.22,200,128000,428,0.261,22684.89,29605.43,29605.43
1,100,10,64,20,2089.66,2000,1280000,957,0.584,104898.01,122463.19,122463.19
2,1000,10,64,20,18090.76,20000,12800000,1106,0.675,899427.35,1002962.15,1002962.15
What changes were proposed in this PR?
When the operator falls back from
hf-inferenceto a third-party chat-completions provider, the reply comes back as{"choices": [{"message": {"content": ...}}]}. Three image tasks inImageTaskCodegen.parsePythoncould not read that shape, so a correct answer was written to the result column as a raw JSON envelope:visual-question-answeringanddocument-question-answeringreturnedbody.get("answer", json.dumps(body)), and a chat response has noanswerkey.zero-shot-image-classificationshared the image-only branch, which always returnsjson.dumps(body).Both now read
choices[0]["message"]["content"]when the body carrieschoices, keeping the nativehf-inferenceshape as the primary path.zero-shot-image-classificationgets its own branch, placed ahead of the image-only tasks because the generatedif/elifchain is first-match-wins. This is the same idiomimage-to-textandimage-text-to-textalready use in this file, and the one applied to the text tasks in #7798.image-classification,object-detectionandimage-segmentationare left as they are: they have no question to answer, so a free-text chat reply is not meaningful structured output for them.This is Part A of #7906 and covers the response side only. The request side which is carrying
candidate_labelsinto the chat message forzero-shot-image-classification, follows in Part B.Any related issues?
Addresses #7906
How was this PR tested?
133 tests pass in the
WorkflowOperatorHugging Face suites,PythonCodeRawInvalidTextSpecpy-compiles the generated Python for all 117 operators, andscalafmtCheckis clean for main and test sources. Two tests were added toImageTaskCodegenSpec: one asserts the visual/document question-answering branch readschoicesahead of the nativeanswerlookup, the other asserts the newzero-shot-image-classificationbranch exists and precedes the image-only branch.The emitted Python was also exercised directly: the three fixed tasks return the chat content, native
hf-inferenceresponses parse exactly as before, non-dict andanswer-less bodies still fall through tojson.dumps, and the untouched branches (image-classification,object-detection,image-segmentation,image-to-text,image-text-to-text) are unchanged.Was this PR authored or co-authored using generative AI tooling?
Yes, this PR was co-authored with Claude in compliance with ASF policy.