vllm.models.nemotron_shortcut.nvidia.moe.runner
¶
A MoE runner whose routing and expert compute are separate graph nodes.
A Nemotron Shortcut shortcut block routes on its input, then runs its mixer, and
only then needs the routed contribution. begin_staged, run_staged_experts
and finish_staged are three opaque custom ops linked by dependency tensors,
so torch.compile keeps routing before the mixer and the experts after it.
With data parallelism on the all-gather/reduce-scatter transport, the stages also take that transport off the compute stream. A side stream runs the routing and the all-gather while the mixer runs, and the reduce-scatter while the caller's shared experts run; the experts stage and the finish wait for it. The collectives, kernels and results are those of the synchronous path.
Classes:
-
NemotronShortcutMoERunner–MoERunnerwith the forward split into three caller-placed stages. -
StagedDispatch–begin_staged's result, passed on to the later stages.
NemotronShortcutMoERunner
¶
Bases: MoERunner
MoERunner with the forward split into three caller-placed stages.
Shared experts are not part of the runner: the caller runs them on its
own input and passes their (unreduced) output to finish_staged.
Methods:
-
begin_staged–Route and dispatch
hidden_states; returns the later stages' input. -
finish_staged–Reduce, transform and add the shared output.
-
receive_staged–Wait for the dispatch if a piecewise CUDA graph piece is captured.
-
run_staged_experts–Run the routed experts after
current_path_outputis computed.
Attributes:
-
overlaps_transport(bool) –Whether the dispatch and the combine run on the side stream.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
overlaps_transport
property
¶
Whether the dispatch and the combine run on the side stream.
Only the all-gather/reduce-scatter transport, the one these experts use with DP. DBO overlaps it with the other microbatch instead, and PCP adds collectives outside the kernel.
begin_staged(hidden_states, router_logits)
¶
Route and dispatch hidden_states; returns the later stages' input.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
finish_staged(dependency, output_template, shared_output=None)
¶
Reduce, transform and add the shared output.
output_template gives the result's shape and dtype.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
receive_staged(dispatch, projections)
¶
Wait for the dispatch if a piecewise CUDA graph piece is captured.
Callers place this after projections and before the op that ends the
piece (an attention or GDP op), so the dispatch still overlaps the
projections. Otherwise the experts stage waits, after the whole mixer.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
run_staged_experts(dispatch, current_path_output)
¶
Run the routed experts after current_path_output is computed.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
StagedDispatch
¶
Bases: NamedTuple
begin_staged's result, passed on to the later stages.
The side stream may still read the routing inputs after begin_staged
returns. Passed to the experts op, which waits for it, they keep inductor
from reusing their memory before then.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
_Combined
dataclass
¶
Routed experts' output, kept from run_staged_experts to the finish.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
_Routed
dataclass
¶
Routed experts' input, kept from begin_staged to run_staged_experts.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
_capturing_graph_piece()
¶
Whether a piecewise CUDA graph piece is being captured.
A piece must join every stream it forks before it ends. A full CUDA graph is one capture of the whole forward pass, in runtime mode NONE or FULL.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
_launch_on_side_stream(device, done, launch)
¶
Run launch on the side stream and record done after it.
The side stream first waits for the compute stream's work so far (marked
with done too), so it never overtakes a compute-stream read of memory
freed to it. Tensors both streams use stay referenced until the compute
stream waits for done, which keeps this safe under CUDA graph capture
(no record_stream).