Skip to content

[SPARK-62498][CONNECT][PYTHON] Delegate standard LDA operations to Rust - #1003

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

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

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Delegate standard pyspark.ml.clustering.LDA to the existing Rust ML API. Python setters synchronize parameters eagerly. The standard and compatibility imports expose the same estimator and model classes.

The online optimizer returns a LocalLDAModel. EM returns a DistributedLDAModel, whose toLocal() caches the converted model. Both concrete classes now accept a PySpark RemoteModelRef through the shared model constructor. When Rust receives a model from the server, it binds the reference after the Python constructor finishes. This preserves the reference across copies and lazy transforms.

Why are the changes needed?

The standard estimator previously built fit, transform and persistence requests in Python. Delegating these operations lets standard PySpark LDA tests exercise the implementation used by Rust callers and follows the other migrated clustering estimators. SPARK-62498

Does this PR introduce any user-facing change?

The public imports, class hierarchy and method signatures match PySpark 4.3.0. Existing LDA estimators and models saved by either client can be loaded by the other. The change adds no Python dependencies.

How was this patch tested?

  • Ran both optimizers on a local Spark 4.3.0 Connect server with the Python ML request builders disabled. Covered topic matrices, topic distributions (including an empty document), likelihood, cached toLocal(), save/load and a lazy transform collected after releasing the model.
  • Saved estimators and models with official PySpark and loaded them with the Rust-backed client, then repeated in the other direction. Compared topic matrices and per-document probabilities. Reloading an EM model introduces small variations in Spark's inference step, also observed between official PySpark loads.
  • Ran seven upstream ML suites in drop-in mode (clustering, classification, regression, model offloading, model cache, pipelines and tuning). 58 tests passed and 4 were skipped. All public signatures and member kinds matched PySpark 4.3.0 for the estimator and three model classes.
  • Ran the offline ML tests (1,577 passed), type-stub tests (21 passed), 864 Rust library tests, and the live and golden Rust clustering suites. Compiled all Rust integration tests with and without wasm-udf and ran formatting, Clippy, Ruff, generated-stub and vendor-drift checks.

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-lda-rust branch December 1, 2026 06:46
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