Skip to content

fix(workflow-operator): carry structured task context into chat fallback payloads - #7798

Merged
xuang7 merged 1 commit into
apache:mainfrom
PG1204:fix/hf-structured-fallback-payload
Aug 24, 2026
Merged

fix(workflow-operator): carry structured task context into chat fallback payloads#7798
xuang7 merged 1 commit into
apache:mainfrom
PG1204:fix/hf-structured-fallback-payload

Conversation

@PG1204

@PG1204 PG1204 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

The five structured Hugging Face tasks (question-answering, table-question-answering, zero-shot-classification, sentence-similarity, text-ranking) build a native HF pipeline payload that only hf-inference understands. When the operator fell back to a third-party chat-completions provider, all three chat branches sent just the prompt cell, dropping the
context, table, candidate labels, or sentence list, so the model answered without the input that defines the task.

This adds a _chat_content_for_task helper to the generated operator that reformulates each of the five tasks into a chat prompt carrying its full context, and routes all three chat branches (zai-org, OpenAI-compatible, unknown-provider fallback) through it. Other tasks pass through unchanged. QaRankingCodegen.parsePython is also extended to read choices[0].message.content from chat responses, keeping the native {"answer": ...} shape as the primary path, the same idiom ImageTaskCodegen already uses.

Any related issues?

Closes #7195

How was this PR tested?

131 tests pass in the WorkflowOperator Hugging Face suites, PythonCodeRawInvalidTextSpec py-compiles the generated Python for all 117 operators, and scalafmtCheck is clean for main and test sources. A new spec test asserts the helper is emitted and used by every chat branch, with one assertion per task reformulation; two existing tests were updated where they pinned the old parse expression.

Was this PR authored or co-authored using generative AI tooling?

Yes, this PR was co-authored with Claude in compliance with ASF policy.

@github-actions

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. release/* labels drive the post-merge backport, so add or remove one to change where this fix lands.

Release branch Analysis
⚠️ release/v1.2 Not labeled automatically — none of the files this PR modifies exist on this branch (common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/HuggingFaceCodegenBase.scala, common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/QaRankingCodegen.scala, common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDescSpec.scala, common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/codegen/QaRankingCodegenSpec.scala). The fix may target code that isn't on this release, or the files were moved/renamed after the branch was cut. Please check and add release/v1.2 by hand if this fix should be backported here.

Auto-label run.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @anishshiva7, @Ma77Ball
    You can notify them by mentioning @anishshiva7, @Ma77Ball in a comment.

@PG1204

PG1204 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @xuang7

@github-actions
github-actions Bot requested a review from xuang7 August 19, 2026 23:18
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 2 better · 🔴 5 worse · ⚪ 8 noise (<±5%) · 0 without baseline

Compared against main 5f95b67 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 373 0.228 28,239/33,413/33,413 us 🔴 +37.4% / 🔴 +121.5%
🔴 bs=100 sw=10 sl=64 784 0.478 125,397/170,879/170,879 us 🔴 +23.8% / 🔴 +60.0%
bs=1000 sw=10 sl=64 920 0.562 1,087,072/1,123,787/1,123,787 us ⚪ within ±5% / 🔴 +11.9%
Baseline details

Latest main 5f95b67 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 373 tuples/sec 401 tuples/sec 771.02 tuples/sec -7.0% -51.6%
bs=10 sw=10 sl=64 MB/s 0.228 MB/s 0.245 MB/s 0.471 MB/s -6.9% -51.6%
bs=10 sw=10 sl=64 p50 28,239 us 20,558 us 12,749 us +37.4% +121.5%
bs=10 sw=10 sl=64 p95 33,413 us 45,932 us 15,594 us -27.3% +114.3%
bs=10 sw=10 sl=64 p99 33,413 us 45,932 us 19,320 us -27.3% +72.9%
bs=100 sw=10 sl=64 throughput 784 tuples/sec 821 tuples/sec 997.05 tuples/sec -4.5% -21.4%
bs=100 sw=10 sl=64 MB/s 0.478 MB/s 0.501 MB/s 0.609 MB/s -4.6% -21.5%
bs=100 sw=10 sl=64 p50 125,397 us 121,250 us 100,339 us +3.4% +25.0%
bs=100 sw=10 sl=64 p95 170,879 us 138,030 us 106,781 us +23.8% +60.0%
bs=100 sw=10 sl=64 p99 170,879 us 138,030 us 113,101 us +23.8% +51.1%
bs=1000 sw=10 sl=64 throughput 920 tuples/sec 926 tuples/sec 1,037 tuples/sec -0.6% -11.3%
bs=1000 sw=10 sl=64 MB/s 0.562 MB/s 0.565 MB/s 0.633 MB/s -0.5% -11.2%
bs=1000 sw=10 sl=64 p50 1,087,072 us 1,080,533 us 971,388 us +0.6% +11.9%
bs=1000 sw=10 sl=64 p95 1,123,787 us 1,133,336 us 1,013,249 us -0.8% +10.9%
bs=1000 sw=10 sl=64 p99 1,123,787 us 1,133,336 us 1,039,879 us -0.8% +8.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,536.55,200,128000,373,0.228,28238.77,33412.94,33412.94
1,100,10,64,20,2552.64,2000,1280000,784,0.478,125396.95,170879.27,170879.27
2,1000,10,64,20,21728.44,20000,12800000,920,0.562,1087071.84,1123787.12,1123787.12

@xuang7 xuang7 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

@xuang7
xuang7 added this pull request to the merge queue Aug 24, 2026
Merged via the queue into apache:main with commit 2113455 Aug 24, 2026
34 checks passed
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.

HuggingFace inference operator: QA/ranking payloads drop their context/labels/sentences on fallback providers

2 participants