|
4 | 4 | import ray |
5 | 5 |
|
6 | 6 | from graphgen.bases import BaseLLMWrapper |
7 | | -from graphgen.common.init_storage import get_actor_handle |
8 | 7 | from graphgen.models import Tokenizer |
9 | 8 |
|
10 | 9 |
|
@@ -74,9 +73,9 @@ class LLMServiceProxy(BaseLLMWrapper): |
74 | 73 | A proxy class to interact with the LLMServiceActor for distributed LLM operations. |
75 | 74 | """ |
76 | 75 |
|
77 | | - def __init__(self, actor_name: str): |
| 76 | + def __init__(self, actor_handle: ray.actor.ActorHandle): |
78 | 77 | super().__init__() |
79 | | - self.actor_handle = get_actor_handle(actor_name) |
| 78 | + self.actor_handle = actor_handle |
80 | 79 | self._create_local_tokenizer() |
81 | 80 |
|
82 | 81 | async def generate_answer( |
@@ -128,25 +127,25 @@ def create_llm( |
128 | 127 |
|
129 | 128 | actor_name = f"Actor_LLM_{model_type}" |
130 | 129 | try: |
131 | | - ray.get_actor(actor_name) |
| 130 | + actor_handle = ray.get_actor(actor_name) |
| 131 | + print(f"Using existing Ray actor: {actor_name}") |
132 | 132 | except ValueError: |
133 | 133 | print(f"Creating Ray actor for LLM {model_type} with backend {backend}.") |
134 | 134 | num_gpus = float(config.pop("num_gpus", 0)) |
135 | | - actor = ( |
| 135 | + actor_handle = ( |
136 | 136 | ray.remote(LLMServiceActor) |
137 | 137 | .options( |
138 | 138 | name=actor_name, |
139 | 139 | num_gpus=num_gpus, |
140 | | - lifetime="detached", |
141 | 140 | get_if_exists=True, |
142 | 141 | ) |
143 | 142 | .remote(backend, config) |
144 | 143 | ) |
145 | 144 |
|
146 | 145 | # wait for actor to be ready |
147 | | - ray.get(actor.ready.remote()) |
| 146 | + ray.get(actor_handle.ready.remote()) |
148 | 147 |
|
149 | | - return LLMServiceProxy(actor_name) |
| 148 | + return LLMServiceProxy(actor_handle) |
150 | 149 |
|
151 | 150 |
|
152 | 151 | def _load_env_group(prefix: str) -> Dict[str, Any]: |
|
0 commit comments