Skip to content

Conversation

@dhyeyinf
Copy link
Contributor

Overview

This PR adds an example that demonstrates how to use Optuna's ask-and-tell interface with Apache Spark to distribute trial evaluations in parallel using PySpark's RDD API.

The script defines a simple quadratic objective function and evaluates it across Spark worker nodes. It shows how ask-and-tell can be used with a distributed engine without requiring integration with external orchestrators.

Motivation

The example is inspired by multiple user questions regarding Spark integration, as discussed in optuna/optuna#6077. While the functionality already exists via ask() and tell(), this example provides a hands-on script for users working with Spark.

Notes

  • This script is placed in the spark/ directory.
  • Includes fallback if PySpark is not installed.
  • Lightly formatted and runnable standalone (not Sphinx-bound).

Please let me know if you'd like the example adjusted further.

@dhyeyinf
Copy link
Contributor Author

Summary

  • ✅ Fixed isort import ordering in spark/ask_and_tell_spark.py
  • 📦 Added requirements.txt for the Spark ask-and-tell example

This ensures the example follows code style guidelines and includes required dependencies (optuna, pyspark) for easier execution.

Let me know if anything else should be added or refined!

Copy link
Contributor

@nabenabe0928 nabenabe0928 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot make your code work.
Could you please modify your code so that your code works without any modifications?
For example, an obvious bug is optuna.seed, which does not exist.

@dhyeyinf
Copy link
Contributor Author

Thanks for pointing that out! I've removed the invalid optuna.seed() line. The script now runs as-is with no modifications. Let me know if there’s anything else to adjust.

@dhyeyinf
Copy link
Contributor Author

dhyeyinf commented Jul 3, 2025

Hi @nabenabe0928, just following up on this PR — I made the changes you suggested a few days ago (removed the invalid optuna.seed() and ensured the script runs without any modifications). Please let me know if there's anything else you'd like me to address.

Appreciate your time and feedback! 🙇‍♂️

@github-actions
Copy link

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Jul 10, 2025
dhyeyinf and others added 2 commits July 14, 2025 11:31
@dhyeyinf
Copy link
Contributor Author

Thank you! I've applied your suggested changes

Copy link
Contributor

@nabenabe0928 nabenabe0928 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed one thing, could you please reduce the indents?
Please see my comment for more details.

@dhyeyinf
Copy link
Contributor Author

Thank you for catching that! I've committed the suggested indentation fix.

@github-actions github-actions bot removed the stale Exempt from stale bot labeling. label Jul 14, 2025
@github-actions
Copy link

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Jul 21, 2025
@dhyeyinf
Copy link
Contributor Author

Thank you for catching that! I've committed the suggested indentation fix.

@github-actions github-actions bot removed the stale Exempt from stale bot labeling. label Jul 22, 2025
@github-actions
Copy link

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Jul 29, 2025
Copy link
Contributor

@nabenabe0928 nabenabe0928 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response, LGTM!

@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Aug 1, 2025
@nabenabe0928 nabenabe0928 merged commit a2b06a4 into optuna:main Aug 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Exempt from stale bot labeling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants