Skip to content

fabric/mcdma: ConnectX (RoCE v2) links (#1594, step 1) - #1957

Merged
ashhart merged 6 commits into
ashhart:mainfrom
ThinkOffApp:pr/1594-step1
Nov 4, 2026
Merged

ashhart merged 6 commits into
ashhart:mainfrom
ThinkOffApp:pr/1594-step1

Conversation

@ThinkOffApp

Copy link
Copy Markdown
Contributor

What this changes

Step 1 of #1594, as asked there: mcdma.zig takes 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-pair is 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 for serve --cluster on 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

  • Environment: TensorFold a31063d, Zig 0.17.0, default build options. Rank 0: MacBook Pro, Apple M5 Max, macOS 27.0.1 (26A434), ConnectX-5 in a Thunderbolt PCIe enclosure, MCDMA's native kext 0.1.18. Rank 1: two ASUS GX10 (GB10), Ubuntu 24.04.5, kernel 7.0.0-1019-nvidia, ConnectX-7 on mlx5_core, firmware 28.45.4028. libmcdma-fabric from MCDMA e725b45, built on each host. No checkpoint: this is the transport only.
  • Exactness: no arithmetic change. On the hardware, every collective in tf-mcdma-pair equals the host reference on both ends, and both ends give the same run hash (b0d3a38b...0eb2, 33 tests) on two GB10s. bench_concurrent.py and token_sha do not apply: no serving path changes unless a tp settings file declares a ConnectX link.
  • Decode speed before and after: n/a. No shipped serving path changes; a settings file without the new keys parses to the same Link as before, and a Thunderbolt link makes the same library calls (a unit test pins them).
  • Prompt speed before and after: n/a, for the same reason.
  • Tests run, with pass, fail and skip counts: on the M5 Max (macOS 27.0.1, Zig 0.17.0), from a clean git archive of 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.sh with TF_MCDMA_SRC at MCDMA e725b45: 40 passed, 0 failed, 1 skipped (the opt-in verbs smoke test), and MCDMA's stub suites 21 of 21.
  • Not run, and why: a switch between the hosts (these runs are a direct cable); the Thunderbolt Mac-to-Mac line of the gate plan (it needs two Thunderbolt Macs); 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

  • Every token still goes through the lane rounds. Transport only; no serving path changes.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Not touched by this change.
  • No precision traded for speed. No sums change.
  • A new or changed GPU kernel is registered with the kernel contract. No kernel changes.
  • Prompt processing is no slower than the last release. Not touched.
  • The description says which platforms I ran: Metal on an M5 Max, and the CUDA hosts as GB10 ConnectX-7 peers. M1 to M4 not run; the transport has no per-chip code.
  • New tests fail before the change and pass after it: the pinned layout tests fail with the old 4 KiB alignment, and the ConnectX selection and refusal tests cover behaviour that did not exist before. The MCDMA stub tests run in tools/zig/test_fabric.sh when TF_MCDMA_SRC names MCDMA's source.
  • Comments and docstrings are one line. tools/zig/lean_check.py: 424 problems, the same as the base, 0 new.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

1. The transport: zig/src/fabric/mcdma.zig

Production code is +169 / -31 lines; the other +418 lines in the file are tests. mcdma_abi.zig and the callers are unchanged.

  • ConnectX accepted after connect. The check that refused anything but abi.thunderbolt also takes MCDMA_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 is UnsupportedLink, and so is a ConnectX port with a + bond or ports/peer_ports: MCDMA has no RoCE bonds, and refusing port lists is this file's choice. The WindowMismatch check is unchanged.
  • kind() gives .cx5 for a ConnectX port. .tb5 and .local are as before, and an unknown peer still gives .tb5.
  • Path MTU per link. New Link.mtu, default 4096 (the value that was hardcoded). It must be 1024, 2048 or 4096 (path_mtus); anything else is InvalidConfig before anything opens, because MCDMA would quietly run it at 1024.
  • Optional Link.kind (?rdma.LinkKind, default null). Null takes whichever kind connects; .tb5 or .cx5 refuses the other after connect. .cx5 also refuses, before anything opens, gid -1 (NeedGidIndex: MCDMA scans for a GID on Thunderbolt only) and a bond or port lists (UnsupportedLink). NeedGidIndex is 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.
  • No fused write-and-signal over ConnectX. On a RoCE link MCDMA returns UNSUPPORTED for write_signal, 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 and then the signal on the same RC queue pair.
  • write2Signal checks its arguments before every path. Its range and flag checks used to run only before the fused call, so on a fallback the data was posted first and only 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 are OutOfBounds and Unaligned as before; a flag that is both misaligned and out of bounds now reads OutOfBounds on a fallback too, as it always did on the fused path. writeSignalFrom checks the room, range, flag and alignment before posting, on both kinds.
  • Open and connect failures keep MCDMA's status.
    • An open that returns UNSUPPORTED (a ConnectX bond, or MCDMA_FABRIC_QPS above 1) is UnsupportedLink; a Thunderbolt open never returns it. Other open failures stay OpenFailed, and connect failures stay ConnectFailed.
    • Each open or connect failure logs one line naming the link, device, via, GID, path MTU and the status by its MCDMA name. UNSUPPORTED, DEVICE, PEER and TIMEOUT add a hint; INVALID and NOMEM do not. A DEVICE failure at gid -1 gives 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.
    • A kind refused after connect logs its own line (the device, the declared kind and the kind MCDMA reported). WindowMismatch and ThreadFailed log nothing, as before.
  • The peer-down reason, by name. mcdma_fabric_peer_status (additive ABI 1) is looked up as an optional symbol, so mcdma_abi.zig is untouched. The first PeerDown on a port logs link "NAME" to rank P: peer down (MCDMA status 5 PEER): <MCDMA's reason> once, and Endpoint.peerStatus(peer, buf) returns that reason, so a caller can print it after a collective's PeerTimeout.
  • Refactor for tests. create is split into validate, create and start. A private createWith drives the endpoint over a fake library table, and deinit closes only a library the endpoint opened itself.

Thunderbolt unchanged:

  • The data path's per-port branches (port.link == roce in writeSignalFrom, overRoce(peer) in write2Signal) are false for Thunderbolt, and open still passes 4096 unless a link sets mtu.
  • The success paths call the library with the same arguments in the same order. A unit test pins this: write, write2, signal, write2Signal at window + peer*staging + used + 64, writeSignalFrom, zero-length writeSignalFrom and flush, each against the formulas the old code used.
  • Failures return the same error names, with the log lines above. The one difference a Thunderbolt caller can see is write2Signal's: on the local-peer or oversized fallback, a bad flag is now refused before anything is posted.

Deliberately unchanged: read and fetchAdd still return AccessDenied; one link per device; the vtable is still chosen per library.

2. tp settings carry mtu and kind

Every shipped user of the endpoint gets its link from tp_settings.read, which did not read mtu or kind. 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, is BadTpSettings.
  • kind: optional string, "tb5" or "cx5". 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 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 says what a Mac ConnectX link needs (below).

3. tf-mcdma-pair, the gate harness

The 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-pair for this host, and tf-mcdma-pair-dist for 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 with objdump -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 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 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.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 WARN before the run for anything that would spoil it. Nothing in them uses sudo.
    • compare.py 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, and --same-as another 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-host or --stub relaxed 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's links facts, so it guards against an honest mistake, not an edited log.
    • settings.py writes every run's settings and a PLAN.txt per host pair from a hosts file. hosts.example.json documents every field with documentation addresses; real hosts files stay outside the tree. bundle.sh packs the binaries, scripts, plans and MCDMA's sources, and each host builds its own libmcdma-fabric with build_mcdma.sh.
  • The runs: G1 and G2 (both rank orders), G3a and G3c (SIGKILL on each side mid signal storm), G3b (a clean exit mid all-reduce), G3d (a stop mid pipes), G4 (an operator drops the link, planned only for a host marked free), G5a to G5d (path MTU above the active MTU, gid -1 with kind cx5, gid -1 with no kind, no peer), and PLAN's Thunderbolt line against G1.
  • Offline proof. stub_proof.sh runs the harness through the same run scripts and compare.py: over MCDMA's offline 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 through the runs compare.py must refuse. Every offline compare passes --same-host --stub and 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.bytes and the cluster's fabric_link Layout aligned to rdma.page, which is std.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; page stays for allocations and mappings.
  • A Mac's layouts are unchanged (its page is already 16 KiB). On Linux, channels and pipes now start on 16 KiB boundaries, the same as a Mac's, so a Linux window can grow by the padding.
  • The last commit pins the numbers, since same-OS tests cannot catch a split: layout_align is 16384, Channel.bytes(2, 64) is 16384, Channel.bytes(2, 1228800) is 4931584, Pipe.bytes(64 KiB) is 147456, and Layout.init(2, 4096, 64 KiB) puts the words at 32768 and the pipes at 49152, with a total of 638976. With layout_align set to 4096, both tests fail.

The hardware gate: two-host receipt

rank 0 rank 1
host MacBook Pro, Apple M5 Max, macOS 27.0.1 (26A434) ASUS GX10 (GB10), Ubuntu 24.04.5, kernel 7.0.0-1019-nvidia, 4 KiB pages
NIC ConnectX-5 in a Thunderbolt PCIe enclosure, port mcrdma0 ConnectX-7 (vendor_part_id 4129), port rocep1s0f0, firmware 28.45.4028
driver MCDMA's native kext org.mcdma.cx5.native 0.1.18 (UUID 2AF73EEB-D3A3-34D8-8264-0B55AFE4462D, a local build that adds read-only diagnostic reads) mlx5_core from that kernel, rdma-core 50.0
library libmcdma-fabric from MCDMA e725b45, built on the host with build_mcdma.sh the same, built on the host
link one direct cable, no switch; RoCE v2 at path MTU 1024, GID index 0 port ACTIVE at 100 Gb/s (4X EDR), active MTU 4096, RoCE v2 GID index 1

The 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:

run result
G1, G2 GATE PASS. Every test equals the host reference on both ends, in both rank orders, run hash b0d3a38b...0eb2 (33 tests), the same as at the pre-rebase commit on 1 Nov
G3a GATE PASS. The GB10 SIGKILLs itself; the Mac fails with PeerDown 3.67 s after the arm, MCDMA: "a signal failed"
G3b GATE PASS. The GB10 closes its endpoint; the Mac fails with PeerTimeout at 10.01 s, MCDMA: "the other end said goodbye"
G3d GATE PASS. The GB10 stops posting; the Mac fails with PeerTimeout at 10.00 s, the link up
G5a N/A: the GB10's active MTU is 4096
G5b GATE PASS on both hosts: NeedGidIndex before anything opens
G5c GATE PASS on both hosts: OpenFailed with MCDMA's "gid -1"
G5d GATE PASS on the Mac: ConnectFailed after 30.30 s, logged as TIMEOUT
G4 GATE PASS. The cable pulled by hand mid-run, about 45 s in (a carrier watcher on the GB10 wrote the drop time): the GB10 fails with PeerDown 4.41 s after the drop, MCDMA: "a flush failed"; the Mac with PeerTimeout 10.83 s after it, MCDMA: "the other end failed: a flush failed" (window -2 .. 14 s)
G4-after GATE PASS. Cable back and the GB10's static neighbour restored (pulling the cable flushed it): a fresh G1 gives G1's hashes and suite
G3c GATE PASS. The Mac SIGKILLs itself; the GB10 fails with PeerTimeout at 10.00 s, the link up

The 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 index 0 only. The MCDMA kext exposes only GID index 0, so a Mac ConnectX link needs gid: 0. tp settings still default to gid 1 for old files, and gid -1 scans on Thunderbolt only (NeedGidIndex with kind cx5). settings.py refuses any other gid for a Mac.
  • At most 64 memory regions per context. MCDMA registers a Mac RoCE window, staging included, in 4 MiB pieces plus one region per peer, so the window and both ranks' staging get at most 63 pieces, about 252 MiB. The shipped windows do not fit a Mac ConnectX link yet: flashnext's 460 MiB window with 32 MiB staging per rank needs 132 pieces, and glm's 257 MiB window with 4 MiB per rank needs 67. They would fail at registration as 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.md states this limit and the gid 0 rule.
  • The path MTU must match on both ends, and be at most each port's active MTU. MCDMA's exchange does not carry it, so nothing refuses a mismatch at connect. The harness compares it in its settings handshake; the shipped callers do not check it yet, so both settings files must agree.

Left for step 2

metal_link.zig's advice for ConnectFailed still 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.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks @ThinkOffApp. Reviewed against #1594's step-1 gate, and it's met. It's step 1 as its own PR, mcdma.zig takes a ConnectX link beside Thunderbolt (MTU 1024/2048/4096, a ConnectX gid -1 refused before opening), and it's transport only, with no kernel or model file. Thunderbolt's success-path calls are pinned by a test, and there are host tests for link selection and refusals. One thing needs our device run before it lands: rdma.layout_align becomes 16384, so collective.Channel, Pipe and cluster/fabric_link align to it on Linux. That fixes the Mac/Linux layout mismatch (4931584 against 4919296 for the same channel), but it touches every GB10 TP=2 path, not only ConnectX links. Our GLM TP=2 pair (main against this head, tokens and speed) is queued. It lands when that's green.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks @ThinkOffApp. GLM-5.3-Flash NVFP4 TP=2 pair on two GB10s, main against this head (--parallel 2, --context 65536): tokens equal on 52 of 52, with 0 unequal or unverified. Prompts are a little faster (2K +3.7%, 8K +0.1%, 32K +3.9%), and decode is level (chat +0.5/-0.4%, code -0.1/-0.1% at 1 and 2 streams). That was the run this was waiting on, so it's queued to land.

ashhart added a commit to ThinkOffApp/TensorFold that referenced this pull request Nov 3, 2026
ashhart added a commit to ThinkOffApp/TensorFold that referenced this pull request Nov 4, 2026
ThinkOffApp and others added 6 commits November 4, 2026 02:49
…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.
@ashhart
ashhart merged commit 823e9c7 into ashhart:main Nov 4, 2026
0 of 7 checks passed
@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

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.

@ashhart

ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks @ThinkOffApp! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants