Skip to content

Commit d20b08d

Browse files
committed
auto setup cluster on dlc
1 parent 423f9dc commit d20b08d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/agentscope/tuner/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def to_trinity_config(
109109
config.buffer.batch_size = algorithm.batch_size
110110
config.trainer.save_interval = algorithm.save_interval_steps
111111
config.explorer.eval_interval = algorithm.eval_interval_steps
112-
return config.check_and_update()
112+
return config
113113

114114

115115
def check_workflow_function(

src/agentscope/tuner/_tune.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""The main entry point for agent learning."""
3+
import os
34
from ._workflow import WorkflowType
45
from ._judge import JudgeType
56
from ._model import TunerChatModel
@@ -48,6 +49,7 @@ def tune(
4849
"""
4950
try:
5051
from trinity.cli.launcher import run_stage
52+
from trinity.utils.dlc_utils import setup_ray_cluster, stop_ray_cluster
5153
except ImportError as e:
5254
raise ImportError(
5355
"Trinity-RFT is not installed. Please install it with "
@@ -69,7 +71,13 @@ def tune(
6971
algorithm=algorithm,
7072
experiment_name=experiment_name,
7173
)
72-
73-
return run_stage(
74-
config=config,
75-
)
74+
use_dlc = os.environ.get("USE_ALIYUN_PAI_DLC", "0") == "1"
75+
if use_dlc:
76+
setup_ray_cluster(config, namespace="agentscope")
77+
try:
78+
return run_stage(
79+
config=config.check_and_update(),
80+
)
81+
finally:
82+
if use_dlc:
83+
stop_ray_cluster(namespace="agentscope")

0 commit comments

Comments
 (0)