Skip to content

feat(cs): add async multi-turn agentic rollout - #361

Merged
Yunnglin merged 27 commits into
dev-swift-v5from
cs-async-rl
Nov 11, 2026
Merged

Yunnglin merged 27 commits into
dev-swift-v5from
cs-async-rl

Conversation

@Yunnglin

@Yunnglin Yunnglin commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Enable client-orchestrated, text-only multi-turn GRPO over HTTP: run tool-using episodes with the shared rollout core, consume complete groups through StreamingDriver, train the remote model, and publish immutable policy snapshots for subsequent episodes.

Changes

  • Extend ClientMultiTurnRollout with admit/poll/collect/stop and scoped streaming cleanup while retaining synchronous and asynchronous batch calls. Preserve sampled token IDs, labels, masks and logprobs without re-encoding the conversation; reject unsupported media or divergent engine encodings.
  • Track independent Env/harness borrows and immutable admission metadata. Cooperative cancellation waits for issued work; batch draining and interruptions after executor enqueue retain ownership until settlement. Unknown remote execution is reported and quarantined rather than treated as released.
  • Add RolloutResources and scoped operation protection so examples call model methods directly without implementing cleanup or interrupt bookkeeping. Keep sampling concurrent with training, and do not automatically replay training operations.
  • Add training_groups for complete-group membership, policy and training-data checks. Keep reward selection, GRPO advantages, backward, optimizer steps and publication/commit explicit in the cookbook.
  • Provide Blackjack examples using local OpenEnv or one official E2B sandbox per trajectory. Both use the same training loop and task contract; the E2B path runs trusted game tools without a generated-code verifier. Add the optional [e2b] dependency group and bilingual setup/extension guidance; retain the existing batch multi-turn example.
  • Fix supporting training contracts: completed-backward gradient-accumulation boundaries, exact LoRA slot-name matching in both training backends, missing Megatron text positions, optional media fields, template/harness metadata preservation, AgentEnv initialization failures and batched EnvTool reward/terminal-state recording. Correct task-head initialization and metric reporting in the existing classification/reranking examples.

Existing DataPlane/DataRef APIs and the paper TQ runtime are retained. This adds no server-side rollout service or HTTP/Wire protocol.

Validation

  • Current implementation: 402 local tests passed, 0 failed, 0 skipped (407 → 402 after consolidating redundant coverage; 166 net test lines removed). Covers the complete client suite plus shared multi-turn, tools, AgentEnv initialization, token utilities, templates and input processing. Includes controlled concurrent-worker regressions and real local-HTTP subprocess tests with repeated SIGINT. The reviewed source snapshot matches the current PR head.
  • New SDK modules pass explicit Ruff checks; existing changed SDK/agentic sources have no additional diagnostics relative to the base. Edited documentation links and git diff --check pass. This is not a claim that the entire repository is lint-clean.
  • Earlier hardware snapshot, before the final SDK refactor: Transformers DP=2 + vLLM eager + official E2B completed real Blackjack training, two optimizer updates, policy publication and subsequent sampling with new policy URIs. Changed adapter weights and release of all 35 test sandboxes were verified. These results are historical evidence, not current-head hardware acceptance or evidence of learning improvement.

Remaining validation and boundaries

  • Rerun real PPU/E2B acceptance after the final SDK lifecycle refactor; complete both training backends and strict sampler-versus-trainer logprob comparisons.
  • Validate two independent tenants against one server, including external harness state isolation, cancelling one tenant while the other continues, and per-tenant resource release.
  • Cancellation is cooperative; immediate remote generation/command termination requires additional server/provider support.
  • Independent evaluation of training benefit remains outstanding. Successful updates, finite loss and changed weights alone do not establish improved task performance.

@Yunnglin
Yunnglin changed the base branch from main to dev-swift-v5 November 2, 2026 04:58
Restore token-aligned HTTP features and skip only model-truncated groups so async multi-turn GRPO can train and publish updated policies reliably.
…ixes

Adopt the target branch's equivalent token-field append implementation to resolve the PR conflict.
Move recipe resource cleanup into RolloutResources while keeping GRPO training and policy publication explicit. Share Blackjack task metadata across local OpenEnv and official E2B environments, validate the task tool contract, and fail sandbox initialization explicitly.

Add the E2B installation option, bilingual setup and extension guidance, and lifecycle, reward, and integration coverage. Validation: 92 focused CPU tests passed; new files pass Ruff and edited guide links are valid.
Keep OpenEnv action-schema discovery alongside the client lifecycle lock, and preserve both driver budget assertions and upstream bookkeeping regressions. Add HTTP multi-turn length-budget coverage across sync, async and streaming entry points.

Validation: 416 focused CPU tests passed with no failures or skips. Full repository lint also fails on the upstream base; conflict-affected files introduce no new Ruff findings and unrelated formatting is unchanged.
@Yunnglin
Yunnglin marked this pull request as ready for review November 11, 2026 06:56
Copilot AI balanced review requested due to automatic review settings November 11, 2026 06:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Move scored-group preparation and guarded operation waits into the SDK while keeping training calls and connection settings explicit. Cover batch and streaming admission/draining, preserve registered results across interruption, and retain resources when remote execution is unconfirmed.

Include the pending rollout cleanup, transport validation hook, regression coverage and documentation changes. PPU validation will run against this commit after push.
Consolidate resource borrowing, stop and setup-failure cases; remove duplicate characterization and configuration checks. Replace validator call-count assertions with rejection-before-generation checks while retaining lifecycle, token-alignment and real-service acceptance coverage.

Validation: 402 tests passed with zero failures or skips, down from 407 collected cases; net reduction of 166 lines across four test files. No production changes.
@Yunnglin
Yunnglin merged commit ad08e5b into dev-swift-v5 Nov 11, 2026
0 of 6 checks passed
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.

3 participants