Repository navigation
Commit 5d395de
Link received payload objects into the core cache instead of copying (#125)
A rank export receives each cache payload object as a complete companion
wrapper in a synced temporary file in the core cache. `store_slice` then
hashes the received payload, copies it into a new wrapper in cache
staging, syncs the copy, and hashes the installed copy again: three full
reads and one write and sync per object, on the receiving stream's
thread. When the received file already is the wrapper `store_slice`
would write, the copy, its write and its sync repeat work whose result
is already on disk. In a DeepSeek V4.1 Flash TP3 export on three DGX
Spark GB10 hosts with an empty core cache, rank zero receives 203.5 GB
from the other two ranks this way.
Before this change the receiver always called `store_slice`. Now it
first calls the new `Root::adopt_companion`, which links the received
file itself into cache staging when it is byte-for-byte that wrapper;
both hashes remain. The link step is shared with directory publication,
which already hard-linked source files that are canonical wrappers from
its own code in `export.rs`; that code moves into
`container::link_companion`. It checks the length and leading bytes
against `companion_prefix`, links the opened file through its descriptor
so that a replaced path cannot be linked instead, checks that the link
names the same inode, and hashes the linked file against the declared
identity; a mismatched identity is an error. For a file that is not the
canonical wrapper, or a link the filesystem refuses, `link_companion`
returns false, `adopt_companion` returns `None`, and the receiver stores
the slice as before. Adoption checks and links the descriptor the
receiver opened, the same one `store_slice` copies from. An already
cached identity returns the verified cached object, as `store_slice`
does. Publication is unchanged: the object is made immutable, linked
under its identity and verified once more, and the receiver closes its
writable descriptor before the file is published. Core format, cache
layout and object identities are unchanged, and directory publication
keeps its behavior, error kinds and messages. Adoption needs Linux
(`linkat` through `/proc/self/fd`); on other platforms received objects
are copied as before.
Expected result: with an empty core cache, "Receive rank export
payloads" no longer copies, writes and syncs each received object. On an
earlier tree, with an earlier version of this adoption, that phase took
280.6 s instead of 457.8 s; this commit itself was not measured on its
current base.
Evidence: on `f9aec99c` with this commit, helios `cargo test --features
runtime-core,server --lib`: 1431 passed, 4 failed, 33 ignored. The 4
failures are chat-template tests that panic because
FLARE_TEST_TEMPLATE_DIR was not set; the same 4 fail on `f9aec99c`
without this commit, where 1430 pass. With that directory prepared by
tests/frontend/prepare_templates.py, the suite passed with this change
on its previous base `bbad44fe` (`--release`: 1335 passed, 0 failed, 26
ignored). heliopause `cargo test` on `f9aec99c` with this commit: 196
passed, 0 failed, 4 ignored. A helios test covers
adoption by link (same inode); a wrapper with an extra tensor and a
wrapper of the right length with different header bytes, both declined;
a mismatched identity, which is rejected; a second arrival of a cached
identity, which returns the cached object; and that cache staging is
empty after the declined, rejected and cached cases. A heliopause test
checks that the receiver's install step adopts a canonical wrapper (same
inode) and copies another framing into a new file. The existing
directory publication tests cover the shared link step. The 203.5 GB is
the byte count reported by "Receive rank export payloads" in an export
on `d2b5c5f3` without this change, with an empty core cache; there that
phase took 462.3 s. The measurement above used full TP3 exports with the
same model and export command, an empty core cache (then named the
package cache) and an empty forward compilation cache, built from
`ca1f960e` plus an earlier version of #124 that published cache payloads
concurrently and without the directory publication changes merged as
`e13ecb74`; its adoption step linked the received file by path instead
of through `link_companion`. There, with the default 8 transfer streams,
"Receive rank export payloads" took 280.6 s with adoption and 457.8 s
without it (477.2 s without it and `--transfer-streams 16`), and the
whole export phase took 1473.2 s against 1677.4 s; the package exported
with adoption served with `flare run` and answered a 262k-token prompt
that asks for 16 values placed through the context with all 16 correct,
with identical output with an empty and with a warm prefix cache. One
export per configuration was measured. The payload is still read twice
after it arrives (identity check and post-installation verification)
instead of being hashed while it streams.
Design-Signed-Off-By: Claude Fable 5.2; design-review=ed22
Signed-off-by: Javier López <59578422+javieratomic@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent e60a70d commit 5d395de
4 files changed
Lines changed: 279 additions & 113 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
741 | 741 | | |
742 | 742 | | |
743 | 743 | | |
744 | | - | |
745 | | - | |
746 | | - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
747 | 749 | | |
748 | 750 | | |
749 | 751 | | |
| |||
758 | 760 | | |
759 | 761 | | |
760 | 762 | | |
761 | | - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
762 | 767 | | |
763 | 768 | | |
764 | 769 | | |
| |||
1038 | 1043 | | |
1039 | 1044 | | |
1040 | 1045 | | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1041 | 1049 | | |
1042 | 1050 | | |
1043 | 1051 | | |
| |||
1444 | 1452 | | |
1445 | 1453 | | |
1446 | 1454 | | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
1447 | 1508 | | |
1448 | 1509 | | |
1449 | 1510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
1502 | 1502 | | |
1503 | 1503 | | |
1504 | 1504 | | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
| 1505 | + | |
1510 | 1506 | | |
1511 | 1507 | | |
1512 | 1508 | | |
| |||
1528 | 1524 | | |
1529 | 1525 | | |
1530 | 1526 | | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
1531 | 1569 | | |
1532 | 1570 | | |
1533 | 1571 | | |
| |||
4882 | 4920 | | |
4883 | 4921 | | |
4884 | 4922 | | |
| 4923 | + | |
| 4924 | + | |
| 4925 | + | |
| 4926 | + | |
| 4927 | + | |
| 4928 | + | |
| 4929 | + | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
| 4933 | + | |
| 4934 | + | |
| 4935 | + | |
| 4936 | + | |
| 4937 | + | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
| 4941 | + | |
| 4942 | + | |
| 4943 | + | |
| 4944 | + | |
| 4945 | + | |
| 4946 | + | |
| 4947 | + | |
| 4948 | + | |
| 4949 | + | |
| 4950 | + | |
| 4951 | + | |
| 4952 | + | |
| 4953 | + | |
| 4954 | + | |
| 4955 | + | |
| 4956 | + | |
| 4957 | + | |
| 4958 | + | |
| 4959 | + | |
| 4960 | + | |
| 4961 | + | |
| 4962 | + | |
| 4963 | + | |
| 4964 | + | |
| 4965 | + | |
| 4966 | + | |
| 4967 | + | |
| 4968 | + | |
| 4969 | + | |
| 4970 | + | |
| 4971 | + | |
| 4972 | + | |
| 4973 | + | |
| 4974 | + | |
| 4975 | + | |
| 4976 | + | |
| 4977 | + | |
| 4978 | + | |
| 4979 | + | |
| 4980 | + | |
| 4981 | + | |
| 4982 | + | |
| 4983 | + | |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
| 4987 | + | |
| 4988 | + | |
| 4989 | + | |
| 4990 | + | |
4885 | 4991 | | |
4886 | 4992 | | |
4887 | 4993 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
571 | 571 | | |
572 | 572 | | |
573 | 573 | | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
574 | 673 | | |
575 | 674 | | |
576 | 675 | | |
| |||
0 commit comments