Commit 58dfc1c
[tinker] Continuous sampling: per-request future completion under colocate_all
The engine's serial loop batched all pending sample requests and completed
every future only when the whole batch finished, so with ~64 lockstep
agentic rollouts each wave's turn latency was max(generation in wave): a
single 200s turn stalled 63 finished agents for its full tail. The batch
semantics existed only to serialize sampling against ops that sleep the
colocated engines.
Keep that safety property with admission control instead of serialization:
- _ContinuousSampler: daemon thread + asyncio loop; each admitted sample
runs as its own coroutine (backend.sample_batch_async -> per-request
vLLM HTTP; vLLM continuous-batches internally) and its future is written
the moment its own generation completes.
- Engine loop admits pending samples whenever no blocking work exists;
engines are brought up/woken on the main thread first
(backend.prepare_for_sampling). Blocking work (forward/forward_backward,
single requests, stale-session model unloads) drains in-flight samples
first -- generations keep decoding while the blocking op waits, then run
with the engines quiesced exactly as before. Deferred samples stay
PENDING and are admitted next iteration, never as a convoy batch.
- Admission runs _filter_valid_requests first (serial-path parity): stale
sample requests left over from a previous server fail with "model not
loaded" instead of driving prepare_for_sampling into an engine build
with no model registered.
- No-op session-cleanup sweeps don't drain (only sweeps that actually
unload models do), so the periodic reaper can't reintroduce a stall.
- backend: prepare_for_sampling + sample_batch_async (validation shared
with the serial path; the async core reuses the loop-aware HTTP client,
keeping the session open on the sampler's persistent loop).
RemoteInferenceClient._get_session closes the stale loop's connector
synchronously on loop handoff so sockets release immediately.
- SKYRL_TINKER_CONTINUOUS_SAMPLING=0 restores the serial loop; backends
without the async surface (jax) keep it automatically.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 8b0a909 commit 58dfc1c
4 files changed
Lines changed: 497 additions & 43 deletions
File tree
- skyrl
- backends
- skyrl_train/inference_servers
- tinker
- tests/tinker
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
293 | 305 | | |
294 | 306 | | |
295 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1049 | 1049 | | |
1050 | 1050 | | |
1051 | 1051 | | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
1052 | 1069 | | |
1053 | 1070 | | |
1054 | 1071 | | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
1061 | | - | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1062 | 1084 | | |
1063 | 1085 | | |
1064 | 1086 | | |
| |||
1073 | 1095 | | |
1074 | 1096 | | |
1075 | 1097 | | |
| 1098 | + | |
1076 | 1099 | | |
1077 | | - | |
1078 | | - | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1079 | 1117 | | |
1080 | 1118 | | |
1081 | 1119 | | |
1082 | 1120 | | |
1083 | 1121 | | |
1084 | | - | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
1085 | 1137 | | |
1086 | 1138 | | |
1087 | 1139 | | |
| |||
1141 | 1193 | | |
1142 | 1194 | | |
1143 | 1195 | | |
1144 | | - | |
| 1196 | + | |
| 1197 | + | |
1145 | 1198 | | |
1146 | | - | |
1147 | | - | |
| 1199 | + | |
| 1200 | + | |
1148 | 1201 | | |
1149 | 1202 | | |
1150 | 1203 | | |
| |||
1153 | 1206 | | |
1154 | 1207 | | |
1155 | 1208 | | |
1156 | | - | |
| 1209 | + | |
1157 | 1210 | | |
1158 | 1211 | | |
1159 | 1212 | | |
| |||
0 commit comments