Skip to content

Conversation

@ChenZiHong-Gavin
Copy link
Collaborator

This PR fixes detached Ray actor lifecycle issues and improves environment variable handling in the GraphGen framework.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ChenZiHong-Gavin, 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 focuses on enhancing the stability and reliability of the GraphGen framework by addressing critical issues related to Ray actor lifecycle management and environment variable propagation. It refines how Ray actors are created and interacted with, centralizes environment configuration for distributed tasks, and integrates LLM actor management directly into the core Engine class. These changes collectively aim to prevent actor-related errors and ensure consistent execution environments.

Highlights

  • Ray Actor Lifecycle Fix: The lifetime="detached" option has been removed during Ray actor creation, specifically for LLM service actors. This change directly addresses and fixes issues related to the lifecycle management of detached Ray actors, ensuring they are properly managed and cleaned up.
  • Streamlined LLMServiceProxy Initialization: The LLMServiceProxy class now directly accepts a ray.actor.ActorHandle during its initialization, rather than an actor name. This simplifies the proxy's interaction with the underlying Ray actor and removes an unnecessary lookup step.
  • Centralized Environment Variable Handling: Environment variable loading and propagation have been centralized within graphgen/engine.py. All os.environ variables are now explicitly copied and merged into Ray's runtime_env, ensuring consistent environment settings across all Ray workers and preventing potential configuration discrepancies.
  • Engine-Managed LLM Actor Initialization: The Engine class now takes responsibility for initializing and managing key LLM actors (specifically 'synthesizer' and 'trainee'). These actors are created and their handles stored within the Engine instance, improving overall actor management and accessibility.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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
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 introduces several valuable improvements. It addresses Ray actor lifecycle management by removing the lifetime="detached" option for LLM actors, which is a good move for ensuring they are properly cleaned up with the driver process. The changes to LLMServiceProxy to accept an actor handle directly is a nice application of dependency injection. The environment variable handling is also made more robust by explicitly passing them to the Ray runtime environment, ensuring workers have the correct context. I've added a couple of comments regarding logging consistency and a potentially unused/incomplete feature for LLM actor initialization. Overall, these are solid changes that improve the stability and maintainability of the framework.

Comment on lines +58 to +60
def _init_llms(self):
self.llm_actors["synthesizer"] = init_llm("synthesizer")
self.llm_actors["trainee"] = init_llm("trainee")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The _init_llms method initializes self.llm_actors, but this attribute is not used anywhere else in the Engine class. This appears to be either dead code or part of an incomplete feature. If it's not used, it should be removed to avoid confusion and unnecessary initialization of LLM actors, which can be resource-intensive. If it is intended for use by operators, it should be passed to them, for example via a shared context.

Additionally, the LLM types synthesizer and trainee are hardcoded. This is inflexible. A better approach would be to derive the required LLM types from the configuration, for instance by inspecting the nodes in the graph for LLM requirements.

Comment on lines +131 to 133
print(f"Using existing Ray actor: {actor_name}")
except ValueError:
print(f"Creating Ray actor for LLM {model_type} with backend {backend}.")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with logging across the project, it's better to use the configured logger instead of print(). This provides benefits like log levels, timestamps, and consistent formatting. You could import logger from graphgen.utils and replace the print calls with logger.info().

@ChenZiHong-Gavin ChenZiHong-Gavin merged commit c69483b into main Dec 22, 2025
4 checks passed
@ChenZiHong-Gavin ChenZiHong-Gavin deleted the fix/fix-detached-actors branch December 22, 2025 08:11
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.

2 participants