Skip to content

[SPARK-62503][CONNECT][PYTHON] Delegate standard ALS operations to Rust - #1007

Closed
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-als-rust
Closed

zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-als-rust

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Make from pyspark.ml.recommendation import ALS, ALSModel use the Rust client for fit, transform, rank, factor tables, recommendations and persistence. Python setters update the native parameters immediately, including both block counts set by setNumBlocks. The compatibility import aliases the same classes.

The Rust APIs and PyO3 now share the relation builder for factor tables and all four recommendation methods. A lazy result retains both the fitted model and any models used by its subset DataFrame. Python subclasses can still override _fit, _create_model and _copyValues. ALS and FPGrowth share the code that hands a fitted model reference to a custom factory.

The standard module loads its PySpark definitions from the byte-identical Spark 4.3.0 file at python/pyspark/ml/_upstream/recommendation.py.

Why are the changes needed?

ALS was already available in Rust, but standard Python callers still used upstream Python code to build the requests. Routing the standard import through Rust lets the upstream PySpark ALS tests exercise the implementation used by Rust callers. SPARK-62503

Does this PR introduce any user-facing change?

The public Python signatures, import paths and saved-model format are preserved. This change adds no Python dependency.

How was this patch tested?

  • Ran the official PySpark ALS, FPM, model offloading, cache, pipeline and tuning suites against the drop-in client. 31 tests passed and four were skipped.
  • Ran 31 local live Python tests, including recommendation arguments, model lifetime, custom factories and persistence. The routing test disabled the Python request builders while fitting, saving, loading and collecting predictions, factor tables and recommendations.
  • Exchanged saved estimators and models in both directions with official PySpark 4.3.0 for explicit and implicit feedback. For each loaded model, predictions, both factor tables and all four recommendation outputs matched in rows and exact schemas. The Rust-backed process ran with Python protobuf, gRPC, Py4J and optional ML packages blocked.
  • Compared public members and signatures for ALS (75) and ALSModel (40). Ran the standard and broader offline ML suites, Rust library and live ALS tests, and type checks. Compiled all Rust integration tests with and without wasm-udf. Checked formatting, Clippy, Ruff, generated stubs and vendored source.

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

Generated-by: OpenAI Codex (GPT-6)

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
@zhengruifeng
zhengruifeng deleted the feature/standard-als-rust branch December 1, 2026 10:01
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.

1 participant