Skip to content

fix: derive Megatron-LM PYTHONPATH from script location#3

Open
koriyoshi2041 wants to merge 1 commit intoGen-Verse:mainfrom
koriyoshi2041:fix/megatron-pythonpath
Open

fix: derive Megatron-LM PYTHONPATH from script location#3
koriyoshi2041 wants to merge 1 commit intoGen-Verse:mainfrom
koriyoshi2041:fix/megatron-pythonpath

Conversation

@koriyoshi2041
Copy link

Summary

  • Replace the hardcoded placeholder /absolute/path/to/OpenClaw-RL/Megatron-LM/ in RUNTIME_ENV_JSON's PYTHONPATH with a dynamically computed MEGATRON_ROOT variable

Unlike HF_CKPT, SAVE_CKPT, and PRM_MODEL_PATH — which use ${VAR:-default} syntax and are clearly marked as user-configurable — this Megatron-LM path was embedded inside a JSON string and easy to overlook. Users who correctly set the model paths could still hit import failures because this PYTHONPATH entry silently pointed to a non-existent placeholder directory.

The fix computes MEGATRON_ROOT using the same cd && pwd pattern already established for SLIME_ROOT, so it resolves correctly regardless of where the repository is cloned.

Files changed

  • openclaw-rl/run_qwen3_4b_openclaw_rl.sh
  • openclaw-opd/run_qwen3_4b_openclaw_opd.sh

Test plan

  • Verified SCRIPT_DIR/../Megatron-LM resolves to the correct sibling directory
  • Confirmed the pattern is identical to the existing SLIME_ROOT computation
  • Checked that trailing slash removal has no effect on PYTHONPATH resolution
  • Verified shell quoting is correct within the JSON string

The RUNTIME_ENV_JSON in both launch scripts hardcoded a placeholder
path `/absolute/path/to/OpenClaw-RL/Megatron-LM/` for the Megatron-LM
PYTHONPATH entry. Unlike HF_CKPT and other paths which use
`${VAR:-default}` syntax and are clearly marked as user-configurable,
this PYTHONPATH was embedded inside a JSON string and easy to miss,
causing import failures at runtime.

Compute MEGATRON_ROOT from the script's directory (same pattern as
SLIME_ROOT) so it resolves correctly regardless of where the
repository is cloned.
JasonOA888 added a commit to JasonOA888/OpenClaw-RL that referenced this pull request Mar 12, 2026
Fixes Gen-Verse#3

## Summary
- Replace hardcoded /absolute/path/to/OpenClaw-RL/Megatron-LM/ with dynamically computed MEGATRON_ROOT
- Computes MEGATRON_ROOT using the same cd && pwd pattern as SLIME_ROOT

## Changes
- openclaw-rl/run_qwen3_4b_openclaw_rl.sh
- openclaw-opd/run_qwen3_4b_openclaw_opd.sh

Each script now includes:
```bash
MEGATRON_ROOT="$(cd -- "${SCRIPT_DIR}/../Megatron-LM" &>/dev/null && pwd)"
...
"PYTHONPATH": "${MEGATRON_ROOT}:${SCRIPT_DIR}:${SLIME_ROOT}"
```

## Test plan
- [x] Verified SCRIPT_DIR/../Megatron-LM resolves correctly
- [x] Pattern matches existing SLIME_ROOT computation
- [x] Shell quoting correct in JSON string
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.

1 participant