Skip to content

[Train] Add ControllerError for the errors thrown from the controller#54633

Closed
xinyuangui2 wants to merge 1 commit intoray-project:masterfrom
xinyuangui2:add-scheduling-training-error
Closed

[Train] Add ControllerError for the errors thrown from the controller#54633
xinyuangui2 wants to merge 1 commit intoray-project:masterfrom
xinyuangui2:add-scheduling-training-error

Conversation

@xinyuangui2
Copy link
Copy Markdown
Contributor

@xinyuangui2 xinyuangui2 commented Jul 15, 2025

Why are these changes needed?

We are supporting to use FailurePolicy to handle the scheduling exception. And this requires we refactor the TrainingFailedError firstly.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@xinyuangui2 xinyuangui2 requested a review from justinvyu July 15, 2025 19:06
@xinyuangui2 xinyuangui2 requested a review from a team as a code owner July 15, 2025 19:06
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @xinyuangui2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a more granular exception hierarchy for training failures within Ray Train's API. By refactoring the generic TrainingFailedError into a base class and creating distinct WorkerTrainingFailedError and SchedulingTrainingFailedError subclasses, it provides clearer distinction between different failure modes. This change is crucial for enabling more sophisticated error handling mechanisms, particularly for future FailurePolicy implementations that can specifically address scheduling-related exceptions during training.

Highlights

  • Exception Hierarchy Refactoring: The existing TrainingFailedError has been refactored from a concrete exception into a base class for more specific training failure types. Its __init__ method was simplified to only accept an error message.
  • New Worker-Specific Exception: A new exception, WorkerTrainingFailedError, has been introduced. This class now specifically encapsulates training failures that originate from issues with individual workers, inheriting from TrainingFailedError and retaining the worker_failures attribute.
  • New Scheduling-Specific Exception: A new exception, SchedulingTrainingFailedError, has been added. This class, also inheriting from TrainingFailedError, is designed to specifically represent and handle training failures that occur due to underlying scheduling issues, including a scheduling_error attribute.
  • Enabling Future Features: This refactoring is a foundational step to enable the implementation of a FailurePolicy that can intelligently handle and respond to scheduling exceptions during the training process, as stated in the PR description.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors TrainingFailedError into a base class with two specific subclasses, WorkerTrainingFailedError and SchedulingTrainingFailedError. There are potential serialization issues in the __init__ methods of the new exception classes that could cause issues with pickling and unpickling. I've left specific comments with suggestions on how to fix this.

@xinyuangui2 xinyuangui2 requested a review from matthewdeng July 21, 2025 18:52
@xinyuangui2 xinyuangui2 changed the title [Train] Split the TrainingFailedError into WorkerTrainingFailedError and SchedulingTrainingFailedError [Train] Add ControllerError for the errors thrown from the controller Jul 21, 2025
@xinyuangui2 xinyuangui2 force-pushed the add-scheduling-training-error branch from 20ab5de to d46d39d Compare July 21, 2025 22:57
@xinyuangui2
Copy link
Copy Markdown
Contributor Author

Moved to #54801

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