TITO support for SkyRL - #2143
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the Harbor TITO integration, routing Harbor's Chat Completions calls through a generator-owned, OpenAI-compatible token-in/token-out (TITO) proxy. Key additions include the TITOProxy server, exact message-graph trace bookkeeping, a thread-safe renderer adapter, and corresponding unit tests. Feedback on these changes identifies a potential resource leak in the proxy startup and shutdown logic, a potential AttributeError when configuring the generator with setdefault on potentially None values, and a potential unhandled 500 error if the Content-Length header is malformed.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit d5b0db4. Configure here.
| has_routed_experts = True | ||
| rollout_expert_indices.append(row_routed) | ||
| else: | ||
| rollout_expert_indices.append([]) |
There was a problem hiding this comment.
Routed experts crash training conversion
Medium Severity
build_trace_generator_output emits rollout_expert_indices as nested Python lists, including empty [] placeholders for masked or missing rows. The trainer’s convert_prompts_responses_to_batch_tensors requires a NumPy array per trajectory with shape [tokens, layers, topk], so any MoE run that returns routes will fail during batch conversion.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d5b0db4. Configure here.
| ) | ||
| rollout_metrics["generate/num_error_trajectories"] = sum( | ||
| 1 for outcome, rows in zip(outcomes, branch_rows) if outcome.stop_reason == "error" or not rows | ||
| ) |
There was a problem hiding this comment.
Timeouts counted as error metrics
Low Severity
generate/num_error_trajectories increments when not rows, so agent_timeout outcomes that use an empty sealed Trace are counted as both timeouts and errors. The existing Harbor composer treats these as disjoint cases.
Reviewed by Cursor Bugbot for commit d5b0db4. Configure here.


This PR implements TITO proxy for SkyRL. A custom generator simply needs to instantiate the proxy and point the url endpoint to the proxy, who are OpenAI-API compatible.
The implementation detail is discussed in #1959.
How it works
Validation
Two end-to-end run in code-contest with and without summarization enabled.

Purple curve = run without summarization. Red curve = run with summarization. Blue Curve = code-contest.
Note
Medium Risk
Touches the rollout→training path (exact tokens, loss masks, rewards) and introduces an in-process HTTP proxy on the critical inference path; incorrect trace/composer logic could silently skew RL training, though baseline Harbor is unchanged.
Overview
Adds token-in/token-out (TITO) support so external agents that speak OpenAI Chat Completions can roll out through SkyRL’s inference client while training on the exact sampled token IDs and logprobs.
A generator-owned FastAPI proxy (
TITOProxy) validates requests with vLLM’s OpenAI stack, renders prompts via Primerenderers, runs inference, and commits each turn into a message graph (Trace) that supports prefix reuse, retries, and branching (e.g. summarization).build_trace_generator_outputturns trace leaves intoGeneratorOutputrows, with masking for errors/timeouts, optional overlong filtering, and step-wise vs single-branch behavior.Ships a parallel
harbor_titoexample:TITOHarborGeneratorpoints Harbor trials at per-session proxy URLs, enables interleaved thinking and rollout-detail parity checks, and mergestito.yamltrial overrides. Entrypoints mirror sync, fully-async, and generate-only Harbor flows and require explicitmax_seq_len.Also adds optional
harbor-titoextra (harbor + pinned renderers + vllm), forwardsNCCL_NETinto Ray runtime env, and broad CPU/integration tests for trace, proxy, composer, and Harbor wiring.Reviewed by Cursor Bugbot for commit d5b0db4. Bugbot is set up for automated code reviews on this repo. Configure here.