Skip to content

Commit 3e733de

Browse files
committed
simplify launch
1 parent e7f5a76 commit 3e733de

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/forge/controller/actor.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async def set_env(self, addr: str, port: str):
154154
os.environ["MASTER_PORT"] = port
155155

156156
@classmethod
157-
async def launch(cls, *, process_config: ProcessConfig, **kwargs) -> "ForgeActor":
157+
async def launch(cls, **kwargs) -> "ForgeActor":
158158
"""Provisions and deploys a new actor.
159159
160160
This method is used by `Service` to provision a new replica.
@@ -167,7 +167,13 @@ async def launch(cls, *, process_config: ProcessConfig, **kwargs) -> "ForgeActor
167167
a homogeneous set of actors on a single proc mesh.
168168
169169
"""
170-
proc_mesh = await get_proc_mesh(process_config=process_config)
170+
# Build process config from class attributes with defaults
171+
cfg = ProcessConfig(
172+
procs=getattr(cls, "procs", 1),
173+
hosts=getattr(cls, "hosts", None),
174+
with_gpus=getattr(cls, "with_gpus", False),
175+
)
176+
proc_mesh = await get_proc_mesh(process_config=cfg)
171177

172178
# TODO - expand support so name can stick within kwargs
173179
actor_name = kwargs.pop("name", cls.__name__)
@@ -189,11 +195,8 @@ async def as_actor(cls: Type[T], **actor_kwargs) -> T:
189195
`procs`) are used to construct a ProcessConfig instance.
190196
If no configuration was stored, defaults to a single process with no GPU.
191197
"""
192-
class_attrs = {k: v for k, v in cls.__dict__.items() if not k.startswith("__")}
193-
cfg = ProcessConfig(**filter_config_params(ProcessConfig, class_attrs))
194-
195198
logger.info("Spawning single actor %s", cls.__name__)
196-
actor = await cls.launch(process_config=cfg, **actor_kwargs)
199+
actor = await cls.launch(**actor_kwargs)
197200

198201
# Patch shutdown to bypass endpoint system
199202
actor.shutdown = types.MethodType(

0 commit comments

Comments
 (0)