1<!-- Google Tag Manager -->
2<script>
vendor: 415 bytes, lines 2-12
2 3 (function (w, d, s, l, i) { 4 w[l] = w[l] || []; 5 w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); 6 var f = d.getElementsByTagName(s)[0], 7 j = d.createElement(s), 8 dl = l != "dataLayer" ? "&l=" + l : ""; 9 j.async = true; 10 j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; 11 f.parentNode.insertBefore(j, f); 12 })(window, document, "script", "dataLayer", "
12GTM-KV83JWN
vendor: 4 bytes, line 12
12");
13</script>
13 14<!-- End Google Tag Manager --> 15 16 17<!doctype html> 18<html lang="en" class="no-js"> 19 <head> 20 21 <meta charset="utf-8"> 22 <meta name="viewport" content="width=device-width,initial-scale=1"> 23 24 <meta name="description" content="Scaffold for experienced Machine Learning Researchers"> 25 26 27 <meta name="author" content="DanLing Team"> 28 29 30 <link rel="canonical" href="https://danling.org/runners/"> 31 32 33 <link rel="prev" href=".."> 34 35 36 <link rel="next" href="config/"> 37 38 39 40 <link rel="alternate" href="/" hreflang="en"> 41 42 <link rel="alternate" href="/index.zh/" hreflang="zh"> 43 44 45 46 <link rel="icon" href="../assets/images/logo.ico"> 47 <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.7.7"> 48 49 50 51 <title>Runners - DanLing</title> 52 53 54 55 <link rel="stylesheet" href="../assets/stylesheets/main.ec1eaa64.min.css"> 56 57 58 <link rel="stylesheet" href="../assets/stylesheets/palette.ab4e12ef.min.css"> 59 60 61 62 63 64 65 66 67 68 69 70 71 <link rel="stylesheet" href="../assets/_mkdocstrings.css"> 72 73 <link rel="stylesheet" href="../assets/css/fonts.css"> 74 75 <link rel="stylesheet" href="../assets/css/extra.css"> 76 77
77<script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
77 78 79 80 81 82 83 84 85
86<script id="__analytics">function __md_analytics(){function e(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],e("js",new Date),e("config","G-RE7EKZ9T8D"),document.addEventListener("DOMContentLoaded",(function(){document.forms.search&&document.forms.search.query.addEventListener("blur",(function(){this.value&&e("event","search",{search_term:this.value})}));document$.subscribe((function(){var t=document.forms.feedback;if(void 0!==t)for(var a of t.querySelectorAll("[type=submit]"))a.addEventListener("click",(function(a){a.preventDefault();var n=document.location.pathname,d=this.getAttribute("data-md-value");e("event","feedback",{page:n,data:d}),t.firstElementChild.disabled=!0;var r=t.querySelector(".md-feedback__note [data-md-value='"+d+"']");r&&(r.hidden=!1)})),t.hidden=!1})),location$.subscribe((function(t){e("config","G-RE7EKZ9T8D",{page_path:t.pathname})}))}));var t=document.createElement("script");t.async=!0,t.src="https://www.googletagmanager.com/gtag/js?id=G-RE7EKZ9T8D",document.getElementById("__analytics").insertAdjacentElement("afterEnd",t)}</script>
86 87 88
88<script>if("undefined"!=typeof __md_analytics){var consent=__md_get("__consent");consent&&consent.analytics&&__md_analytics()}</script>
88 89 90 91 92 93 </head> 94 95 96 97 98 99 100 101 102 103 <body dir="ltr" data-md-color-scheme="slate" data-md-color-primary="blue-grey" data-md-color-accent="teal"> 104 105 106 <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off"> 107 <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off"> 108 <label class="md-overlay" for="__drawer"></label> 109 <div data-md-component="skip"> 110 111 112 <a href="#danling-runner" class="md-skip"> 113 Skip to content 114 </a> 115 116 </div> 117 <div data-md-component="announce"> 118 119 </div> 120 121 122 123 124 125 126<header class="md-header md-header--shadow md-header--lifted" data-md-component="header"> 127 <nav class="md-header__inner md-grid" aria-label="Header"> 128 <a href=".." title="DanLing" class="md-header__button md-logo" aria-label="DanLing" data-md-component="logo"> 129 130 <img src="../assets/images/logo.png" alt="logo"> 131 132 </a> 133 <label class="md-header__button md-icon" for="__drawer"> 134 135 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> 136 </label> 137 <div class="md-header__title" data-md-component="header-title"> 138 <div class="md-header__ellipsis"> 139 <div class="md-header__topic"> 140 <span class="md-ellipsis"> 141 DanLing 142 </span> 143 </div> 144 <div class="md-header__topic" data-md-component="header-topic"> 145 <span class="md-ellipsis"> 146 147 Runners 148 149 </span> 150 </div> 151 </div> 152 </div> 153 154 155 <form class="md-header__option" data-md-component="palette"> 156 157 158 159 160 <input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="blue-grey" data-md-color-accent="teal" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_0"> 161 162 <label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden> 163 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> 164 </label> 165 166 167 168 169 170 <input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="blue-grey" data-md-color-accent="teal" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_1"> 171 172 <label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_0" hidden> 173 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> 174 </label> 175 176 177</form> 178 179 180 181
181<script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
181 182 183 184 <div class="md-header__option"> 185 <div class="md-select"> 186 187 <button class="md-header__button md-icon" aria-label="Select language"> 188 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m12.87 15.07-2.54-2.51.03-.03A17.5 17.5 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2zm-2.62 7 1.62-4.33L19.12 17z"/></svg> 189 </button> 190 <div class="md-select__inner"> 191 <ul class="md-select__list"> 192 193 <li class="md-select__item"> 194 <a href="/" hreflang="en" class="md-select__link"> 195 English 196 </a> 197 </li> 198 199 <li class="md-select__item"> 200 <a href="/index.zh/" hreflang="zh" class="md-select__link"> 201 æ±è¯ 202 </a> 203 </li> 204 205 </ul> 206 </div> 207 </div> 208</div> 209 210 211 212 213 <label class="md-header__button md-icon" for="__search"> 214 215 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> 216 </label> 217 <div class="md-search" data-md-component="search" role="dialog"> 218 <label class="md-search__overlay" for="__search"></label> 219 <div class="md-search__inner" role="search"> 220 <form class="md-search__form" name="search"> 221 <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required> 222 <label class="md-search__icon md-icon" for="__search"> 223 224 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> 225 226 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg> 227 </label> 228 <nav class="md-search__options" aria-label="Search"> 229 230 <a href="javascript:void(0)" class="md-search__icon md-icon" title="Share" aria-label="Share" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1"> 231 232 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91s2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08"/></svg> 233 </a> 234 235 <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1"> 236 237 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg> 238 </button> 239 </nav> 240 241 <div class="md-search__suggest" data-md-component="search-suggest"></div> 242 243 </form> 244 <div class="md-search__output"> 245 <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix> 246 <div class="md-search-result" data-md-component="search-result"> 247 <div class="md-search-result__meta"> 248 Initializing search 249 </div> 250 <ol class="md-search-result__list" role="presentation"></ol> 251 </div> 252 </div> 253 </div> 254 </div> 255</div> 256 257 258 259 <div class="md-header__source"> 260 <a href="https://github.com/ZhiyuanChen/DanLing" title="Go to repository" class="md-source" data-md-component="source"> 261 <div class="md-source__icon md-icon"> 262 263 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg> 264 </div> 265 <div class="md-source__repository"> 266 DanLing 267 </div> 268</a> 269 </div> 270 271 </nav> 272 273 274 275<nav class="md-tabs" aria-label="Tabs" data-md-component="tabs"> 276 <div class="md-grid"> 277 <ul class="md-tabs__list"> 278 279 280 281 282 283 284 <li class="md-tabs__item"> 285 <a href=".." class="md-tabs__link"> 286 287 288 289 290 291 DanLing 292 293 </a> 294 </li> 295 296 297 298 299 300 301 302 303 304 305 <li class="md-tabs__item md-tabs__item--active"> 306 <a href="./" class="md-tabs__link"> 307 308 309 310 311 312 Runners 313 314 </a> 315 </li> 316 317 318 319 320 321 322 323 324 <li class="md-tabs__item"> 325 <a href="../tensors/" class="md-tabs__link"> 326 327 328 329 330 331 Tensors 332 333 </a> 334 </li> 335 336 337 338 339 340 341 342 343 344 345 <li class="md-tabs__item"> 346 <a href="../optim/lr_scheduler/" class="md-tabs__link"> 347 348 349 350 351 352 Optim 353 354 </a> 355 </li> 356 357 358 359 360 361 362 363 364 365 <li class="md-tabs__item"> 366 <a href="../metrics/" class="md-tabs__link"> 367 368 369 370 371 372 Metrics 373 374 </a> 375 </li> 376 377 378 379 380 381 382 383 384 385 386 <li class="md-tabs__item"> 387 <a href="../utils/decorators/" class="md-tabs__link"> 388 389 390 391 392 393 Utils 394 395 </a> 396 </li> 397 398 399 400 401 402 403 404 405 406 <li class="md-tabs__item"> 407 <a href="../package/" class="md-tabs__link"> 408 409 410 411 412 413 package 414 415 </a> 416 </li> 417 418 419 420 421 422 423 424 425 426 427 <li class="md-tabs__item"> 428 <a href="../about/" class="md-tabs__link"> 429 430 431 432 433 434 About 435 436 </a> 437 </li> 438 439 440 441 442 443 444 445 446 447 448 449 <li class="md-tabs__item"> 450 <a href="../index.zh/" class="md-tabs__link"> 451 452 453 454 455 456 䏿 457 458 </a> 459 </li> 460 461 462 463 464 </ul> 465 </div> 466</nav> 467 468 469</header> 470 471 <div class="md-container" data-md-component="container"> 472 473 474 475 476 <main class="md-main" data-md-component="main"> 477 <div class="md-main__inner md-grid"> 478 479 480 481 <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" > 482 <div class="md-sidebar__scrollwrap"> 483 <div class="md-sidebar__inner"> 484 485 486 487 488 489 490<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="Navigation" data-md-level="0"> 491 <label class="md-nav__title" for="__drawer"> 492 <a href=".." title="DanLing" class="md-nav__button md-logo" aria-label="DanLing" data-md-component="logo"> 493 494 <img src="../assets/images/logo.png" alt="logo"> 495 496 </a> 497 DanLing 498 </label> 499 500 <div class="md-nav__source"> 501 <a href="https://github.com/ZhiyuanChen/DanLing" title="Go to repository" class="md-source" data-md-component="source"> 502 <div class="md-source__icon md-icon"> 503 504 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg> 505 </div> 506 <div class="md-source__repository"> 507 DanLing 508 </div> 509</a> 510 </div> 511 512 <ul class="md-nav__list" data-md-scrollfix> 513 514 515 516 517 518 519 520 <li class="md-nav__item"> 521 <a href=".." class="md-nav__link"> 522 523 524 525 <span class="md-ellipsis"> 526 527 528 DanLing 529 530 531 532 </span> 533 534 535 536 </a> 537 </li> 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 <li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested"> 577 578 579 580 <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" checked> 581 582 583 <div class="md-nav__link md-nav__container"> 584 <a href="./" class="md-nav__link md-nav__link--active"> 585 586 587 588 <span class="md-ellipsis"> 589 590 591 Runners 592 593 594 595 </span> 596 597 598 599 </a> 600 601 602 <label class="md-nav__link md-nav__link--active" for="__nav_2" id="__nav_2_label" tabindex="">
603 <span class="md-nav__icon md-icon"></span> 604 </label> 605 606 </div> 607 608 <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="true"> 609 <label class="md-nav__title" for="__nav_2"> 610 <span class="md-nav__icon md-icon"></span> 611 612 613 Runners 614 615 616 </label> 617 <ul class="md-nav__list" data-md-scrollfix> 618 619 620 621 622 623 624 625 <li class="md-nav__item"> 626 <a href="config/" class="md-nav__link"> 627 628 629 630 <span class="md-ellipsis"> 631 632 633 RunnerConfig 634 635 636 637 </span> 638 639 640 641 </a> 642 </li> 643 644 645 646 647 648 649 650 651 652 653 <li class="md-nav__item"> 654 <a href="runner/" class="md-nav__link"> 655 656 657 658 <span class="md-ellipsis"> 659 660 661 Runner 662 663 664 665 </span> 666 667 668 669 </a> 670 </li> 671 672 673 674 675 676 677 678 679 680 681 <li class="md-nav__item"> 682 <a href="torch_runner/" class="md-nav__link"> 683 684 685 686 <span class="md-ellipsis"> 687 688 689 TorchRunner 690 691 692 693 </span> 694 695 696 697 </a> 698 </li> 699 700 701 702 703 704 705 706 707 708 709 <li class="md-nav__item"> 710 <a href="base_runner/" class="md-nav__link"> 711 712 713 714 <span class="md-ellipsis"> 715 716 717 BaseRunner 718 719 720 721 </span> 722 723 724 725 </a> 726 </li> 727 728 729 730 731 732 733 734 735 736 737 <li class="md-nav__item"> 738 <a href="utils/" class="md-nav__link"> 739 740 741 742 <span class="md-ellipsis"> 743 744 745 Utilities 746 747 748 749 </span> 750 751 752 753 </a> 754 </li> 755 756 757 758 759 </ul> 760 </nav> 761 762 </li> 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> 796 797 798 799 800 801 <a href="../tensors/nested_tensor/" class="md-nav__link"> 802 803 804 805 <span class="md-ellipsis"> 806 807 808 Tensors 809 810 811 812 </span> 813 814 815 816 817 <span class="md-nav__icon md-icon"></span> 818 819 </a> 820 821 822 823 </li> 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> 853 854 855 856 857 858 <a href="../optim/lr_scheduler/" class="md-nav__link"> 859 860 861 862 <span class="md-ellipsis"> 863 864 865 Optim 866 867 868 869 </span> 870 871 872 873 874 <span class="md-nav__icon md-icon"></span> 875 876 </a> 877 878 879 880 </li> 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> 920 921 922 923 924 925 <a href="../metrics/metrics/" class="md-nav__link"> 926 927 928 929 <span class="md-ellipsis"> 930 931 932 Metrics 933 934 935 936 </span> 937 938 939 940 941 <span class="md-nav__icon md-icon"></span> 942 943 </a> 944 945 946 947 </li> 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> 983 984 985 986 987 988 <a href="../utils/decorators/" class="md-nav__link"> 989 990 991 992 <span class="md-ellipsis"> 993 994 995 Utils 996 997 998 999 </span> 1000 1001 1002 1003 1004 <span class="md-nav__icon md-icon"></span> 1005 1006 </a> 1007 1008 1009 1010 </li> 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 <li class="md-nav__item"> 1021 <a href="../package/" class="md-nav__link"> 1022 1023 1024 1025 <span class="md-ellipsis"> 1026 1027 1028 package 1029 1030 1031 1032 </span> 1033 1034 1035 1036 </a> 1037 </li> 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> 1073 1074 1075 1076 1077 1078 <a href="../about/" class="md-nav__link"> 1079 1080 1081 1082 <span class="md-ellipsis"> 1083 1084 1085 About 1086 1087 1088 1089 </span> 1090 1091 1092 1093
1094 <span class="md-nav__icon md-icon"></span> 1095 1096 </a> 1097 1098 1099 1100 </li> 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> 1136 1137 1138 1139 1140 1141 <a href="../index.zh/" class="md-nav__link"> 1142 1143 1144 1145 <span class="md-ellipsis"> 1146 1147 1148 䏿 1149 1150 1151 1152 </span> 1153 1154 1155 1156 1157 <span class="md-nav__icon md-icon"></span> 1158 1159 </a> 1160 1161 1162 1163 </li> 1164 1165 1166 1167 </ul> 1168</nav> 1169 </div> 1170 </div> 1171 </div> 1172 1173 1174 1175 <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" > 1176 <div class="md-sidebar__scrollwrap"> 1177 <div class="md-sidebar__inner"> 1178 1179 1180<nav class="md-nav md-nav--secondary" aria-label="Table of contents"> 1181 1182 1183 1184 1185 1186 1187 <label class="md-nav__title" for="__toc"> 1188 <span class="md-nav__icon md-icon"></span> 1189 Table of contents 1190 </label> 1191 <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix> 1192 1193 <li class="md-nav__item"> 1194 <a href="#core-apis" class="md-nav__link"> 1195 <span class="md-ellipsis"> 1196 1197 Core APIs 1198 1199 </span> 1200 </a> 1201 1202</li> 1203 1204 <li class="md-nav__item"> 1205 <a href="#common-workflows" class="md-nav__link"> 1206 <span class="md-ellipsis"> 1207 1208 Common workflows 1209 1210 </span> 1211 </a> 1212 1213</li> 1214 1215 <li class="md-nav__item"> 1216 <a href="#baserunner-contract" class="md-nav__link"> 1217 <span class="md-ellipsis"> 1218 1219 BaseRunner contract 1220 1221 </span> 1222 </a> 1223 1224</li> 1225 1226 <li class="md-nav__item"> 1227 <a href="#checkpoint-semantics" class="md-nav__link"> 1228 <span class="md-ellipsis"> 1229 1230 Checkpoint semantics 1231 1232 </span> 1233 </a> 1234 1235</li> 1236 1237 <li class="md-nav__item"> 1238 <a href="#dataloader-state" class="md-nav__link"> 1239 <span class="md-ellipsis"> 1240 1241 Dataloader state 1242 1243 </span> 1244 </a> 1245 1246</li> 1247 1248 <li class="md-nav__item"> 1249 <a href="#torchft" class="md-nav__link"> 1250 <span class="md-ellipsis"> 1251 1252 TorchFT 1253 1254 </span> 1255 </a> 1256 1257</li> 1258 1259 <li class="md-nav__item"> 1260 <a href="#directory-hierarchy" class="md-nav__link"> 1261 <span class="md-ellipsis"> 1262 1263 Directory hierarchy 1264 1265 </span> 1266 </a> 1267 1268</li> 1269 1270 <li class="md-nav__item"> 1271 <a href="#runner-state-layout" class="md-nav__link"> 1272 <span class="md-ellipsis"> 1273 1274 Runner state layout 1275 1276 </span> 1277 </a> 1278 1279</li> 1280 1281 <li class="md-nav__item"> 1282 <a href="#runner-construction" class="md-nav__link"> 1283 <span class="md-ellipsis"> 1284 1285 Runner Construction 1286 1287 </span> 1288 </a> 1289 1290</li> 1291 1292 <li class="md-nav__item"> 1293 <a href="#parallel-topology" class="md-nav__link"> 1294 <span class="md-ellipsis"> 1295 1296 Parallel topology 1297 1298 </span> 1299 </a> 1300 1301</li> 1302 1303 <li class="md-nav__item"> 1304 <a href="#pipeline-aware-hooks" class="md-nav__link"> 1305 <span class="md-ellipsis"> 1306 1307 Pipeline-aware hooks 1308 1309 </span> 1310 </a> 1311 1312</li> 1313 1314 <li class="md-nav__item"> 1315 <a href="#platform-support" class="md-nav__link"> 1316 <span class="md-ellipsis"> 1317 1318 Platform support 1319 1320 </span> 1321 </a> 1322 1323</li> 1324 1325 </ul> 1326 1327</nav> 1328 </div> 1329 </div> 1330 </div> 1331 1332 1333 1334 <div class="md-content" data-md-component="content"> 1335 1336 <article class="md-content__inner md-typeset"> 1337 1338 1339 1340 1341 1342 1343 1344 1345<h1 id="danling-runner">DanLing Runner<a class="headerlink" href="#danling-runner" title="Permanent link">¶</a></h1> 1346<p>DanLing runners are now <strong>Torch-only</strong> and focus on scalable distributed training.</p> 1347<p>The new design borrows from TorchTitan’s Trainer philosophy:</p> 1348<ul> 1349<li>A single, explicit training lifecycle</li> 1350<li>Backend-agnostic extension through <code>Runner</code>, with opt-in stack-specific subclasses when needed</li> 1351<li>Backend-specific distributed logic in dedicated subclass runners</li> 1352<li>Minimal shared contracts in <code>BaseRunner</code></li> 1353</ul> 1354<h2 id="core-apis">Core APIs<a class="headerlink" href="#core-apis" title="Permanent link">¶</a></h2> 1355<ul> 1356<li><code>RunnerConfig</code>: <code>chanfig</code>-based long-term configuration surface</li> 1357<li><code>Runner</code>: stack-selecting backend-agnostic entrypoint (<code>ddp</code>/<code>torch</code>, <code>deepspeed</code>/<code>ds</code>, <code>parallel</code>; default <code>ddp</code>)</li> 1358<li><code>TorchRunner</code>: shared Torch training core with explicit epoch-mode and step-mode loops</li> 1359<li><code>TorchRunner</code> / <code>ParallelRunner</code> / <code>DeepSpeedRunner</code>: class-based stack runners</li> 1360</ul> 1361<h2 id="common-workflows">Common workflows<a class="headerlink" href="#common-workflows" title="Permanent link">¶</a></h2> 1362<p>The default entrypoint is direct:</p> 1363<ul> 1364<li>Scratch: <code>runner = Runner(config)</code></li> 1365<li>Resume full training state: <code>runner = Runner.from_checkpoint(checkpoint)</code> or <code>runner.load_checkpoint(checkpoint)</code></li> 1366<li>Initialize model weights only: <code>runner = Runner.from_pretrained(config, checkpoint)</code> or <code>runner.load_pretrained(checkpoint)</code></li> 1367</ul> 1368<p>The config keys follow the same split:</p> 1369<table> 1370<thead> 1371<tr> 1372<th>Key</th> 1373<th>Meaning</th> 1374</tr> 1375</thead> 1376<tbody> 1377<tr> 1378<td><code>checkpoint</code></td> 1379<td>Explicit full-state checkpoint source. Loads runner state, model/EMA, optimizer, scheduler, and dataloaders.</td> 1380</tr> 1381<tr> 1382<td><code>resume</code></td> 1383<td>Boolean auto-resume switch. When <code>True</code>, loads <code>latest</code> from the current run checkpoint directory.</td> 1384</tr> 1385<tr> 1386<td><code>pretrained</code></td> 1387<td>Model-only initialization source. Loads EMA/model weights and leaves optimizer, scheduler, runner state, and dataloaders untouched.</td> 1388</tr> 1389<tr> 1390<td><code>ckpt</code></td> 1391<td>Checkpoint write policy only: backend, directory, async mode, interval, retention, export dtype, and write enablement.</td> 1392</tr> 1393</tbody> 1394</table> 1395<p>Load-source precedence is <code>checkpoint</code> > <code>resume</code> > <code>pretrained</code>.</p> 1396<p>Common config shapes:</p> 1397<div class="language-yaml highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">YAML</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"> 1</span> 1398<span class="normal"> 2</span> 1399<span class="normal"> 3</span> 1400<span class="normal"> 4</span> 1401<span class="normal"> 5</span> 1402<span class="normal"> 6</span> 1403<span class="normal"> 7</span> 1404<span class="normal">
1404 8</span> 1405<span class="normal"> 9</span> 1406<span class="normal">10</span> 1407<span class="normal">11</span> 1408<span class="normal">12</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="c1"># Resume from a known full-state checkpoint.</span> 1409<span class="nt">checkpoint</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">experiments/lin-<code_id>/<id>/checkpoints/latest.pth</span> 1410 1411<span class="c1"># Or auto-resume from this run's own latest checkpoint.</span> 1412<span class="nt">resume</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span> 1413 1414<span class="c1"># Finetune from model weights only.</span> 1415<span class="nt">pretrained</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">experiments/lin-<code_id>/<id>/checkpoints/model.pth</span> 1416 1417<span class="c1"># Disable all checkpoint writes while still allowing checkpoint/pretrained loading.</span> 1418<span class="nt">ckpt</span><span class="p">:</span> 1419<span class="w"> </span><span class="nt">enabled</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">false</span> 1420</code></pre></div></td></tr></table></div> 1421<p><code>ckpt.enabled=False</code> disables <code>latest</code>, <code>best</code>, history, and <code>model</code> writes. It does not disable reads from 1422<code>checkpoint</code>, <code>resume</code>, or <code>pretrained</code>. 1423CLI overrides use the same keys, for example <code>--checkpoint ...</code>, <code>--resume</code>, <code>--pretrained ...</code>, or 1424<code>--ckpt.enabled false</code>.</p> 1425<h2 id="baserunner-contract">BaseRunner contract<a class="headerlink" href="#baserunner-contract" title="Permanent link">¶</a></h2> 1426<p><code>BaseRunner</code> is inheritance-first and keeps only cross-backend functionality. 1427There is no plugin/spec registry layer.</p> 1428<p>Construction is intentionally direct: subclasses set concrete components in 1429<code>__init__</code>, call <code>super().__init__(config)</code>, then assign model/data/optimizer 1430objects. <code>MetaRunner</code> invokes <code>__post_init__</code> after subclass construction so 1431concrete runners can materialize models, optimizers, checkpoint state, and 1432metadata once user-owned attributes are present.</p> 1433<p>Execution API stubs in <code>BaseRunner</code> (all overridable):</p> 1434<ul> 1435<li><code>train</code> / <code>train_epoch</code> / <code>train_steps</code> / <code>train_step</code></li> 1436<li><code>evaluate</code> / <code>evaluate_epoch</code> / <code>evaluate_steps</code> / <code>evaluate_step</code></li> 1437<li><code>infer</code></li> 1438</ul> 1439<p>Step-mode semantics:</p> 1440<ul> 1441<li><code>train</code> dispatches to <code>train_steps</code> when <code>epochs</code> is unset (<code>is_step_mode=True</code>).</li> 1442<li><code>TorchRunner</code> keeps epoch-mode and step-mode loops separate on purpose to keep control flow local and 1443 override points explicit.</li> 1444<li><code>evaluate_steps(split, steps=None)</code> is always bounded-step evaluation. 1445 When <code>steps</code> is omitted, it defaults to <code>max(steps_budget // 20, 1)</code>.</li> 1446</ul> 1447<p>Checkpoint/score contracts (all overridable):</p> 1448<ul> 1449<li><code>load_model</code></li> 1450<li><code>read_checkpoint</code></li> 1451<li><code>load_optimizer</code> / <code>load_scheduler</code></li> 1452<li><code>load_state_dict</code></li> 1453<li><code>scores</code></li> 1454<li><code>best_index</code></li> 1455</ul> 1456<h2 id="checkpoint-semantics">Checkpoint semantics<a class="headerlink" href="#checkpoint-semantics" title="Permanent link">¶</a></h2> 1457<p>The user-facing checkpoint contract is intentionally small:</p> 1458<ul> 1459<li><code>latest</code>: the most recent persisted full-state checkpoint.</li> 1460<li><code>best</code>: the best persisted full-state checkpoint, updated only when <code>save_best=True</code> and the current score is best.</li> 1461<li><code>model</code>: a model-only checkpoint written after normal training completion for publishing or <code>pretrained</code> loading.</li> 1462<li>History checkpoints: periodic snapshots created by the training loop.</li> 1463<li>epoch mode: <code>ckpt-e{completed_epoch:06d}</code></li> 1464<li>step mode: <code>ckpt-s{global_step:012d}</code></li> 1465<li><code>ckpt.keep_latest_k</code>: number of framework-generated historical checkpoints to retain. 1466 <code>0</code> disables automatic retention pruning. When enabled, current <code>latest</code> and <code>best</code> targets are protected.</li> 1467</ul> 1468<p>Periodic checkpoint attempts are controlled by <code>ckpt.interval</code>. 1469When <code>ckpt.interval</code> is unset, runner defaults are used by mode (<code>epochs</code>: every epoch, <code>steps</code>: budget/20). 1470Forced checkpoints, including final and graceful-shutdown checkpoints, bypass the interval and update <code>latest</code>. 1471Normal training completion also writes <code>model</code> without changing <code>latest</code>, <code>best</code>, or history aliases. 1472All checkpoint writes are gated by <code>ckpt.enabled</code>; loading paths are independent.</p> 1473<p>
1473Backend storage is an implementation detail:</p> 1474<ul> 1475<li>File backend stores <code>latest.pth</code>, <code>best.pth</code>, and <code>ckpt-*.pth</code>. 1476 <code>best</code> and history files are updated from <code>latest</code> via hardlink-first aliasing with copy fallback. 1477 It is intended for local, single-process, and small-run workflows. In async mode it snapshots live tensors before 1478 background writes; use DCP for distributed or large-model training.</li> 1479<li>DCP backend exposes the same logical names (<code>latest</code>, <code>best</code>, <code>ckpt-*</code>) but stores immutable physical target directories plus pointer files. 1480 This avoids overwriting checkpoints while async writers or external readers may still hold references.</li> 1481<li>DeepSpeed full-state saves use engine checkpoint tag directories plus pointer files for <code>latest</code>, <code>best</code>, and history names. 1482 DeepSpeed model-only export still writes a DanLing <code>model</code> payload for publication and <code>pretrained</code> loading.</li> 1483<li>Retention policy is enforced by DanLing-managed file and DCP checkpoint managers.</li> 1484</ul> 1485<p>Rank participation contract:</p> 1486<ul> 1487<li><code>BaseRunner.save_checkpoint</code> and <code>save_model_checkpoint</code> delegate participation to the active checkpoint manager: 1488 file-style managers write on the main process; collective managers require all participating ranks to enter the call.</li> 1489<li><code>TorchRunner</code> uses the configured manager (<code>file</code>, <code>dcp</code>, or TorchFT-backed DCP) for full-state and model-only saves.</li> 1490<li><code>DeepSpeedRunner.save_checkpoint</code> uses DeepSpeed engine checkpointing for full-state saves; all ranks participate in those saves.</li> 1491<li><code>DeepSpeedRunner.save_model_checkpoint</code> exports the unwrapped engine module as a DanLing model-only checkpoint for publication or <code>pretrained</code>.</li> 1492<li>When <code>config.ft.enabled=True</code> under <code>TorchRunner</code>/DDP or <code>ParallelRunner</code> FSDP, full DCP saves are gated to the TorchFT participating replica group. 1493 Other replica groups save only their per-replica dataloader state.</li> 1494</ul> 1495<p>Checkpoint persistence internals are implemented under <code>danling.runners.checkpoints</code>:</p> 1496<ul> 1497<li><code>CheckpointManager</code>: base contract</li> 1498<li><code>FileCheckpointManager</code>: default async filesystem manager with reliable history/best queueing plus latest-wins coalescing for non-critical saves</li> 1499<li><code>TorchDistributedCheckpointManager</code>: Torch DCP backend used when <code>ckpt.backend="dcp"</code> in <code>TorchRunner</code></li> 1500</ul> 1501<p><code>ParallelRunner</code> forces <code>ckpt.backend="dcp"</code> by default.</p> 1502<h2 id="dataloader-state">Dataloader state<a class="headerlink" href="#dataloader-state" title="Permanent link">¶</a></h2> 1503<p>Full-state checkpoints include split-keyed dataloader progress under the top-level 1504<code>dataloaders</code> payload.</p> 1505<ul> 1506<li><code>TorchRunner.build_dataloaders()</code> uses <code>StatefulDataLoader</code> for datasets that have not already been materialized.</li> 1507<li>User-provided dataloaders participate when they implement <code>state_dict()</code> and <code>load_state_dict()</code>.</li> 1508<li>Non-stateful dataloaders are skipped rather than wrapped or special-cased.</li> 1509<li><code>BaseRunner.load_checkpoint()</code> restores dataloaders after model/EMA/optimizer/scheduler state.</li> 1510<li>DCP checkpoints carry dataloader state in the main checkpoint payload.</li> 1511<li>With TorchFT enabled, per-replica dataloader checkpoints take precedence over the main checkpoint dataloader payload during restore.</li> 1512<li><code>ParallelRunner</code> middle-stage proxy loaders delegate <code>state_dict()</code> and <code>load_state_dict()</code> to the real first-stage loader while yielding placeholders locally.</li> 1513</ul> 1514<h2 id="torchft">TorchFT<a class="headerlink" href="#torchft" title="Permanent link">¶</a></h2> 1515<p>DanLing has an opt-in TorchFT integration for replicated-weight runners:</p> 1516<ul> 1517<li>enable with <code>config.ft.enabled=True</code></li> 1518<li>configure replica layout with:</li> 1519<li><code>ft.replica_id</code></li> 1520<li><code>ft.group_size</code></li> 1521<li><code>ft.min_replica_size</code></li> 1522<li><code>ft.process_group</code></li> 1523<li><code>ft.process_group_timeout_seconds</code></li> 1524<li>requires the external <code>torchft</code> package and a TorchFT lighthouse setup</li> 1525</ul> 1526<p>Current scope:</p> 1527<ul> 1528<li>supported: <code>TorchRunner</code>
1528/DDP, <code>ParallelRunner</code> FSDP without tensor/pipeline axes</li> 1529<li>not yet supported: <code>ParallelRunner</code> tensor/pipeline runs, <code>DeepSpeedRunner</code></li> 1530</ul> 1531<p>Current launch contract:</p> 1532<ul> 1533<li>launch one <code>torchrun</code> per replica group</li> 1534<li><code>WORLD_SIZE</code> is replica-local data-parallel size, while <code>ft.group_size</code> counts replica groups</li> 1535<li>a single global <code>torchrun</code> spanning all replica groups is not a supported TorchFT launch mode</li> 1536</ul> 1537<p>When TorchFT is enabled:</p> 1538<ul> 1539<li>dataloader sharding and seed bias are expanded across replica groups using 1540 <code>ft.replica_id</code> and <code>ft.group_size</code></li> 1541<li>FSDP2 replicated-dimension all-reduce hooks use TorchFT-managed process groups</li> 1542<li>loss/normalizer logging reductions use the TorchFT managed replica group when available</li> 1543<li>per-replica dataloader checkpoints are enabled automatically through the DCP checkpoint manager and win over main-checkpoint dataloader state on restore</li> 1544</ul> 1545<p>Distributed state-dict invariants:</p> 1546<ul> 1547<li>Parallel distributed runs require DCP state-dict APIs for model/optimizer restore.</li> 1548<li>Checkpoint restore order is model -> EMA -> optimizer -> scheduler -> dataloaders.</li> 1549<li>File checkpoint fallback is only for non-distributed/basic flows.</li> 1550</ul> 1551<p>Async policy is configured by <code>ckpt.async_mode</code>:</p> 1552<ul> 1553<li><code>disabled</code>: synchronous checkpoint writes</li> 1554<li><code>async</code>: asynchronous uploads</li> 1555<li><code>async_with_pinned_mem</code>: process-based async uploads with staging hook support (<code>maybe_wait_for_staging</code>)</li> 1556</ul> 1557<h2 id="directory-hierarchy">Directory hierarchy<a class="headerlink" href="#directory-hierarchy" title="Permanent link">¶</a></h2> 1558<p>DanLing now uses a stable run layout with per-attempt timestamps:</p> 1559<p><code>workspace.root/workspace.lineage[-code_id]/id</code></p> 1560<ul> 1561<li><code>workspace.lineage</code>: top-level lineage namespace</li> 1562<li><code>code_id</code>: git code identity (<code><short_sha></code> for clean trees, <code><short_sha>-d<diff_sha10></code> when dirty) appended to <code>workspace.lineage</code> when available</li> 1563<li><code>config_id</code>: low 48 bits of <code>config.fingerprint()</code> as 12 lowercase hexadecimal digits, cached on first access</li> 1564<li><code>id</code>: stable run identifier, defaults to <code>code_id-config_id</code> when git metadata is available and <code>config_id</code> otherwise</li> 1565<li><code>timestamp</code>: per-attempt runtime timestamp</li> 1566<li><code>workspace.experiment</code>: experiment label used in the default runner name and W&B group; it is not a path segment unless user code includes it in <code>workspace.dir</code></li> 1567</ul> 1568<p><code>config.fingerprint()</code> recomputes an unsigned 64-bit integer from the first eight bytes 1569of SHA-1 over the UTF-8 canonical YAML (big-endian byte order). Configurations remain 1570mutable and unhashable. Runtime-only settings are omitted by <code>canonical()</code>.</p> 1571<p>By default:</p> 1572<ul> 1573<li><code>dir</code> points to <code>workspace.root/workspace.lineage[-code_id]/id</code></li> 1574<li>checkpoints are stored at <code>ckpt.dir</code> (default <code>dir/checkpoints</code>)</li> 1575<li>result snapshots are stored at <code>dir</code></li> 1576<li>logs are stored at <code>logging.file</code> (default <code>dir/logs/{timestamp}.log</code>)</li> 1577<li>tensorboard logs are stored as <code>dir/tensorboard/{timestamp}</code></li> 1578<li>W&B local run files default to <code>dir/wandb/</code> when W&B logging is enabled</li> 1579<li>MLflow tracking uses <code>mlflow.experiment_name</code> or defaults to <code>workspace.lineage</code></li> 1580<li>reproducibility artifacts are stored at <code>dir/metadata</code>:</li> 1581<li><code>config.full.yaml</code></li> 1582<li><code>config.canonical.yaml</code></li> 1583<li><code>config.diff.yaml</code> (diff against baseline/default config)</li> 1584<li><code>git.yaml</code></li> 1585<li><code>git.diff</code></li> 1586<li>logging is initialized on the global main process only</li> 1587</ul> 1588<p><code>id</code> is stable across retries for the same run. <code>timestamp</code> changes for each attempt.</p> 1589<h2 id="runner-state-layout">Runner state layout<a class="headerlink" href="#runner-state-layout" title="Permanent link">¶</a></h2> 1590<p><code>BaseRunner</code> uses a small checkpointed runtime boundary:</p> 1591<ul> 1592<li><code>runner</code>: config snapshot used for semantic resume validation</li> 1593<li><code>state</code>: <code>RunnerState</code> training metadata (<code>train</code>, <code>elastic</code>, <code>rng</code>)</li> 1594<li><code>dataloaders</code>: split-keyed progress for stateful dataloaders</li> 1595</ul> 1596<p>Concrete runners and checkpoint managers add model/EMA/optimizer/scheduler payloads 1597around that shared boundary. Runtime metadata (<code>timestamp</code>, <code>mode</code>) and live 1598trainable/data/metric objects (<code>model</code>, <code>optimizer</code>, <code>datasets</code>, <code>dataloaders</code>, 1599<code>results</code>, <code>meters</code>, etc.) stay as direct runner attributes for minimal 1600indirection in hot paths.</p> 1601<h2 id="runner-construction">Runner Construction<a class="headerlink" href="#runner-construction" title="Permanent link">¶</a></h2> 1602<p><code>TorchRunner</code> is explicit-first: define components in your runner <code>__init__</code>.</p> 1603<p>Example:</p> 1604<div class="language-python highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Python</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"> 1</span> 1605<span class="normal"> 2</span> 1606<span class="normal"> 3</span> 1607<span class="normal"> 4</span> 1608<span class="normal"> 5</span> 1609<span class="normal"> 6</span> 1610<span class="normal"> 7</span> 1611<span class="normal">
1611 8</span> 1612<span class="normal"> 9</span> 1613<span class="normal">10</span> 1614<span class="normal">11</span> 1615<span class="normal">12</span> 1616<span class="normal">13</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">danling</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">dl</span> 1617<span class="kn">from</span><span class="w"> </span><span class="nn">torch</span><span class="w"> </span><span class="kn">import</span> <span class="n">nn</span> 1618 1619 1620<span class="k">class</span><span class="w"> </span><span class="nc">MyRunner</span><span class="p">(</span><span class="n">dl</span><span class="o">.</span><span class="n">TorchRunner</span><span class="p">):</span> 1621 <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">config</span><span class="p">):</span> 1622 <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">config</span><span class="p">)</span> 1623 <span class="bp">self</span><span class="o">.</span><span class="n">model</span> <span class="o">=</span> <span class="n">MyModel</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">model</span><span class="p">)</span> 1624 <span class="bp">self</span><span class="o">.</span><span class="n">criterion</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">CrossEntropyLoss</span><span class="p">()</span> 1625 <span class="bp">self</span><span class="o">.</span><span class="n">optimizer</span> <span class="o">=</span> <span class="n">dl</span><span class="o">.</span><span class="n">OPTIMIZERS</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">params</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">parameters</span><span class="p">(),</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">optim</span><span class="p">)</span> 1626 1627<span class="n">config</span> <span class="o">=</span> <span class="n">dl</span><span class="o">.</span><span class="n">RunnerConfig</span><span class="p">()</span> 1628<span class="n">runner</span> <span class="o">=</span> <span class="n">MyRunner</span><span class="p">(</span><span class="n">config</span><span class="p">)</span> 1629</code></pre></div></td></tr></table></div> 1630<p>For class-based stack presets:</p> 1631<div class="language-python highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Python</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"> 1</span> 1632<span class="normal"> 2</span> 1633<span class="normal"> 3</span> 1634<span class="normal"> 4</span> 1635<span class="normal"> 5</span> 1636<span class="normal"> 6</span> 1637<span class="normal"> 7</span> 1638<span class="normal"> 8</span> 1639<span class="normal"> 9</span> 1640<span class="normal">10</span> 1641<span class="normal">11</span> 1642<span class="normal">12</span> 1643<span class="normal">13</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">danling</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">dl</span> 1644 1645<span class="c1"># Default entrypoint is DDP preset:</span> 1646<span class="n">runner</span> <span class="o">=</span> <span class="n">dl</span><span class="o">.</span><span class="n">Runner</span><span class="p">(</span><span class="n">config</span><span class="p">)</span> <span class="c1"># -> TorchRunner by default</span> 1647 1648<span class="c1"># Explicit preset classes:</span> 1649<span class="n">
1649ddp_runner</span> <span class="o">=</span> <span class="n">dl</span><span class="o">.</span><span class="n">TorchRunner</span><span class="p">(</span><span class="n">config</span><span class="p">)</span> 1650<span class="n">parallel_runner</span> <span class="o">=</span> <span class="n">dl</span><span class="o">.</span><span class="n">ParallelRunner</span><span class="p">(</span><span class="n">config</span><span class="p">)</span> 1651 1652<span class="c1"># Stack selection through Runner:</span> 1653<span class="n">cfg</span> <span class="o">=</span> <span class="n">dl</span><span class="o">.</span><span class="n">RunnerConfig</span><span class="p">(</span><span class="n">config</span><span class="p">)</span> 1654<span class="n">cfg</span><span class="o">.</span><span class="n">stack</span> <span class="o">=</span> <span class="s2">"parallel"</span> 1655<span class="n">parallel_from_runner</span> <span class="o">=</span> <span class="n">dl</span><span class="o">.</span><span class="n">Runner</span><span class="p">(</span><span class="n">cfg</span><span class="p">)</span> 1656</code></pre></div></td></tr></table></div> 1657<h2 id="parallel-topology">Parallel topology<a class="headerlink" href="#parallel-topology" title="Permanent link">¶</a></h2> 1658<p>Parallel topology is configured through semantic axes:</p> 1659<div class="language-yaml highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">YAML</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span> 1660<span class="normal">2</span> 1661<span class="normal">3</span> 1662<span class="normal">4</span> 1663<span class="normal">5</span> 1664<span class="normal">6</span> 1665<span class="normal">7</span> 1666<span class="normal">8</span> 1667<span class="normal">9</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="nt">parallel</span><span class="p">:</span> 1668<span class="w"> </span><span class="nt">axes</span><span class="p">:</span> 1669<span class="w"> </span><span class="nt">replicate</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">1</span> 1670<span class="w"> </span><span class="nt">shard</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">8</span> 1671<span class="w"> </span><span class="nt">context</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">1</span> 1672<span class="w"> </span><span class="nt">pipeline</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">4</span> 1673<span class="w"> </span><span class="nt">tensor</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">8</span> 1674<span class="w"> </span><span class="nt">expert</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">1</span> 1675<span class="w"> </span><span class="nt">expert_tensor</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">1</span> 1676</code></pre></div></td></tr></table></div> 1677<p>Data loading and metric reduction are scoped to the logical <code>data</code> domain. 1678Middle pipeline stages automatically use step-only proxy loaders so pipeline schedules 1679preserve step count and dataloader state without consuming real input batches locally. 1680Optimizer control decisions, such as non-finite-gradient skip, are reduced over 1681the <code>optimizer</code> domain covering all configured parallel axes so stages/shards do 1682not diverge on step/skip boundaries. 1683<code>TorchRunner</code>-based stacks build <code>torchdata.stateful_dataloader.StatefulDataLoader</code> 1684by default so train dataloader progress is checkpointable across restart paths. 1685Explicit user-provided dataloaders are not rewrapped.</p> 1686<p><code>ParallelRunner</code> exposes topology-, pipeline-, and FSDP-aware extension points:</p> 1687<ul> 1688<li><code>build_topology</code>: validate/construct ordered parallel axes from config + world state</li> 1689<li><code>init_model_parallel_groups</code>: initialize model-parallel process groups/device mesh</li> 1690<li><code>parallelize_model</code>: apply model-specific TP/CP/EP transforms before compile/FSDP wrapping</li> 1691<li><code>build_pipeline_schedule</code>: build <code>torch.distributed.pipelining</code> schedule from config</li> 1692<li><code>bind_pipeline_modules</code>: bind local model parts to pipeline stages</li> 1693<li><code>apply_activation_checkpointing</code>: wrap local model parts before compile/FSDP wrapping</li> 1694<li><code>fsdp_kwargs</code> / <code>build_mixed_precision_policy</code> / <code>build_offload_policy</code>: customize FSDP wrapping policy</li> 1695<li><code>build_optimizer</code>: deduplicate parameters across local model parts before optimizer build</li> 1696</ul> 1697<p>If any of <code>parallel.axes.tensor</code>, <code>parallel.axes.context</code>, <code>parallel.axes.expert</code>, 1698or <code>parallel.axes.expert_tensor</code> is greater than <code>1</code>, the model must either expose 1699<code>model.parallelize(parallel_context)</code> or the runner must override 1700<code>parallelize_model</code>. DanLing intentionally does not silently no-op model-parallel 1701axes, because TP/CP/EP transforms are model-architecture specific.</p> 1702<h2 id="pipeline-aware-hooks">Pipeline-aware hooks<a class="headerlink" href="#pipeline-aware-hooks" title="Permanent link">¶</a></h2> 1703<p><code>TorchRunner</code> exposes core training hooks that can be overridden:</p> 1704<ul> 1705<li><code>train_context</code></li> 1706</ul> 1707<p><code>ParallelRunner</code> wires pipeline execution through <code>build_pipeline_schedule</code> and 1708<code>bind_pipeline_modules</code>, and routes train/eval/infer paths based on whether a 1709pipeline schedule is active.</p> 1710<p>When <code>parallel.axes.pipeline > 1</code> and no explicit schedule is provided, <code>ParallelRunner</code> now 1711builds a <code>torch.distributed.pipelining</code> schedule internally from 1712<code>config.parallel.pipeline_schedule</code> (default: <code>"1F1B"</code>). The default is intentionally 1713non-interleaved for current pipeline+FSDP stability, with migration to 1714<code>"Interleaved1F1B"</code> planned after upstream issue 1715<code>pytorch/pytorch#164756</code> is resolved.</p> 1716<h2 id="platform-support">Platform support<a class="headerlink" href="#platform-support" title="Permanent link">¶</a></h2> 1717<p>Supported runner stacks:</p> 1718<table> 1719<thead> 1720<tr> 1721<th>Stack</th> 1722<th>Full-state checkpoint path</th> 1723<th>
1723Model-only export</th> 1724<th>Stateful dataloaders</th> 1725<th>TorchFT runtime</th> 1726</tr> 1727</thead> 1728<tbody> 1729<tr> 1730<td><code>torch</code> / <code>ddp</code></td> 1731<td>file default, DCP opt-in</td> 1732<td>DanLing payload</td> 1733<td>default for built loaders</td> 1734<td>supported</td> 1735</tr> 1736<tr> 1737<td><code>parallel</code></td> 1738<td>DCP default</td> 1739<td>DCP/DanLing model payload</td> 1740<td>default plus pipeline proxy state delegation</td> 1741<td>FSDP-only supported</td> 1742</tr> 1743<tr> 1744<td><code>deepspeed</code> / <code>ds</code></td> 1745<td>DeepSpeed engine tag directories plus DanLing pointer files</td> 1746<td>DanLing payload</td> 1747<td>default for built loaders via client state</td> 1748<td>not supported</td> 1749</tr> 1750</tbody> 1751</table> 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 <aside class="md-source-file"> 1766 1767 1768 <span class="md-source-file__fact"> 1769 <span class="md-icon" title="Last update"> 1770 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg> 1771 </span> 1772 <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_datetime" title="August 9, 2024 08:24:01 UTC">2024-08-09 08:24:01</span> 1773 </span> 1774 1775 1776 1777 1778 1779 </aside> 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789<!-- Giscus -->
1790<script 1791 src="https://giscus.app/client.js" 1792 data-repo="ZhiyuanChen/DanLing" 1793 data-repo-id="R_kgDOGv-RWA" 1794 data-category="General" 1795 data-category-id="DIC_kwDOGv-RWM4CTx_d" 1796 data-mapping="pathname" 1797 data-strict="0" 1798 data-reactions-enabled="1" 1799 data-emit-metadata="1" 1800 data-input-position="top" 1801 data-theme="preferred_color_scheme" 1802 data-lang="en" 1803 data-loading="lazy" 1804 crossorigin="anonymous" 1805 async 1806></script>
1806 1807 1808<!-- Reload on palette change -->
1809<script> 1810 var palette = __md_get("__palette"); 1811 if (palette && typeof palette.color === "object") 1812 if (palette.color.scheme === "slate") { 1813 var giscus = document.querySelector("script[src*=giscus]"); 1814 giscus.setAttribute("data-theme", "dark"); 1815 } 1816 1817 /* Register event handlers after documented loaded */ 1818 document.addEventListener("DOMContentLoaded", function () { 1819 var ref = document.querySelector("[data-md-component=palette]"); 1820 ref.addEventListener("change", function () { 1821 var palette = __md_get("__palette"); 1822 if (palette && typeof palette.color === "object") { 1823 var theme = palette.color.scheme === "slate" ? "dark" : "light"; 1824 1825 /* Instruct Giscus to change theme */ 1826 var frame = document.querySelector(".giscus-frame"); 1827 frame.contentWindow.postMessage( 1828 { giscus: { setConfig: { theme } } }, 1829 "https://giscus.app", 1830 ); 1831 } 1832 }); 1833 }); 1834</script>
1834 1835 1836 </article> 1837 </div> 1838 1839 1840
1840<script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script>
1840 1841
1842<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
1842 1843 </div> 1844 1845 <button type="button" class="md-top md-icon" data-md-component="top" hidden> 1846 1847 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> 1848 Back to top 1849</button> 1850 1851 </main> 1852 1853 <footer class="md-footer"> 1854 1855 1856 1857 <nav class="md-footer__inner md-grid" aria-label="Footer" > 1858 1859 1860 <a href=".." class="md-footer__link md-footer__link--prev" aria-label="Previous: DanLing"> 1861 <div class="md-footer__button md-icon"> 1862 1863 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg> 1864 </div> 1865 <div class="md-footer__title"> 1866 <span class="md-footer__direction"> 1867 Previous 1868 </span> 1869 <div class="md-ellipsis"> 1870 DanLing 1871 </div> 1872 </div> 1873 </a> 1874 1875 1876 1877 <a href="config/" class="md-footer__link md-footer__link--next" aria-label="Next: RunnerConfig"> 1878 <div class="md-footer__title"> 1879 <span class="md-footer__direction"> 1880 Next 1881 </span> 1882 <div class="md-ellipsis"> 1883 RunnerConfig 1884 </div> 1885 </div> 1886 <div class="md-footer__button md-icon"> 1887 1888 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11z"/></svg> 1889 </div> 1890 </a> 1891 1892 </nav> 1893 1894 1895 <div class="md-footer-meta md-typeset"> 1896 <div class="md-footer-meta__inner md-grid"> 1897 <div class="md-copyright"> 1898 1899 <div class="md-copyright__highlight"> 1900 All rights reserved © 2021-Present, DanLing Team 1901 </div> 1902 1903 1904</div> 1905 1906 </div> 1907 </div> 1908</footer> 1909 1910 </div> 1911 <div class="md-dialog" data-md-component="dialog"> 1912 <div class="md-dialog__inner md-typeset"></div> 1913 </div> 1914 1915 1916 <div class="md-consent" data-md-component="consent" id="__consent" hidden> 1917 <div class="md-consent__overlay"></div> 1918 <aside class="md-consent__inner"> 1919 <form class="md-consent__form md-grid md-typeset" name="consent"> 1920 1921 1922 1923 1924 1925 1926<h4>Cookie Consent</h4> 1927<p>We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better. Please check out our <a href="https://danling.org/about/privacy">Privacy Notice</a> for more information.</p> 1928<input class="md-toggle" type="checkbox" id="__settings" > 1929<div class="md-consent__settings"> 1930 <ul class="task-list"> 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 <li class="task-list-item"> 1941 <label class="task-list-control"> 1942 <input type="checkbox" name="analytics" checked> 1943 <span class="task-list-indicator"></span> 1944 Google Analytics 1945 </label> 1946 </li> 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 <li class="task-list-item"> 1959 <label class="task-list-control"> 1960 <input type="checkbox" name="github" checked> 1961 <span class="task-list-indicator"></span> 1962 GitHub 1963 </label> 1964 </li> 1965 1966 1967 1968 1969 </ul> 1970</div> 1971<div class="md-consent__controls"> 1972 1973 1974 <button class="md-button md-button--primary">Accept</button> 1975 1976 1977 1978 1979 1980 1981 1982 <label class="md-button" for="__settings">Manage settings</label> 1983 1984 1985</div> 1986 </form> 1987 </aside> 1988 </div> 1989
1989<script>var consent=__md_get("__consent");if(consent)for(var input of document.forms.consent.elements)input.name&&(input.checked=consent[input.name]||!1);else"file:"!==location.protocol&&setTimeout((function(){document.querySelector("[data-md-component=consent]").hidden=!1}),250);var form=document.forms.consent;for(var action of["submit","reset"])form.addEventListener(action,(function(e){if(e.preventDefault(),"reset"===e.type)for(var n of document.forms.consent.elements)n.name&&(n.checked=!1);__md_set("__consent",Object.fromEntries(Array.from(new FormData(form).keys()).map((function(e){return[e,!0]})))),location.hash="",location.reload()}))</script>
1989 1990 1991 1992 1993 1994
1994<script id="__config" type="application/json">{"annotate": null, "base": "..", "features": ["announce.dismiss", "content.code.annotate", "content.code.copy", "content.code.select", "content.tabs.link", "content.tooltips", "header.autohide", "navigation.expand", "navigation.footer", "navigation.indexes", "navigation.prune", "navigation.sections", "navigation.tabs", "navigation.tabs.sticky", "navigation.top", "navigation.tracking", "search.highlight", "search.share", "search.suggest", "toc.follow"], "search": "../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
1994 1995 1996 1997
1997<script src="../assets/javascripts/bundle.d7400e89.min.js"></script>
1997 1998 1999
1999<script src="../javascripts/mathjax.js"></script>
1999 2000 2001
2001<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
2001 2002 2003
2003<script src="../javascripts/shortcuts.js"></script>
2003 2004 2005 2006
2006<script type="module" src="https://static.cloudflareinsights.com/beacon.min.js/v31edd6df95cf4e85bb4c19e7a9bdbcba1788362987495" integrity="sha512-iIg7k2xntmwu6/uSb5tpc/hySgZc4eoL31yB29W6tJFo2akwjPWcEqnCEdJvGexCL0KEQwVYv5BlowfhVz26hg==" data-cf-beacon='{"version":"2024.11.0","token":"9c892eda43914cc59e37016c23ab0870","r":1,"spa":2}' crossorigin="anonymous"></script>
2006 2007</body> 2008</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.