-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[trainer] feat: add gpt-oss sglang-megatron example #4394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[trainer] feat: add gpt-oss sglang-megatron example #4394
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for the sglang-megatron backend by adding a new example script and modifying an import fallback. My review has identified a critical security vulnerability due to a hardcoded API key in the example script, which must be removed and the key revoked. Additionally, a high-severity typo in the Python code could lead to import errors under certain conditions and should be corrected.
examples/grpo_trainer/customer_run_gptoss_20b_megatron_backend.sh
Outdated
Show resolved
Hide resolved
clean file add instructions
1b4440f to
a574734
Compare
examples/grpo_trainer/customer_run_gptoss_20b_megatron_backend.sh
Outdated
Show resolved
Hide resolved
| raise | ||
|
|
||
| __all__ = ["AutoBridge", "make_value_model", "freeze_moe_router"] | ||
| from megatron.bridge import AutoBridge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use Megatron-Bridge instead of mbridge, please set
actor_rollout_ref.actor.megatron.vanilla_mbridge=False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| logger = logging.getLogger(__file__) | ||
| logger.setLevel(os.getenv("VERL_LOGGING_LEVEL", "WARN")) | ||
|
|
||
| load_actor_from_cpu=os.getenv("MEGATRON_VERL_LOAD_FROM_CPU", "1") == "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need this instead of megatron.param_offload=True?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @wuxibin89 megatron-bridge supports to load modules directly from cpu :
self.bridge.export_hf_weights(self.actor.actor_module, cpu=load_actor_from_cpu, show_progress=False)
If that is true we don't need to reload parameters from cpu to gpu , then offload megatron module to cpu.

What does this PR do?
This is follow up of #4323 to add SGLang running example
Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI){modules}includefsdp,megatron,sglang,vllm,rollout,trainer,ci,training_utils,recipe,hardware,deployment,ray,worker,single_controller,misc,perf,model,algo,env,tool,ckpt,doc,data,like[megatron, fsdp, doc]{type}is infeat,fix,refactor,chore,test[BREAKING]to the beginning of the title.[BREAKING][fsdp, megatron] feat: dynamic batchingTest
py312+torch2.8+vllm0.11+sglang0.5.5+te2.9
docker:
Build Instruction:
vllm:
sglang:
V1

In our first trial, single node version of SGLang has unusual memory footprint (with the same test codes , just change vLLM to SGlang), we are currently working on improving its memory efficiency.
py312+torch2.9.1+sglang0.5.5+te2.9
sglang:
Benchmark
API and Usage Example
# Add code snippet or script demonstrating how to use thisDesign & Code Changes
Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace. (If not accessible, please try the Feishu group (飞书群).)