Skip to content

[v0.2] Add lazy import to fix circular import and ray init config support#236

Merged
jeffreysijuntan merged 1 commit into
rllm-org:v0.2from
listar2000:fix/circular-import-and-ray-config
Oct 7, 2025
Merged

[v0.2] Add lazy import to fix circular import and ray init config support#236
jeffreysijuntan merged 1 commit into
rllm-org:v0.2from
listar2000:fix/circular-import-and-ray-config

Conversation

@listar2000
Copy link
Copy Markdown
Collaborator

@listar2000 listar2000 commented Oct 7, 2025

Description

This PR merges two issues encountered when testing the examples/math_tools/train_math_with_tool.sh script.

  1. Circular import issue between engine and workflows modules
    Previous cycling pattern:
    workflows/__init__.py → workflows/workflow.py → engine/rollout/rollout_engine.py → engine/__init__.py → engine/agent_workflow_engine.py → workflows/workflow.py ← CYCLE!

  2. Improves Ray initialization (ray.init) configuration to allow more arguments other than num_cpus.

    Now it's easier to specify arguments like (_temp_dir, address, logging_level) under the ray_init fields.

Changes Made

  • Implemented lazy import for AgentWorkflowEngine in engine/__init__.py using __getattr__() pattern (similar to workflows/__init__.py.
  • Added None value filtering in agent_trainer.py before passing config to ray.init()

Motivation

The circular import prevented the engine module from being imported successfully, causing the training to fail on initialization. The ray configuration improvements allow users to properly configure Ray's temporary directory and other settings through Hydra configuration.

Testing

  • Pass the pytests (a couple of seemingly unrelated errors in tests/agents/test_math_agent.py)
  • Tested locally (with examples/math_tools/train_math_with_tool.sh) with multi-GPU training setup
  • Verified circular import is resolved
  • Confirmed Ray initialization works with custom configurations (e.g. _temp_dir)

@jeffreysijuntan jeffreysijuntan merged commit 994d62e into rllm-org:v0.2 Oct 7, 2025
1 check passed
@kylemontgomery1 kylemontgomery1 mentioned this pull request Oct 8, 2025
@listar2000 listar2000 deleted the fix/circular-import-and-ray-config branch October 22, 2025 21:01
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