Skip to content

Add Feature-Extractor-Plugin: Spark expression fusion (batch) and Flink GPU operators (streaming) - #540

Merged
shijieliu merged 3 commits into
NVIDIA:mainfrom
cb521:fea-feature-extractor-plugin
Nov 10, 2026
Merged

shijieliu merged 3 commits into
NVIDIA:mainfrom
cb521:fea-feature-extractor-plugin

Conversation

@cb521

@cb521 cb521 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Description

Adds examples/Feature-Extractor-Plugin/ with two independent parts. English and Chinese docs for both.

batch (Spark): an add-on for spark-rapids that fuses chains of row-independent expressions into one generated GPU kernel, with results bit-identical to spark-rapids. Separate jar; spark-rapids is not modified. Includes the plugin source, build and self-test scripts, five KuaiRand cases with real plans, and a reproduction guide.

streaming (Flink): a small Flink GPU operator library (window aggregation and bounded INNER lookup join) that a job calls explicitly from DataStream code, with no planner override. Includes the native CUDA/JNI layer, two example jobs, qualification and profiling tools, six KuaiRand benchmark cases with real plans, and a one-command rebuild of the research plugin Mega-Flink at a pinned commit so all six cases can be rerun. The README compares the approach with other Flink acceleration projects and explains when to use the CPU or the GPU.

Only files under examples/Feature-Extractor-Plugin/ are added, plus one word (ForSt, a Flink state backend name) in the codespell ignore list of .pre-commit-config.yaml.

Verification

  • Library: 63 unit tests pass without a GPU. Tools: self-test passes.
  • On one NVIDIA L20 (sm_89, CUDA 12.4): the native layer builds and its self-test passes; the final result tables of the library's window aggregation (HOP one- and two-phase, TUMBLE) and lookup join match the CPU runs by SHA-256, and GPU kernel launches were counted.
  • With the pinned Mega-Flink build, all six benchmark cases match between CPU and GPU on a small slice.
  • pre-commit hooks (isort, autoflake, codespell, black, mypy) pass on the added Python files.
  • Not verified: other GPUs (Hopper is only compiled), multi-GPU, clusters, Kafka, other datasets; no independent review of the benchmark numbers. See streaming/docs/LIMITS.md.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

binc-maker and others added 2 commits November 8, 2026 13:30
…usion)

An add-on for spark-rapids that fuses chains of row-independent expressions
into one generated GPU kernel, with results bit-identical to spark-rapids.
Includes the plugin source, build and self-test scripts, design notes and
limits, the KuaiRand benchmark cases with real plans and a reproduction
guide, and English and Chinese README with figures.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: binc <[email protected]>
…ators)

A small Flink GPU operator library (window aggregation and bounded INNER
lookup join) that a job calls explicitly, with its native CUDA/JNI layer,
qualification and profiling tools, example jobs, the six KuaiRand benchmark
cases with real plans, a one-command Mega-Flink build at a pinned commit for
reproduction, and design, limits and how-it-works docs. README compares the
approach with other Flink acceleration projects and explains when to use the
CPU or the GPU. English and Chinese.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: binc <[email protected]>
…-plugin

Signed-off-by: binc <[email protected]>

# Conflicts:
#	.pre-commit-config.yaml
@cb521
cb521 marked this pull request as ready for review November 10, 2026 11:51
@shijieliu
shijieliu merged commit b085012 into NVIDIA:main Nov 10, 2026
1 check passed
@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The new GPU paths affect workloads that choose to install or call them.

Fix the lost CASE nulls and the false-success test runner before merging.

Findings

  1. P1 CASE loses NULL results ▶
  2. P1 Failed tests look successful ▶

Summary

Adds independent Spark and Flink GPU examples:

  • Spark fuses supported expressions into one GPU kernel.
  • Flink DataStream jobs can call GPU window and lookup operators.
  • Operators can inspect Flink jobs and reproduce GPU comparisons.
  • Codespell accepts the Flink backend name ForSt.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  S[Spark GPU expressions] --> T[Translate supported expressions]
  T --> K[Generate and compile CUDA kernel]
  K --> R[Run fused expression]
  K --> F[Original expression on failure]
  D[Flink DataStream] --> W[GPU window partials]
  W --> M[Merge into keyed window state]
  D --> L[Bounded dimension lookup]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment on lines +16 to +19
def createsNulls(c: Call): Boolean = c.op match {
case "div" | "idiv" | "rem" | "pmod" | "log" | "logbase" => true
case "inset" => c.attr.lastOption.contains(java.lang.Boolean.TRUE) // NULL when not found and the list contains NULL
case _ => false

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.

P1 CASE loses NULL results

createsNulls misses casewhen without an ELSE. For example, CASE WHEN a > 0 THEN b WHEN a < 0 THEN c END must return NULL when a = 0. When the input columns have no null masks, selfNull stays false and FusionRuntime.run allocates no output null mask. The kernel's placeholder zero then becomes a non-null result, which can also change later counts and calculations.

Mark casewhen without an ELSE as able to create nulls, and add a test with null-free inputs.

Comment on lines +19 to +24
./gpu-run.sh ${PART:+-p $PART} -t 03:00:00 -- bash -c "
python3 fz/directed.py --out $OUT/directed --modes $MODES > $OUT/directed.log 2>&1;
fz/fuzz_loop.sh --data $DATA --out $OUT/fuzz --cases $CASES --seed $SEED --modes $MODES --time-limit 5400 > $OUT/fuzz.log 2>&1;
[ -f udf/udfs.jar ] || udf/build.sh > $OUT/udf-build.log 2>&1;
python3 udf/coverage.py --data $DATA --out $OUT/coverage.json --modes $MODES > $OUT/coverage.log 2>&1"
PYTHONPATH=${PYLIB_DIR:-} python3 fz/report.py $OUT; rc=$?

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.

P1 Failed tests look successful

run-all.sh can exit successfully when the tests never ran. Commands inside bash -c ignore earlier failures, and the status from gpu-run.sh is discarded before report.py runs. If the GPU allocation fails, or Spark fails before writing results, report.py skips the missing files and exits zero.

Preserve the test commands' failure status and require the expected reports before declaring success.

shijieliu added a commit to shijieliu/recsys-examples that referenced this pull request Nov 12, 2026
Merge main up to 476cdc0: NVIDIA#544 and NVIDIA#547 in DynamicEmb; NVIDIA#535, NVIDIA#537,
NVIDIA#539 and NVIDIA#540 outside it.

- NVIDIA#544 deduplicates int32 keys as int64 in _dedup_indices and returns
  them in the input's dtype, as this branch did. The merge keeps main's
  widening (indices_64bit) and drops this branch's copy of it, so the
  keys are widened once. It keeps this branch's structure: a sharding on
  the hierarchical dist keeps its unique keys sized on the device, and
  TorchRec's dists slice them to the count. The docstring says both.
- NVIDIA#544 also bucketizes an int32 key as the int64 key of its value. The
  hierarchical dist's own bucketize still reads a key in its own width;
  the next commit gives it int32 keys as int64.
- DynamicEmb_APIs.md: main's paragraph on how the rules read a key, then
  this branch's line that the hierarchical dist takes roundrobin and
  hash_roundrobin only.
- test_sequence_embedding_fw.py and test_twin_module.py: main's int32
  runs (NVIDIA#544) and no-grad forward (NVIDIA#547), with this branch's checks that
  a sharding took the dist it was given (check_path, check_totals).
- NVIDIA#547 (a no-grad training forward releases its slot pins, after
  refreshing its slots past a rehash) merges without conflicts next to
  this branch's row map and load_from_flat_by.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants