Repository navigation
[HybridEngineRollout] Add multi-turn tool-calling rollout, GRPO primitives and turn-level continuous batching #9037
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: master
Are you sure you want to change the base?
Changes from all commits
cd2694a
ba8598a
8a0c281
bab51d5
f723c7f
4c33fb1
9bdcf1b
c34408c
0ef98fb
bb5660f
e7107cb
a3a715d
c09b6f3
92b1207
0fcc948
c2da157
87d9bc7
0ea1e34
db96f58
df1be51
1e8a7f7
e9be696
2d57b6f
cde4cb7
da3d161
178f41b
b3f2a6b
8858de9
4f5e2d0
b677f3e
d0feab9
a2b6e0d
74e5af6
bca99b4
8673dc6
3c55b97
064897e
1f903d1
66c1c0a
b2ee8bb
3aa67ab
4afaa33
ad555e4
e43e814
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,47 +7,77 @@ | |
| - :class:`RolloutEngine` — abstract base class | ||
| - :class:`RolloutRequest`, :class:`RolloutBatch`, :class:`SamplingConfig` — dataclasses | ||
| - :class:`ResponseTokenBatch` — response-only causal training targets | ||
| - :func:`group_advantages`, :func:`grpo_policy_loss` — GRPO advantages and PPO-clip policy loss | ||
| - :class:`HybridEngineRollout` — concrete implementation using DeepSpeed hybrid engine | ||
| - :class:`Tool`, :class:`ToolSet`, :func:`parse_hermes_tool_calls`, :func:`parse_qwen3_coder_tool_calls` — tools | ||
| for multi-turn rollout | ||
| - :func:`build_rollout` — factory that selects the engine from config | ||
| """ | ||
|
|
||
| import warnings | ||
|
|
||
| from deepspeed.runtime.rollout.base import ( | ||
| RolloutBatch, | ||
| RolloutConfig, | ||
| RolloutEngine, | ||
| RolloutRequest, | ||
| SamplingConfig, | ||
| ) | ||
| from deepspeed.runtime.rollout.hybrid_engine_rollout import HybridEngineRollout | ||
| from deepspeed.runtime.rollout.hybrid_engine_rollout import HybridEngineRollout, HybridEngineRolloutConfig | ||
| from deepspeed.runtime.rollout.grpo import (GRPOLossOutput, group_advantages, grpo_policy_loss, | ||
| old_log_probs_from_rollout) | ||
| from deepspeed.runtime.rollout.opsd import JSDLossOutput, ResponseTokenBatch, generalized_jsd_loss | ||
| from deepspeed.runtime.rollout.tool import Tool, ToolCall, ToolSet, parse_hermes_tool_calls, parse_qwen3_coder_tool_calls | ||
|
|
||
| __all__ = [ | ||
| "GRPOLossOutput", | ||
| "HybridEngineRollout", | ||
| "HybridEngineRolloutConfig", | ||
| "JSDLossOutput", | ||
| "RolloutBatch", | ||
| "RolloutConfig", | ||
| "RolloutEngine", | ||
| "RolloutRequest", | ||
| "ResponseTokenBatch", | ||
| "SamplingConfig", | ||
| "Tool", | ||
| "ToolCall", | ||
| "ToolSet", | ||
| "build_rollout", | ||
| "generalized_jsd_loss", | ||
| "group_advantages", | ||
| "grpo_policy_loss", | ||
| "old_log_probs_from_rollout", | ||
| "parse_hermes_tool_calls", | ||
| "parse_qwen3_coder_tool_calls", | ||
| ] | ||
|
|
||
|
|
||
| def build_rollout(rollout_cfg, student_engine=None, tokenizer=None, **kwargs): | ||
| def build_rollout(rollout_cfg, generation_engine=None, tokenizer=None, tools=None, **kwargs): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For callers using the prior public form AGENTS.md reference: AGENTS.md:L40-L40 Useful? React with 👍 / 👎. |
||
| """Factory: construct the rollout engine specified by ``rollout_cfg.engine``. | ||
|
|
||
| Args: | ||
| rollout_cfg: :class:`RolloutConfig` (or any object with an ``engine`` | ||
| attribute set to ``"hybrid_engine"``). | ||
| student_engine: DeepSpeed engine wrapping the student model. | ||
| rollout_cfg: The backend's config, a subclass of :class:`RolloutConfig` whose ``engine`` names the | ||
| backend: :class:`HybridEngineRolloutConfig` for ``"hybrid_engine"``. | ||
| generation_engine: DeepSpeed engine wrapping the student model. | ||
| tokenizer: HuggingFace tokenizer. | ||
| tools: Tools the model may call in multi-turn rollout: a | ||
| :class:`ToolSet` or a list of :class:`Tool`. | ||
| student_engine: Deprecated alias of ``generation_engine``. | ||
| """ | ||
| if "student_engine" in kwargs: | ||
| if generation_engine is not None: | ||
| raise TypeError("build_rollout got both generation_engine and its deprecated alias student_engine") | ||
| warnings.warn("build_rollout(student_engine=...) is deprecated; use generation_engine", | ||
| DeprecationWarning, | ||
| stacklevel=2) | ||
| generation_engine = kwargs.pop("student_engine") | ||
| engine_name = rollout_cfg.engine | ||
| if engine_name == "hybrid_engine": | ||
| if student_engine is None or tokenizer is None: | ||
| raise ValueError("hybrid_engine rollout needs both student_engine and tokenizer") | ||
| return HybridEngineRollout(engine=student_engine, tokenizer=tokenizer, cfg=rollout_cfg) | ||
| if generation_engine is None or tokenizer is None: | ||
| raise ValueError("hybrid_engine rollout needs both generation_engine and tokenizer") | ||
| if tools is not None and not isinstance(tools, ToolSet): | ||
| tools = ToolSet(tools) | ||
| return HybridEngineRollout(engine=generation_engine, tokenizer=tokenizer, cfg=rollout_cfg, tools=tools) | ||
|
|
||
| raise ValueError(f"Unknown rollout engine {engine_name!r}; choose from 'hybrid_engine'") | ||
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.
When
cdbisCCLBackendand multi-turn AutoTP initializeshost_tensor_parallel_group(), this dispatch passesbackend="gloo", butdeepspeed/comm/ccl.pystill overridesnew_group(self, ranks)without accepting that keyword. The rollout therefore raisesTypeErrorbefore generation on the CCL path; update that override to accept and forward the backend while preserving its subgroup bookkeeping.AGENTS.md reference: AGENTS.md:L40-L40
Useful? React with 👍 / 👎.