Repository navigation
fabric/mcdma: ConnectX (RoCE v2) links (#1594, step 1) - #1957
Conversation
|
Thanks @ThinkOffApp. Reviewed against #1594's step-1 gate, and it's met. It's step 1 as its own PR, |
…uster runtime's picture
|
Thanks @ThinkOffApp. GLM-5.3-Flash NVFP4 TP=2 pair on two GB10s, main against this head ( |
a31063d to
ee4b2bb
Compare
ee4b2bb to
6b4c2c9
Compare
…shhart#1594, step 1) mcdma.zig refused every link MCDMA did not report as Thunderbolt. It now also takes MCDMA_FABRIC_ROCE (1) on one unbonded device, so a Mac and a Linux host can meet over ConnectX, and every Thunderbolt path stays as it was. - The kind MCDMA reports at connect is kept per port, so one endpoint can hold a Thunderbolt peer and a ConnectX peer. Any other kind, or ConnectX with a '+' bond or port lists, is UnsupportedLink. kind() is cx5 for a ConnectX port; tb5 and local as before, and an unknown peer still gives tb5. - Link.mtu is the RC path MTU: 1024, 2048 or 4096, default 4096 (the value open always had). Any other value is InvalidConfig before anything opens, since MCDMA would quietly run it at 1024. MCDMA's exchange does not carry it, so both ends must give the same value. - Link.kind (optional) names the kind MCDMA must report and refuses the other after connect. cx5 also refuses gid -1 (NeedGidIndex: MCDMA scans for a GID on Thunderbolt only) and a bond or port lists (UnsupportedLink) before anything opens. Null takes whichever kind connects. NeedGidIndex is the one new error name. - MCDMA has no fused write-and-signal on a RoCE link: it returns UNSUPPORTED, which surfaced as AccessDenied. On a ConnectX port write2Signal is write2 then signal (the path it already took for a local peer or an oversized write), and writeSignalFrom posts the write then the signal on the same RC queue pair. write2Signal checks the range and the flag before any path, so a bad flag is refused before anything is posted on either kind. Thunderbolt keeps the fused call with the same arguments. - Open and connect failures keep MCDMA's status: an open that returns UNSUPPORTED (a ConnectX bond, or MCDMA_FABRIC_QPS above 1) is UnsupportedLink, other opens stay OpenFailed and connects stay ConnectFailed. Each logs one line with the link, device, via, GID, path MTU and the status by MCDMA's name, with a hint for UNSUPPORTED, DEVICE, PEER and TIMEOUT. - mcdma_fabric_peer_status (additive ABI 1) is looked up as an optional symbol, so mcdma_abi.zig is unchanged: the first PeerDown on a port logs the link, the rank and MCDMA's reason once, and Endpoint.peerStatus returns that reason. - create is split into validate, create and start. createWith drives the endpoint over a fake library table (it and `roce` are public for mcdma_test.zig), and deinit closes only a library the endpoint opened. Tests (no hardware): fake-library tests in zig/src/fabric/mcdma_test.zig, which mcdma.zig's test block imports so mcdma.zig stays under 600 lines, for the MTU and kind checks, the refusals before open, the kept statuses, the exact Thunderbolt and ConnectX post sequences, write2Signal's checks before posting, a Thunderbolt peer and a ConnectX peer on one endpoint, and a peer that goes down failing by name. zig/tests/fabric_mcdma_stub.zig runs two mcdma.Endpoint ranks in one process over MCDMA's own libmcdma-fabric on its offline stub verbs: ConnectX at path MTU 1024 and 4096 and Thunderbolt with the same hashes on both ranks, a stopped peer on both kinds, and the named startup failures. tools/zig/test_fabric.sh passes the sys module the fabric tests have needed since the sys import, and builds and runs the stub test when TF_MCDMA_SRC has tests/stub_link_verbs.c.
step 1) Every shipped user of the MCDMA endpoint (core/pair.zig, core/pair_rows.zig, flashnext/tp.zig, glm/ep.zig) reads its link through tp_settings.read, which never read `mtu` or `kind`. Shipped TensorFold therefore always ran at path MTU 4096 with no declared kind, and could not reach a ConnectX port whose active MTU is below 4096 (a link through a switch may need 1024). - tp_settings.read takes an optional integer `mtu`: 1024, 2048 or 4096 (mcdma.path_mtus, now public), default 4096; anything else, or a string, is BadTpSettings. - It takes an optional string `kind`, "tb5" or "cx5", as fabric.rdma.LinkKind; another string or a non-string is BadTpSettings. Absent, the link takes whichever kind connects, as before. - Both go into mcdma.Link, which every caller passes unchanged to mcdma.Endpoint.create. A file without the keys parses to the same Link as before. - docs/n-link-speed-up.md describes both keys with a ConnectX example, and what a Mac ConnectX link needs: gid 0 (the MCDMA kext exposes only GID index 0) and a window plus both ranks' staging of at most 63 x 4 MiB (the kext registers at most 64 memory regions per context), so flashnext's and glm's windows do not fit one yet. Tests: mtu 1024 and kind cx5 parse; absent keys keep 4096 and null; mtu 1500, mtu "1024", kind "x", kind 2 and kind "nccl" are refused.
…hart#1594 step 1) The gate for a ConnectX link: on a Mac and a Linux host, every collective equals a host reference on both ends; a stopped peer or a dropped link fails by name, not a hang; a Thunderbolt link behaves as today. tf-mcdma-pair and its scripts make the hardware window copy, run, collect, and prove the whole flow offline first. No production code depends on them. - zig/tests/mcdma_pair.zig (zig build tf-mcdma-pair; tf-mcdma-pair-dist for aarch64-macos, aarch64-linux-gnu and x86_64-linux-gnu, linked against glibc 2.35 and needing its symbols up to GLIBC_2.34): one rank per process from a settings JSON. mcdma_pair.zig is the command line, mcdma_pair_rank.zig the settings and the rank's run, and mcdma_pair_suite.zig the tests. It runs barrier, broadcast from both roots, bf16 and f32 all-reduce against collective.reduce and an fp32 rank-order reference, uneven all-to-all, gather, pipes both ways, a bulk copy across the Mac's 4 MiB registration pieces, a signal storm that checks every landed value, and rounds of write2Signal and writeSignalFrom. Each test prints PASS or FAIL with a SHA-256 in an order both ranks share, beside the same hash over the host reference. The ranks first swap a run id and their settings (path MTU and any expected failure included) and refuse a mismatch by name. A watchdog names a step that stops making progress. Arms: exit, kill (SIGKILL), stop, hang, and external (an operator drops the link). On a Mac a ConnectX window past the kext's 64 memory regions is refused by name (TooManyRegions) before anything opens. --pair runs both ranks in one process, for MCDMA's offline stub verbs. - run_macos.sh and run_linux.sh run one side and collect its log, exit code and read-only host facts (kext UUID, port state, active MTU, GID, neighbours, memlock, clock offset), with a pre-flight WARN for anything that would spoil the run. Nothing in them uses sudo. - compare.py (with compare_log.py, which reads the logs and writes the receipt) checks both ends against the reference and each other, the arm's outcome with its timing and MCDMA's reason, each rank's settings against the plan, the run id, the pre-flight's WARNs, and --same-as another run, and writes a receipt. GATE PASS needs two hosts on MCDMA's libmcdma-fabric over librdma or libibverbs and the whole suite; a run that passes only because --same-host or --stub relaxed a check is OFFLINE PASS (not the gate), exit 5. - settings.py writes every run's settings (G1 to G5) and a PLAN.txt per host pair from a hosts file. hosts.example.json documents every field; real hosts files stay outside the tree. bundle.sh packs the three binaries, the scripts, the plans and MCDMA's fabric sources, and each host builds its own libmcdma-fabric with build_mcdma.sh. - README.md documents the binary, the scripts, the runs, compare.py's checks and the offline proof. - stub_proof.sh proves the harness offline through the same run scripts and compare.py: over MCDMA's stub verbs (both ranks in one process), over loop_fabric.c (a loopback TCP stand-in, not MCDMA) for the window's two-process flow and both kill arms, and through the runs compare.py must refuse, each for its own reason. build.zig adds both steps through zig/build/mcdma_pair.zig.
…a Linux rank agree (ashhart#1594 step 1) collective.Channel.bytes, collective.Pipe.bytes and cluster's fabric_link Layout aligned to rdma.page, which is std.heap.page_size_min: 16 KiB on macOS, 4 KiB on Linux. Two ranks on the same OS always agree. A Mac and a Linux host over ConnectX did not: each wrote the other's channel flags and slots at its own offsets (12 KiB apart for tf-mcdma-pair's plan channel), so every write landed and was acknowledged where the other end never looked, and both ends waited out PeerTimeout at the first exchange. - rdma.layout_align (16 KiB, the largest page among the supported hosts) is what those layouts align to now; page stays for allocations and mappings. - A Mac's layouts are unchanged (its page is already 16 KiB); a Linux host's channels and pipes start on 16 KiB boundaries, the same as a Mac's. - Found by tf-mcdma-pair's G1 between a Mac's ConnectX-5 (MCDMA) and a GB10's ConnectX-7 on a direct cable. A debug dump showed the plan channel at window offset 4931584 on the Mac and 4919296 on Linux, and each peer's flag at the sender's offset.
…alignment fails the tests (ashhart#1594 step 1) Same-OS tests could not see the Mac/Linux layout split the previous commit fixes: both ranks of a test share one host's page. These pin the numbers instead. - fabric_collective.zig: layout_align is 16384, Channel.bytes(2, 64) is 16384, Channel.bytes(2, 1228800) is 4931584 (tf-mcdma-pair's plan channel offset) and Pipe.bytes(64 KiB) is 147456. - fabric_link_test.zig: Layout.init(2, 4096, 64 KiB) has words at 32768, pipes at 49152 and a total of 638976. - With layout_align set to 4096 both fail (expected 16384, found 4096; expected 32768, found 20480), as a 4 KiB host page would on Linux. tools/zig/test_fabric.sh and the cluster tests pass.
6b4c2c9 to
3aa63bd
Compare
|
Thank you @ThinkOffApp. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
|
Thanks @ThinkOffApp! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3 |
What this changes
Step 1 of #1594, as asked there:
mcdma.zigtakes a ConnectX (RoCE v2) link beside Thunderbolt, with no arithmetic change and the Thunderbolt path's library calls unchanged. The tp settings file can ask for a ConnectX link (path MTU and kind),tf-mcdma-pairis the two-host gate harness, and Mac and Linux ranks now lay out their windows at the same offsets (the one real bug the gate found). Cluster and CLI wiring forserve --clusteron real hosts is step 2, after this lands.Base: main 088cfbd; it merges with today's main without conflicts. Five commits, each building on its own:
Receipt
mlx5_core, firmware 28.45.4028. libmcdma-fabric from MCDMA e725b45, built on each host. No checkpoint: this is the transport only.tf-mcdma-pairequals the host reference on both ends, and both ends give the same run hash (b0d3a38b...0eb2, 33 tests) on two GB10s.bench_concurrent.pyandtoken_shado not apply: no serving path changes unless a tp settings file declares a ConnectX link.Linkas before, and a Thunderbolt link makes the same library calls (a unit test pins them).git archiveof a31063d with an empty cache, each step's own exit code 0.zig build test: 9365 passed, 0 failed, 58 skipped (9423).zig build test-cluster: 78 passed, 0 failed, 6 skipped.zig build test-tp: 70 passed, 0 failed, 3 skipped.tools/zig/test_fabric.shwithTF_MCDMA_SRCat MCDMA e725b45: 40 passed, 0 failed, 1 skipped (the opt-in verbs smoke test), and MCDMA's stub suites 21 of 21.TF_FABRIC_VERBS=1's opt-in verbs smoke test. CI does not run test-cluster, test-tp or tools/zig/test_fabric.sh, so those ran locally only.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Not touched by this change.tools/zig/test_fabric.shwhenTF_MCDMA_SRCnames MCDMA's source.tools/zig/lean_check.py: 424 problems, the same as the base, 0 new.1. The transport:
zig/src/fabric/mcdma.zigProduction code is +169 / -31 lines; the other +418 lines in the file are tests.
mcdma_abi.zigand the callers are unchanged.abi.thunderboltalso takesMCDMA_FABRIC_ROCE(1, mcdma_fabric.h). The kind is kept per port, so one endpoint can hold a Thunderbolt peer and a ConnectX peer. Any other kind isUnsupportedLink, and so is a ConnectX port with a+bond orports/peer_ports: MCDMA has no RoCE bonds, and refusing port lists is this file's choice. TheWindowMismatchcheck is unchanged.kind()gives.cx5for a ConnectX port..tb5and.localare as before, and an unknown peer still gives.tb5.Link.mtu, default 4096 (the value that was hardcoded). It must be 1024, 2048 or 4096 (path_mtus); anything else isInvalidConfigbefore anything opens, because MCDMA would quietly run it at 1024.Link.kind(?rdma.LinkKind, default null). Null takes whichever kind connects;.tb5or.cx5refuses the other after connect..cx5also refuses, before anything opens,gid -1(NeedGidIndex: MCDMA scans for a GID on Thunderbolt only) and a bond or port lists (UnsupportedLink).NeedGidIndexis the one new error name. It is additive, and the five callers (core/pair.zig,core/pair_rows.zig,flashnext/tp.zig,glm/ep.zig,tests/tp2_bench.zig) use inferred error sets.write_signal, which surfaced asAccessDenied. On a ConnectX port,write2Signalis write2 then signal (the path it already took for a local peer or an oversized write), andwriteSignalFromposts the write and then the signal on the same RC queue pair.signal()refused a bad flag. They now run first on every path and on both kinds, so nothing is posted or written for a bad flag or range. The errors areOutOfBoundsandUnalignedas before; a flag that is both misaligned and out of bounds now readsOutOfBoundson a fallback too, as it always did on the fused path.writeSignalFromchecks the room, range, flag and alignment before posting, on both kinds.MCDMA_FABRIC_QPSabove 1) isUnsupportedLink; a Thunderbolt open never returns it. Other open failures stayOpenFailed, and connect failures stayConnectFailed.gid -1gives both causes, since a down Thunderbolt port looks the same:open failed with MCDMA status 4 DEVICE: ...; is the port active, and its active MTU at least the path MTU? gid -1 scans Thunderbolt only: a ConnectX link needs its RoCE v2 GID index.WindowMismatchandThreadFailedlog nothing, as before.mcdma_fabric_peer_status(additive ABI 1) is looked up as an optional symbol, somcdma_abi.zigis untouched. The first PeerDown on a port logslink "NAME" to rank P: peer down (MCDMA status 5 PEER): <MCDMA's reason>once, andEndpoint.peerStatus(peer, buf)returns that reason, so a caller can print it after a collective'sPeerTimeout.createis split intovalidate,createandstart. A privatecreateWithdrives the endpoint over a fake library table, anddeinitcloses only a library the endpoint opened itself.Thunderbolt unchanged:
port.link == roceinwriteSignalFrom,overRoce(peer)inwrite2Signal) are false for Thunderbolt, and open still passes 4096 unless a link setsmtu.window + peer*staging + used + 64, writeSignalFrom, zero-length writeSignalFrom and flush, each against the formulas the old code used.Deliberately unchanged:
readandfetchAddstill returnAccessDenied; one link per device; the vtable is still chosen per library.2. tp settings carry
mtuandkindEvery shipped user of the endpoint gets its link from
tp_settings.read, which did not readmtuorkind. So shipped TensorFold always ran at path MTU 4096 with no declared kind, and could not reach a ConnectX port whose active MTU is below 4096.mtu: optional integer, 1024, 2048 or 4096 (mcdma.path_mtus, made public here), default 4096. Anything else, or a string, isBadTpSettings.kind: optional string,"tb5"or"cx5". Another string, or a non-string, isBadTpSettings. Absent, the link takes whichever kind connects, as before.mcdma.Link, which every caller passes unchanged toEndpoint.create. A file without the keys parses to the sameLinkas before.docs/n-link-speed-up.mddescribes both keys with a ConnectX example, and says what a Mac ConnectX link needs (below).3.
tf-mcdma-pair, the gate harnessThe gate: on a Mac and a Linux host over ConnectX, every collective equals a host reference on both ends; a stopped peer or a dropped link fails by name, not a hang; a Thunderbolt link behaves as today. The harness makes the hardware window copy, run, collect. No production code depends on it.
zig/tests/mcdma_pair.zig:zig build tf-mcdma-pairfor this host, andtf-mcdma-pair-distfor aarch64-macos, aarch64-linux-gnu (the GB10) and x86_64-linux-gnu. The Linux binaries are built against glibc 2.35 and need its symbols up to GLIBC_2.34 (their version needs, read withobjdump -p); they dlopen the library. One rank per process from a settings JSON. It runs barrier, broadcast from both roots, bf16 and f32 all-reduce againstcollective.reduceand an fp32 rank-order reference, uneven all-to-all, gather, pipes both ways, a bulk copy across the Mac's 4 MiB registration pieces, a signal storm that checks every landed value, and rounds of write2Signal and writeSignalFrom. Each test prints PASS or FAIL with a SHA-256 both ranks share. The ranks first swap a run id and their settings (path MTU and any expected failure included) and refuse a mismatch by name. A watchdog names a step that stops making progress. Arms: exit, kill (SIGKILL), stop, hang, and external (an operator drops the link).tools/zig/mcdma_pair/:run_macos.shandrun_linux.shrun one side and collect its log, exit code and read-only host facts (kext UUID, port state, active MTU, GID, neighbours, memlock, clock offset), with a WARN before the run for anything that would spoil it. Nothing in them uses sudo.compare.pychecks both ends against the reference and each other, the arm's outcome with its timing and MCDMA's reason, each rank's settings against the plan, the run id, and--same-asanother run, and writes a receipt. GATE PASS needs two hosts on MCDMA's libmcdma-fabric linking librdma (Mac) or libibverbs (Linux), the whole suite and one run id. A run that passes only because--same-hostor--stubrelaxed a check prints OFFLINE PASS (not the gate) and exits 5, never GATE PASS. A pre-flight WARN about the kext UUID, relaxed ordering or the clock fails the gate unless--allow-warn. The library check reads the run script'slinksfacts, so it guards against an honest mistake, not an edited log.settings.pywrites every run's settings and a PLAN.txt per host pair from a hosts file.hosts.example.jsondocuments every field with documentation addresses; real hosts files stay outside the tree.bundle.shpacks the binaries, scripts, plans and MCDMA's sources, and each host builds its own libmcdma-fabric withbuild_mcdma.sh.stub_proof.shruns the harness through the same run scripts and compare.py: over MCDMA's offline stub verbs (both ranks in one process), overloop_fabric.c(a loopback TCP stand-in, not MCDMA) for the window's two-process flow, and through the runs compare.py must refuse. Every offline compare passes--same-host --stuband must end in OFFLINE PASS.4. Window layouts: one alignment on every host
The gate's first G1 between the Mac and the GB10 hung at the first exchange, with both ends waiting out
PeerTimeout.collective.Channel.bytes,collective.Pipe.bytesand the cluster'sfabric_linkLayout aligned tordma.page, which isstd.heap.page_size_min: 16 KiB on macOS and 4 KiB on Linux. Two ranks on one OS always agree, so no test could see it. A Mac and a Linux rank did not: a debug dump showed the plan channel at window offset 4931584 on the Mac and 4919296 on Linux, so each rank wrote the other's flags at its own offsets, where the other never looked.rdma.layout_align(16 KiB, the largest page among the supported hosts) is what those layouts align to now;pagestays for allocations and mappings.layout_alignis 16384,Channel.bytes(2, 64)is 16384,Channel.bytes(2, 1228800)is 4931584,Pipe.bytes(64 KiB)is 147456, andLayout.init(2, 4096, 64 KiB)puts the words at 32768 and the pipes at 49152, with a total of 638976. Withlayout_alignset to 4096, both tests fail.The hardware gate: two-host receipt
mcrdma0rocep1s0f0, firmware 28.45.4028org.mcdma.cx5.native0.1.18 (UUID 2AF73EEB-D3A3-34D8-8264-0B55AFE4462D, a local build that adds read-only diagnostic reads)mlx5_corefrom that kernel, rdma-core 50.0build_mcdma.shThe ranks meet over Wi-Fi. Each run's receipt also records the binary and library sha256, the kext UUID, port state, GIDs, static neighbours and the clock offset. All runs on 2 Nov at 87bfe375d. The branch differs from it only in the committer email and two doc comments shortened to one line each (no code change). First GB10:
PeerDown3.67 s after the arm, MCDMA: "a signal failed"PeerTimeoutat 10.01 s, MCDMA: "the other end said goodbye"PeerTimeoutat 10.00 s, the link upNeedGidIndexbefore anything opensOpenFailedwith MCDMA's "gid -1"ConnectFailedafter 30.30 s, logged as TIMEOUTPeerDown4.41 s after the drop, MCDMA: "a flush failed"; the Mac withPeerTimeout10.83 s after it, MCDMA: "the other end failed: a flush failed" (window -2 .. 14 s)PeerTimeoutat 10.00 s, the link upThe same Mac against a second GB10 (same model, kernel and driver) later the same day, cable moved by hand: G1, G2, G3a, G3b, G3c, G3d, G5b, G5c and G5d all GATE PASS, run hash b0d3a38b...0eb2 again (33 tests). G4 was not repeated there.
What this settles from the offline proof's open list: write2Signal and writeSignalFrom held RC ordering in every round of G1 and G2; a SIGKILL on real RC is found on both sides (G3a, G3c); the goodbye over Wi-Fi arrived (G3b); and the cross-compiled Linux binary runs on the GB10.
Not covered: a switch between the hosts (this run is a direct cable), and PLAN's Thunderbolt line (two Thunderbolt Macs).
Mac facts a reviewer needs
gid: 0. tp settings still default to gid 1 for old files, andgid -1scans on Thunderbolt only (NeedGidIndexwith kind cx5). settings.py refuses any other gid for a Mac.OpenFailed(DEVICE); the endpoint does not refuse that by name yet. The harness does (TooManyRegions, before anything opens) and runs at 96 MiB.docs/n-link-speed-up.mdstates this limit and the gid 0 rule.Left for step 2
metal_link.zig's advice forConnectFailedstill matches by error name, but its text is Mac-to-Mac wording ("the other Mac never answered on the link ... Local Network access"), which does not fit a Mac-to-Linux ConnectX peer. It is left for step 2, with the cluster and CLI wiring.