Skip to content

Commit 5130b11

Browse files
committed
delete unused functions
1 parent 08ba9ad commit 5130b11

File tree

5 files changed

+9
-218
lines changed

5 files changed

+9
-218
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ data/output_txt_files/
2828

2929
outputs/
3030
wandb/
31-
logs/
31+
logs/
32+
verl_checkpoints/
33+
verl.egg-info/

openmanus_rl/llm_agent/openmanus.py

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -174,95 +174,6 @@ def _batch_tokenize(self, responses: List[str]) -> torch.Tensor:
174174
padding="longest"
175175
)['input_ids']
176176

177-
def _postprocess_responses(self, responses: torch.Tensor) -> Tuple[torch.Tensor, List[str]]:
178-
"""
179-
Process responses to stop at tool call or final response.
180-
Handles tags like <action> and </action> or <response> and </response>.
181-
182-
Args:
183-
responses: Tensor containing response token IDs
184-
185-
Returns:
186-
Tuple of (processed response tensor, processed response strings)
187-
"""
188-
# Decode responses to strings
189-
responses_str = self.tokenizer.batch_decode(
190-
responses,
191-
skip_special_tokens=True
192-
)
193-
194-
# Process each response to extract action/response content
195-
processed_responses = []
196-
for resp in responses_str:
197-
if '</action>' in resp:
198-
# Stop at end of action
199-
processed = resp.split('</action>')[0] + '</action>'
200-
elif '</response>' in resp:
201-
# Stop at end of response
202-
processed = resp.split('</response>')[0] + '</response>'
203-
else:
204-
# No recognized end tag, keep as is
205-
processed = resp
206-
processed_responses.append(processed)
207-
208-
# Re-tokenize processed responses
209-
responses = self._batch_tokenize(processed_responses)
210-
211-
return responses, processed_responses
212-
213-
def _process_next_obs(self, next_obs: List[str]) -> torch.Tensor:
214-
"""
215-
Process next observations from environment.
216-
Tokenizes observations and handles maximum length constraints.
217-
218-
Args:
219-
next_obs: List of observation strings from the environment
220-
221-
Returns:
222-
Tensor of tokenized observations
223-
"""
224-
# Tokenize observations with consistent padding
225-
next_obs_ids = self.tokenizer(
226-
next_obs,
227-
padding='longest',
228-
return_tensors='pt',
229-
add_special_tokens=False, # Prevents adding special tokens
230-
)['input_ids']
231-
232-
# Truncate if observations are too long
233-
if next_obs_ids.shape[1] > self.config.max_obs_length:
234-
print(f"[WARNING] OBSERVATION TOO LONG, CONSIDER CHANGING YOUR CONFIG, {next_obs_ids.shape[1]} & {self.config.max_obs_length}")
235-
# Truncate to max_obs_length
236-
next_obs_ids = next_obs_ids[:, :self.config.max_obs_length]
237-
238-
return next_obs_ids
239-
240-
def _update_rolling_state(self, rollings: DataProto, cur_responses: torch.Tensor,
241-
next_obs_ids: torch.Tensor) -> DataProto:
242-
"""Update rolling state with new responses and observations."""
243-
# Concatenate and handle padding
244-
new_input_ids = self.tensor_fn.concatenate_with_padding([
245-
rollings.batch['input_ids'],
246-
cur_responses,
247-
next_obs_ids
248-
])
249-
250-
# Create attention mask and position ids
251-
new_attention_mask = self.tensor_fn.create_attention_mask(new_input_ids)
252-
new_position_ids = self.tensor_fn.create_position_ids(new_attention_mask)
253-
254-
# Cut to appropriate length
255-
effective_len = new_attention_mask.sum(dim=1).max()
256-
max_len = min(self.config.max_prompt_length, effective_len)
257-
258-
new_rollings = DataProto.from_dict({
259-
'input_ids': new_input_ids[:, -max_len:],
260-
'position_ids': new_position_ids[:, -max_len:],
261-
'attention_mask': new_attention_mask[:, -max_len:]
262-
})
263-
new_rollings.meta_info.update(rollings.meta_info)
264-
265-
return new_rollings
266177

267178
def _run_single_rollout(self, initial_prompt_ids: torch.Tensor, task_idx: int, client: Any) -> Dict[str, Any]:
268179
"""

openmanus_rl/llm_agent/tool_manager.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

train_grpo.sh

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# --- Configuration (defaults, can be overridden via env vars) ---
4-
export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-0,1,2,3,4,5,6,7}
4+
export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-1,2,3,4}
55
WAND_PROJECT=${WAND_PROJECT:-'OpenManus-rl'}
66
export BASE_MODEL=${BASE_MODEL:-'Qwen/Qwen2.5-3B'}
77
AGENTGYM_HOST=${AGENTGYM_HOST:-'0.0.0.0'} # Default to 0.0.0.0 for external access
@@ -99,32 +99,6 @@ case $AGENTGYM_ENV_NAME in
9999
echo "Error: Unsupported environment name '$AGENTGYM_ENV_NAME'"; usage;;
100100
esac
101101

102-
# --- Environment Dependency Installation (in‑place) ---
103-
ENV_SETUP_DIR="openmanus_rl/agentgym/agentenv-${AGENTGYM_ENV_NAME}"
104-
if [ -d "$ENV_SETUP_DIR" ]; then
105-
echo -e "\n[Setup] Preparing AgentGym environment '$AGENTGYM_ENV_NAME' from $ENV_SETUP_DIR ..."
106-
pushd "$ENV_SETUP_DIR" > /dev/null || { echo "Failed to enter $ENV_SETUP_DIR"; exit 1; }
107-
108-
# install requirements
109-
if [ -f "requirements.txt" ]; then
110-
echo "[Setup] Installing Python requirements ..."
111-
pip install --no-cache-dir -r requirements.txt
112-
fi
113-
# run setup.sh
114-
if [ -f "setup.sh" ]; then
115-
echo "[Setup] Running setup.sh ..."
116-
bash setup.sh
117-
fi
118-
# editable install
119-
if [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
120-
echo "[Setup] Installing environment package (editable) ..."
121-
pip install -e .
122-
fi
123-
popd > /dev/null
124-
echo "[Setup] Environment '$AGENTGYM_ENV_NAME' ready."
125-
else
126-
echo "[Setup] WARNING: $ENV_SETUP_DIR not found; skipping env‑specific installation."
127-
fi
128102

129103
# --- Start AgentGym Servers in Dedicated Environment ---
130104
TARGET_ENV_NAME="agentenv-${AGENTGYM_ENV_NAME}"
@@ -314,8 +288,8 @@ hydra_overrides=(
314288
"actor_rollout_ref.actor.optim.lr=1e-6"
315289
"actor_rollout_ref.actor.optim.lr_warmup_steps_ratio=0.95"
316290
"actor_rollout_ref.actor.use_kl_loss=true"
317-
"actor_rollout_ref.actor.ppo_mini_batch_size=256"
318-
"actor_rollout_ref.actor.ppo_micro_batch_size=64"
291+
"actor_rollout_ref.actor.ppo_mini_batch_size=32"
292+
"actor_rollout_ref.actor.ppo_micro_batch_size=32"
319293
"actor_rollout_ref.actor.fsdp_config.param_offload=true"
320294
"actor_rollout_ref.actor.fsdp_config.grad_offload=true"
321295
"actor_rollout_ref.actor.fsdp_config.optimizer_offload=true"
@@ -346,7 +320,7 @@ hydra_overrides=(
346320
"+trainer.val_only=false"
347321
"+trainer.val_before_train=true"
348322
"trainer.default_hdfs_dir=null"
349-
"trainer.n_gpus_per_node=8"
323+
"trainer.n_gpus_per_node=4"
350324
"trainer.nnodes=1"
351325
"trainer.save_freq=100"
352326
"trainer.test_freq=50"

train_ppo.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ hydra_overrides=(
296296
"actor_rollout_ref.model.enable_gradient_checkpointing=true"
297297
"actor_rollout_ref.model.use_remove_padding=True"
298298
"actor_rollout_ref.actor.optim.lr_warmup_steps_ratio=0.95"
299-
"actor_rollout_ref.actor.ppo_mini_batch_size=2"
299+
"actor_rollout_ref.actor.ppo_mini_batch_size=4"
300300
"actor_rollout_ref.actor.ppo_micro_batch_size=4"
301301
"actor_rollout_ref.actor.fsdp_config.param_offload=true"
302302
"actor_rollout_ref.actor.fsdp_config.grad_offload=true"
@@ -329,7 +329,7 @@ hydra_overrides=(
329329
"+trainer.val_only=false"
330330
"+trainer.val_before_train=true"
331331
"trainer.default_hdfs_dir=null"
332-
"trainer.n_gpus_per_node=3"
332+
"trainer.n_gpus_per_node=4"
333333
"trainer.nnodes=1"
334334
"trainer.save_freq=100"
335335
"trainer.test_freq=50"

0 commit comments

Comments
 (0)