From 4bf0fc2b5a47e66860898e38deb0c86cb8d773e0 Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 01:16:55 -0500 Subject: [PATCH 01/12] Preserve fabric configuration and resource ownership across operations Carry immutable device bindings through planning and observation, share apply and restoration decisions, and persist executable boot configuration. Reject invalid device identifiers before script generation. CLI syntax and record schemas remain compatible; malformed identifiers and extra port fields are rejected. Validation: 138 fabric tests pass in an isolated Debian 13 LXC. --- fabric-tool/fabric_tool/boot.py | 42 +++- fabric-tool/fabric_tool/cli.py | 52 +++-- fabric-tool/fabric_tool/commands.py | 66 +++---- fabric-tool/fabric_tool/diff.py | 181 ++++++------------ fabric-tool/fabric_tool/facts.py | 18 +- fabric-tool/fabric_tool/model.py | 109 ++++++----- fabric-tool/fabric_tool/ops.py | 22 +-- fabric-tool/fabric_tool/plan.py | 50 ++--- fabric-tool/fabric_tool/report.py | 13 +- fabric-tool/fabric_tool/state.py | 23 +-- fabric-tool/fabric_tool/topology.py | 17 +- fabric-tool/tests/test_boot.py | 7 +- fabric-tool/tests/test_operation_contracts.py | 87 +++++++++ fabric-tool/tests/test_topology.py | 11 +- 14 files changed, 392 insertions(+), 306 deletions(-) create mode 100644 fabric-tool/tests/test_operation_contracts.py diff --git a/fabric-tool/fabric_tool/boot.py b/fabric-tool/fabric_tool/boot.py index 71df8e7..6fffea8 100644 --- a/fabric-tool/fabric_tool/boot.py +++ b/fabric-tool/fabric_tool/boot.py @@ -27,8 +27,36 @@ DEFAULT_TOOL = BIN_PATH -def unit_text(tool: str = DEFAULT_TOOL) -> str: +@dataclasses.dataclass(frozen=True) +class RestoreInvocation: + """Behavior persisted by the boot unit and used by immediate restoration.""" + + tool: str = DEFAULT_TOOL + marker: str = commands.DEFAULT_MARKER + max_relays: int = 3 + host: str | None = None + skip_hostname_check: bool = False + + def argv(self) -> tuple[str, ...]: + args = (self.tool, "apply", "--boot", "--execute", "--topology", TOPOLOGY_INPUT, + "--facts", FACTS_INPUT, "--marker", self.marker, "--max-relays", str(self.max_relays)) + if self.host: + args += ("--host", self.host) + if self.skip_hostname_check: + args += ("--skip-hostname-check",) + return args + + +def systemd_arg(value: str) -> str: + """Quote one ExecStart argument, including systemd specifier and variable expansion.""" + if any(ord(c) < 32 for c in value): + raise ValueError("service arguments must not contain control characters") + return '"' + value.replace('\\', '\\\\').replace('"', '\\"').replace('%', '%%').replace('$', '$$') + '"' + + +def unit_text(tool: str = DEFAULT_TOOL, *, invocation: RestoreInvocation | None = None) -> str: """The unit file of ``fabric-table.service``.""" + invocation = invocation or RestoreInvocation(tool=tool) return "\n".join([ "[Unit]", "Description=Fabric relay table of directly cabled DGX Sparks (fabric-tool)", @@ -38,7 +66,7 @@ def unit_text(tool: str = DEFAULT_TOOL) -> str: "", "[Service]", "Type=oneshot", - f"ExecStart={tool} apply --boot --topology {TOPOLOGY_INPUT} --facts {FACTS_INPUT}", + "ExecStart=" + " ".join(systemd_arg(arg) for arg in invocation.argv()), "RemainAfterExit=yes", "", "[Install]", @@ -70,13 +98,15 @@ def commands(self) -> tuple[str, ...]: return ("systemctl daemon-reload", f"systemctl enable {UNIT_NAME}") -def plan(topology_path: str, facts_path: str, tool: str = DEFAULT_TOOL) -> BootPlan: +def plan(topology_path: str, facts_path: str, tool: str = DEFAULT_TOOL, *, + invocation: RestoreInvocation | None = None, topology_text: str | None = None, + facts_text: str | None = None) -> BootPlan: """The unit and input files of an ``install-boot`` (the caller passes validated inputs).""" - topology = Path(topology_path).read_text(encoding="utf-8") - facts = Path(facts_path).read_text(encoding="utf-8") + topology = topology_text if topology_text is not None else Path(topology_path).read_text(encoding="utf-8") + facts = facts_text if facts_text is not None else Path(facts_path).read_text(encoding="utf-8") return BootPlan(topology_path, facts_path, UNIT_NAME, ((TOPOLOGY_INPUT, topology), (FACTS_INPUT, facts), (f"/etc/systemd/system/{UNIT_NAME}", - unit_text(tool)))) + unit_text(tool, invocation=invocation)))) def install(spec: BootPlan, *, root: str = "/", execute: bool) -> list[str]: diff --git a/fabric-tool/fabric_tool/cli.py b/fabric-tool/fabric_tool/cli.py index 80cc54a..ba06deb 100644 --- a/fabric-tool/fabric_tool/cli.py +++ b/fabric-tool/fabric_tool/cli.py @@ -37,7 +37,7 @@ import sys from pathlib import Path -from . import boot, commands, facts as facts_mod, model, ops, report, topology as topology_mod +from . import boot, commands, diff as diff_mod, facts as facts_mod, model, ops, report, topology as topology_mod from .model import FabricError from .plan import Facts, build_plan, render_text @@ -71,18 +71,12 @@ def _install_scripts(plan, marker: commands.MarkerConfig) -> dict[int, str]: """The from-nothing install script of every host (what ``apply`` converges to on an empty host).""" scripts = {} for host in plan.hosts: - lines = [commands.HEADER, commands.guard(host.name)] - for netdev in host.filter_netdevs: - lines.append(commands.qdisc_add(netdev)) - lines.extend(commands.filter_add(relay_filter) for relay_filter in host.filters) - lines.extend(commands.neigh_replace(route.destination, route.next_mac, route.netdev) - for route in host.routes) - lines.extend(commands.route_replace(route.destination, route.netdev, route.source) - for route in host.routes) - for rules in host.markers: - lines.extend(commands.marker_start(marker, rules.device, rules.rules)) - lines.append(commands.SETTLE) - scripts[host.position] = "\n".join(lines) + "\n" + observed = ops.state_mod.HostState(host.position, host.name, "", True, + hostname=host.name, bindings=host.bindings) + result = diff_mod.compare_up(observed, host, plan, layout_name=plan.group.name, + marker=marker, adopt=False) + if result.script: + scripts[host.position] = result.script return scripts @@ -141,7 +135,7 @@ def _command_plan(args: argparse.Namespace) -> int: if args.facts: facts = facts_mod.bind(facts_mod.load(args.facts), topology) else: - facts = Facts.symbolic_for(topology.hosts) + facts = Facts.symbolic_for(topology.hosts, bindings=topology.bindings) plan = build_plan(topology.group, facts, max_relays=args.max_relays) if args.json: print(json.dumps({"schema": "fabric-tool-plan/v2", "topology": args.topology, @@ -163,7 +157,7 @@ def _command_facts(args: argparse.Namespace, topology: topology_mod.Topology, executor: ops.Executor) -> int: hosts = _resolve_hosts(topology, args) marker = commands.MarkerConfig(args.marker) - states = ops.gather(hosts, sorted(hosts), executor, marker) + states = ops.gather(hosts, sorted(hosts), executor, marker, bindings=topology.bindings) document = facts_mod.from_states(states, topology) text = json.dumps(document, indent=1) if args.output: @@ -182,8 +176,9 @@ def _apply_flow(args: argparse.Namespace, topology: topology_mod.Topology, mode: hosts = _resolve_hosts(topology, args) marker = commands.MarkerConfig(args.marker) positions = sorted(hosts) - states = ops.gather(hosts, positions, executor, marker) file_facts = _file_facts(args, topology) + bindings = file_facts.bindings if file_facts else topology.bindings + states = ops.gather(hosts, positions, executor, marker, bindings=bindings) outcome = ops.evaluate(topology, states, file_facts, mode=mode, marker=marker, adopt=args.adopt, check_hostname=not args.skip_hostname_check, max_relays=args.max_relays, positions=positions) @@ -206,7 +201,7 @@ def _apply_flow(args: argparse.Namespace, topology: topology_mod.Topology, mode: text = (result.stdout + result.stderr).strip() print(f"{hosts[position].name}: exit {result.returncode}" + (f": {text[-1500:]}" if text else "")) failed |= not result.ok - states = ops.gather(hosts, positions, executor, marker) + states = ops.gather(hosts, positions, executor, marker, bindings=bindings) verify = ops.evaluate(topology, states, file_facts, mode=mode, marker=marker, adopt=args.adopt, check_hostname=not args.skip_hostname_check, max_relays=args.max_relays, positions=positions) @@ -227,8 +222,10 @@ def _command_verify(args: argparse.Namespace, topology: topology_mod.Topology, executor: ops.Executor) -> int: hosts = _resolve_hosts(topology, args) marker = commands.MarkerConfig(args.marker) - states = ops.gather(hosts, sorted(hosts), executor, marker) - outcome = ops.evaluate(topology, states, _file_facts(args, topology), mode="up", marker=marker, + file_facts = _file_facts(args, topology) + states = ops.gather(hosts, sorted(hosts), executor, marker, + bindings=file_facts.bindings if file_facts else topology.bindings) + outcome = ops.evaluate(topology, states, file_facts, mode="up", marker=marker, adopt=False, check_hostname=not args.skip_hostname_check, max_relays=args.max_relays, positions=sorted(hosts)) _print_outcome(outcome, args, scripts=args.scripts) @@ -243,7 +240,7 @@ def _command_status(args: argparse.Namespace, topology: topology_mod.Topology, executor: ops.Executor) -> int: hosts = _resolve_hosts(topology, args) marker = commands.MarkerConfig(args.marker) - states = ops.gather(hosts, sorted(hosts), executor, marker) + states = ops.gather(hosts, sorted(hosts), executor, marker, bindings=topology.bindings) print(report.render_show(states, marker)) return 0 if all(state.reachable for state in states.values()) else 1 @@ -252,7 +249,7 @@ def _command_marker(args: argparse.Namespace, topology: topology_mod.Topology, executor: ops.Executor) -> int: hosts = _resolve_hosts(topology, args) marker = commands.MarkerConfig(args.marker) - states = ops.gather(hosts, sorted(hosts), executor, marker) + states = ops.gather(hosts, sorted(hosts), executor, marker, bindings=topology.bindings) print(_marker_status(states, marker)) # A missing executable, or one without the digest its install recorded, is (re)built. targets = [p for p in sorted(hosts) if states[p].reachable @@ -311,12 +308,11 @@ def _command_install_boot(args: argparse.Namespace, topology: topology_mod.Topol if file_facts is None or file_facts.symbolic: raise FabricError("install-boot needs a complete facts file (--facts); placeholders are not installable") build_plan(topology.group, file_facts, max_relays=args.max_relays) # refuses a plan that cannot be built - spec = boot.plan(args.topology, args.facts[0], tool=args.tool) - # Persist all facts, including hosts supplied by additional --facts files. - merged = json.dumps(facts_mod.load(args.facts), indent=1) + "\n" - spec = boot.BootPlan(spec.topology_path, spec.facts_path, spec.unit, - tuple((name, merged if name == boot.FACTS_INPUT else content) - for name, content in spec.files)) + restore = boot.RestoreInvocation(tool=args.tool, marker=args.marker, max_relays=args.max_relays, + host=args.host, skip_hostname_check=args.skip_hostname_check) + spec = boot.plan(args.topology, args.facts[0], invocation=restore, + topology_text=Path(args.topology).read_text(encoding="utf-8"), + facts_text=json.dumps(facts_mod.load(args.facts), indent=1) + "\n") print(f"unit {boot.UNIT_NAME}:") print(spec.files[2][1], end="") for destination, _ in spec.files[:2]: @@ -328,7 +324,7 @@ def _command_install_boot(args: argparse.Namespace, topology: topology_mod.Topol # Reject identity/ownership/facts blockers before persisting a boot service. hosts = _resolve_hosts(topology, args) marker = commands.MarkerConfig(args.marker) - states = ops.gather(hosts, sorted(hosts), executor, marker) + states = ops.gather(hosts, sorted(hosts), executor, marker, bindings=file_facts.bindings) outcome = ops.evaluate(topology, states, file_facts, mode="boot", marker=marker, adopt=False, check_hostname=not args.skip_hostname_check, max_relays=args.max_relays, positions=sorted(hosts)) diff --git a/fabric-tool/fabric_tool/commands.py b/fabric-tool/fabric_tool/commands.py index af64193..b0e55d2 100644 --- a/fabric-tool/fabric_tool/commands.py +++ b/fabric-tool/fabric_tool/commands.py @@ -170,39 +170,39 @@ def _mac(value: str) -> str: return value.lower() -def _netdev(value: str) -> str: - if value not in model.FABRIC_NETDEVS: +def _netdev(value: str, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + if value not in bindings.netdevs: raise FabricError(f"{value!r} is not a fabric network device") - return value + return q(model.device_name(value)) -def _device(value: str) -> str: - if value not in model.RDMA_DEVICES: +def _device(value: str, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + if value not in bindings.devices: raise FabricError(f"{value!r} is not a fabric RDMA device") - return value + return q(model.device_name(value)) # -- read script --------------------------------------------------------------------------- -def read_script(marker: MarkerConfig) -> str: +def read_script(marker: MarkerConfig, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: """Read-only facts and relay objects of one host, as ``@@
`` blocks.""" lines = ["set -u"] def section(name: str, *commands: str) -> None: - lines.append(f"echo {SECTION}{name}") + lines.append(f"echo {q(SECTION + name)}") lines.extend(commands) lines.append(SECTION_END) section("hostname", "hostname") section("versions", "ip -V 2>&1 || true", "tc -V 2>&1 || true") section("links", "ip -j addr show") - for device in model.RDMA_DEVICES: - section(f"rdma:{device}", f"ls /sys/class/infiniband/{device}/device/net 2>/dev/null || true") + for device in bindings.devices: + section(f"rdma:{device}", f"ls /sys/class/infiniband/{q(device)}/device/net 2>/dev/null || true") section("routes", "ip -j -d route show table main") section("neighbours", "ip -j neigh show nud permanent") - for netdev in model.FABRIC_NETDEVS: - section(f"qdisc:{netdev}", f"tc -j qdisc show dev {netdev} 2>/dev/null || true") + for netdev in bindings.netdevs: + section(f"qdisc:{netdev}", f"tc -j qdisc show dev {q(netdev)} 2>/dev/null || true") section(f"filters:{netdev}", f"tc -j filter show dev {netdev} ingress 2>/dev/null || true") section("markers", f"pgrep -a -x {q(marker.comm)} || true") section("marker-binary", f"sha256sum {q(marker.path)} 2>/dev/null || true") @@ -210,7 +210,7 @@ def section(name: str, *commands: str) -> None: section("marker-owners", f"stat -c '%U %a %n' -- {' '.join(q(p) for p in marker.checked_paths)} " f"{' '.join(q(p) for p in marker.log_dirs if p not in marker.checked_paths)} " "2>/dev/null || true") - for device in model.RDMA_DEVICES: + for device in bindings.devices: section(f"marker-log:{device}", f"head -c 4096 {q(marker.log(device))} 2>/dev/null || true") section("record", f"cat {RECORD_PATH} 2>/dev/null || true") section("sparkring-record", f"cat {SPARKRING_RECORD_PATH} 2>/dev/null || true") @@ -242,47 +242,47 @@ def guard(hostname: str) -> str: f'{{ echo {q("refusing: this host is not " + hostname)} >&2; exit 3; }}') -def qdisc_add(netdev: str) -> str: - return f"sudo -n tc qdisc add dev {_netdev(netdev)} ingress" +def qdisc_add(netdev: str, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + return f"sudo -n tc qdisc add dev {_netdev(netdev, bindings=bindings)} ingress" -def qdisc_del(netdev: str) -> str: - return f"sudo -n tc qdisc del dev {_netdev(netdev)} ingress" +def qdisc_del(netdev: str, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + return f"sudo -n tc qdisc del dev {_netdev(netdev, bindings=bindings)} ingress" -def filter_add(relay_filter: RelayFilter) -> str: - return (f"sudo -n tc filter add dev {_netdev(relay_filter.in_netdev)} ingress protocol " +def filter_add(relay_filter: RelayFilter, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + return (f"sudo -n tc filter add dev {_netdev(relay_filter.in_netdev, bindings=bindings)} ingress protocol " f"0x{relay_filter.protocol:04x} pref {relay_filter.pref} handle {relay_filter.handle} flower skip_sw " f"action pedit ex munge eth dst set {_mac(relay_filter.next_mac)} pipe " f"action pedit ex munge eth type set 0x{relay_filter.new_type:04x} pipe " - f"action mirred egress redirect dev {_netdev(relay_filter.out_netdev)}") + f"action mirred egress redirect dev {_netdev(relay_filter.out_netdev, bindings=bindings)}") -def filter_del(netdev: str, pref: int, *, protocol: int | None = None, handle: int | None = None) -> str: +def filter_del(netdev: str, pref: int, *, protocol: int | None = None, handle: int | None = None, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: """Delete one filter (protocol and handle known) or every filter of a reserved preference.""" if protocol is None or handle is None: - return f"sudo -n tc filter del dev {_netdev(netdev)} ingress pref {int(pref)}" - return (f"sudo -n tc filter del dev {_netdev(netdev)} ingress protocol 0x{int(protocol):04x} " + return f"sudo -n tc filter del dev {_netdev(netdev, bindings=bindings)} ingress pref {int(pref)}" + return (f"sudo -n tc filter del dev {_netdev(netdev, bindings=bindings)} ingress protocol 0x{int(protocol):04x} " f"pref {int(pref)} handle {int(handle)} flower") -def neigh_replace(destination: str, mac: str, netdev: str) -> str: - return (f"sudo -n ip neigh replace {_ipv4(destination)} lladdr {_mac(mac)} dev {_netdev(netdev)} " +def neigh_replace(destination: str, mac: str, netdev: str, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + return (f"sudo -n ip neigh replace {_ipv4(destination)} lladdr {_mac(mac)} dev {_netdev(netdev, bindings=bindings)} " f"nud permanent proto {ROUTE_PROTOCOL}") -def neigh_del(destination: str, netdev: str) -> str: - return f"sudo -n ip neigh del {_ipv4(destination)} dev {_netdev(netdev)}" +def neigh_del(destination: str, netdev: str, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + return f"sudo -n ip neigh del {_ipv4(destination)} dev {_netdev(netdev, bindings=bindings)}" -def route_replace(destination: str, netdev: str, source: str) -> str: - return (f"sudo -n ip route replace {_ipv4(destination)}/32 dev {_netdev(netdev)} src {_ipv4(source)} " +def route_replace(destination: str, netdev: str, source: str, *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: + return (f"sudo -n ip route replace {_ipv4(destination)}/32 dev {_netdev(netdev, bindings=bindings)} src {_ipv4(source)} " f"scope link proto {ROUTE_PROTOCOL}") -def route_del(destination: str, netdev: str, *, protocol: int | None, metric: int = 0) -> str: +def route_del(destination: str, netdev: str, *, protocol: int | None, metric: int = 0, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> str: """Delete one /32 route; naming its protocol makes the kernel refuse any other route.""" - command = f"sudo -n ip route del {_ipv4(destination)}/32 dev {_netdev(netdev)}" + command = f"sudo -n ip route del {_ipv4(destination)}/32 dev {_netdev(netdev, bindings=bindings)}" if protocol is not None: command += f" proto {int(protocol)}" if metric: @@ -336,7 +336,7 @@ def marker_checks(marker: MarkerConfig, action: str = "start the marker") -> tup def marker_start(marker: MarkerConfig, device: str, - rules: Iterable[tuple[str, int]]) -> tuple[str, str, str, str, str]: + rules: Iterable[tuple[str, int]], *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> tuple[str, str, str, str, str]: """The log directory (:func:`log_dir_setup`), the checks of :func:`marker_checks`, then one managed marker started as root in its own session. @@ -353,7 +353,7 @@ def marker_start(marker: MarkerConfig, device: str, raise FabricError(f"a marker for {device} needs at least one rule") return (*log_dir_setup(marker), *marker_checks(marker), f"sudo -n setsid -f bash -c {q(MARKER_LAUNCH)} {q(marker.log(device))} {q(marker.path)} " - f"--device {_device(device)} {rule_words} --managed < /dev/null") + f"--device {_device(device, bindings=bindings)} {rule_words} --managed < /dev/null") def marker_stop(marker: MarkerConfig, pid: int) -> tuple[str, str]: diff --git a/fabric-tool/fabric_tool/diff.py b/fabric-tool/fabric_tool/diff.py index 4cd57ac..7db8cd3 100644 --- a/fabric-tool/fabric_tool/diff.py +++ b/fabric-tool/fabric_tool/diff.py @@ -125,15 +125,15 @@ def _route_equal(entry: RouteEntry, destination: str, netdev: str, source: str) and entry.metric == 0 and entry.kind == "unicast" and entry.destination == destination) -def _route_removal(entry: RouteEntry) -> str: - return commands.route_del(entry.destination, entry.dev, protocol=entry.protocol, metric=entry.metric) +def _route_removal(entry: RouteEntry, bindings: model.FabricBindings) -> str: + return commands.route_del(entry.destination, entry.dev, protocol=entry.protocol, metric=entry.metric, bindings=bindings) -def _filter_removal(entries: Sequence[FilterEntry]) -> list[str]: +def _filter_removal(entries: Sequence[FilterEntry], bindings: model.FabricBindings) -> list[str]: if len(entries) == 1 and entries[0].protocol is not None and entries[0].handle is not None: entry = entries[0] - return [commands.filter_del(entry.netdev, entry.pref, protocol=entry.protocol, handle=entry.handle)] - return [commands.filter_del(entries[0].netdev, entries[0].pref)] + return [commands.filter_del(entry.netdev, entry.pref, protocol=entry.protocol, handle=entry.handle, bindings=bindings)] + return [commands.filter_del(entries[0].netdev, entries[0].pref, bindings=bindings)] def _common_blockers(diff: HostDiff, state: HostState, *, check_hostname: bool) -> bool: @@ -203,7 +203,7 @@ def _marker_blockers(state: HostState, marker: commands.MarkerConfig) -> list[st def _marker_changes(diff: HostDiff, script: _Script, state: HostState, host: HostPlan | None, marker: commands.MarkerConfig) -> None: handled = set() - for device in model.RDMA_DEVICES: + for device in state.bindings.devices: planned = host.marker(device) if host is not None else None wanted = frozenset(planned.rules) if planned is not None else frozenset() present = [process for process in state.markers if process.device == device] @@ -217,7 +217,7 @@ def _marker_changes(diff: HostDiff, script: _Script, state: HostState, host: Hos for process in present: script.marker_stop.extend(commands.marker_stop(marker, process.pid)) if wanted: - script.marker_start.extend(commands.marker_start(marker, device, planned.rules if planned else ())) + script.marker_start.extend(commands.marker_start(marker, device, planned.rules if planned else (), bindings=state.bindings)) before = "; ".join(process.text() + ("" if process.argv[:1] == (marker.path,) else f" (executable {process.argv[0]})") for process in present) diff.changes.append(Change("marker", "replace" if present else "add", device, @@ -240,25 +240,43 @@ def _record(host: HostPlan, plan: GroupPlan, layout_name: str, marker: commands. "qdiscs": sorted(qdiscs)} +@dataclasses.dataclass(frozen=True) +class ReconcilePolicy: + mode: str + remove_stale: bool + require_adoption: bool + + +APPLY = ReconcilePolicy("up", True, True) +RESTORE = ReconcilePolicy("boot", False, False) + + def compare_up(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name: str, marker: commands.MarkerConfig, adopt: bool, check_hostname: bool = True) -> HostDiff: + """Reconcile desired resources and remove stale owned resources.""" + return _reconcile(state, host, plan, layout_name=layout_name, marker=marker, + adopt=adopt, check_hostname=check_hostname, policy=APPLY) + + +def _reconcile(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name: str, + marker: commands.MarkerConfig, adopt: bool, check_hostname: bool, policy: ReconcilePolicy) -> HostDiff: """What ``apply`` changes on one host to install its group's plan.""" - diff = HostDiff(host.position, host.name, plan.group.label, "up") + diff = HostDiff(host.position, host.name, plan.group.label, policy.mode) if _common_blockers(diff, state, check_hostname=check_hostname): return diff script = _Script() - removed_filters = {netdev: 0 for netdev in model.FABRIC_NETDEVS} + removed_filters = {netdev: 0 for netdev in state.bindings.netdevs} # Relay filters (reserved preferences) and the ingress qdiscs they need. added_qdiscs = [] - for netdev in model.FABRIC_NETDEVS: + for netdev in state.bindings.netdevs: planned = {relay_filter.pref: relay_filter for relay_filter in host.filters if relay_filter.in_netdev == netdev} present: dict[int, list[FilterEntry]] = {} for entry in state.reserved_filters(netdev): present.setdefault(entry.pref, []).append(entry) if planned and state.ingress_qdisc.get(netdev) is None: - script.qdisc_add.append(commands.qdisc_add(netdev)) + script.qdisc_add.append(commands.qdisc_add(netdev, bindings=state.bindings)) added_qdiscs.append(netdev) diff.changes.append(Change("qdisc", "add", netdev, "ingress")) for pref, relay_filter in sorted(planned.items()): @@ -269,14 +287,14 @@ def compare_up(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name diff.changes.append(Change("filter", "keep", f"{netdev} pref {pref}", wanted)) continue if entries: - script.filter_del.extend(_filter_removal(entries)) + script.filter_del.extend(_filter_removal(entries, state.bindings)) removed_filters[netdev] += len(entries) - script.filter_add.append(commands.filter_add(relay_filter)) + script.filter_add.append(commands.filter_add(relay_filter, bindings=state.bindings)) before = "; ".join(entry.text() for entry in entries) diff.changes.append(Change("filter", "replace" if entries else "add", f"{netdev} pref {pref}", f"{before} -> {wanted}" if entries else wanted)) - for pref, entries in sorted(present.items()): - script.filter_del.extend(_filter_removal(entries)) + for pref, entries in sorted(present.items()) if policy.remove_stale else (): + script.filter_del.extend(_filter_removal(entries, state.bindings)) removed_filters[netdev] += len(entries) diff.changes.append(Change("filter", "remove", f"{netdev} pref {pref}", "; ".join(entry.text() for entry in entries))) @@ -293,30 +311,31 @@ def compare_up(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name foreign = [entry for entry in entries if entry not in candidates] want = f"dev {route.netdev} src {route.source} -> position {route.peer} {route.peer_netdev}" if foreign: - diff.blockers.append(f"route {destination}/32 is held by a route that is not a relay route " + messages = diff.blockers if policy.require_adoption else diff.notes + messages.append(f"route {destination}/32 is held by a route that is not a relay route " f"({foreign[0].text()}); it is never touched") continue # `ip route replace` rewrites the metric-0 route in place; routes at other metrics are removed. equal = next((entry for entry in candidates if _route_equal(entry, destination, route.netdev, route.source)), None) in_place = equal or next((entry for entry in candidates if entry.metric == 0), None) - for entry in candidates: + for entry in candidates if policy.remove_stale else (): if entry is not in_place: - script.route_del.append(_route_removal(entry)) + script.route_del.append(_route_removal(entry, state.bindings)) diff.changes.append(Change("route", "remove", f"{destination}/32", entry.text(), not entry.owned)) if equal is not None: action = "keep" if equal.owned else "mark" diff.changes.append(Change("route", action, f"{destination}/32", want, not equal.owned)) if action == "mark": - script.route_set.append(commands.route_replace(destination, route.netdev, route.source)) + script.route_set.append(commands.route_replace(destination, route.netdev, route.source, bindings=state.bindings)) else: - script.route_set.append(commands.route_replace(destination, route.netdev, route.source)) + script.route_set.append(commands.route_replace(destination, route.netdev, route.source, bindings=state.bindings)) diff.changes.append(Change("route", "replace" if in_place else "add", f"{destination}/32", f"{in_place.text()} -> {want}" if in_place else want, bool(in_place and not in_place.owned))) for entry in state.relay_routes(): - if entry.destination not in planned_routes: - script.route_del.append(_route_removal(entry)) + if policy.remove_stale and entry.destination not in planned_routes: + script.route_del.append(_route_removal(entry, state.bindings)) diff.changes.append(Change("route", "remove", f"{entry.destination}/32", entry.text(), not entry.owned)) planned_neighbours = {(route.destination, route.netdev): route.next_mac for route in host.routes} @@ -329,13 +348,13 @@ def compare_up(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name action = "keep" if entry.owned else "mark" diff.changes.append(Change("neighbour", action, f"{destination} dev {netdev}", mac, not entry.owned)) if action == "mark": - script.neigh_set.append(commands.neigh_replace(destination, mac, netdev)) + script.neigh_set.append(commands.neigh_replace(destination, mac, netdev, bindings=state.bindings)) continue - script.neigh_set.append(commands.neigh_replace(destination, mac, netdev)) + script.neigh_set.append(commands.neigh_replace(destination, mac, netdev, bindings=state.bindings)) diff.changes.append(Change("neighbour", "replace" if entry else "add", f"{destination} dev {netdev}", f"{entry.mac} -> {mac}" if entry else mac, bool(entry and not entry.owned))) - for (destination, netdev), entry in sorted(present_neighbours.items()): - script.neigh_del.append(commands.neigh_del(destination, netdev)) + for (destination, netdev), entry in sorted(present_neighbours.items()) if policy.remove_stale else (): + script.neigh_del.append(commands.neigh_del(destination, netdev, bindings=state.bindings)) diff.changes.append(Change("neighbour", "remove", f"{destination} dev {netdev}", entry.text(), not entry.owned)) @@ -345,10 +364,10 @@ def compare_up(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name record = state.record if state.record and state.record.get("group") == plan.group.label else None recorded = set(record.get("qdiscs", [])) if record else set() kept = set(added_qdiscs) | recorded - for netdev in sorted(recorded): + for netdev in sorted(recorded) if policy.remove_stale else (): remaining = len(state.filters.get(netdev, [])) - removed_filters[netdev] if netdev not in host.filter_netdevs and remaining <= 0 and state.ingress_qdisc.get(netdev) == "ingress": - script.qdisc_del.append(commands.qdisc_del(netdev)) + script.qdisc_del.append(commands.qdisc_del(netdev, bindings=state.bindings)) kept.discard(netdev) diff.changes.append(Change("qdisc", "remove", netdev, "ingress qdisc added by the tool")) wanted_record = _record(host, plan, layout_name, marker, sorted(kept)) @@ -361,7 +380,8 @@ def compare_up(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name for entry in state.foreign_tag_filters(): diff.notes.append(f"a filter outside the reserved preferences matches relay tag 0x{entry.protocol:04x}: " f"{entry.text()}") - _adopt_blocker(diff, adopt) + if policy.require_adoption: + _adopt_blocker(diff, adopt) diff.commands = script.lines(host.name) if diff.pending else [] return diff @@ -373,21 +393,21 @@ def compare_down(state: HostState, *, group: str, marker: commands.MarkerConfig, if _common_blockers(diff, state, check_hostname=check_hostname): return diff script = _Script() - removed_filters = {netdev: 0 for netdev in model.FABRIC_NETDEVS} - for netdev in model.FABRIC_NETDEVS: + removed_filters = {netdev: 0 for netdev in state.bindings.netdevs} + for netdev in state.bindings.netdevs: present: dict[int, list[FilterEntry]] = {} for entry in state.reserved_filters(netdev): present.setdefault(entry.pref, []).append(entry) for pref, entries in sorted(present.items()): - script.filter_del.extend(_filter_removal(entries)) + script.filter_del.extend(_filter_removal(entries, state.bindings)) removed_filters[netdev] += len(entries) diff.changes.append(Change("filter", "remove", f"{netdev} pref {pref}", "; ".join(entry.text() for entry in entries))) for entry in state.relay_routes(): - script.route_del.append(_route_removal(entry)) + script.route_del.append(_route_removal(entry, state.bindings)) diff.changes.append(Change("route", "remove", f"{entry.destination}/32", entry.text(), not entry.owned)) for entry in state.relay_neighbours(): - script.neigh_del.append(commands.neigh_del(entry.destination, entry.dev)) + script.neigh_del.append(commands.neigh_del(entry.destination, entry.dev, bindings=state.bindings)) diff.changes.append(Change("neighbour", "remove", f"{entry.destination} dev {entry.dev}", entry.text(), not entry.owned)) _marker_changes(diff, script, state, None, marker) @@ -395,7 +415,7 @@ def compare_down(state: HostState, *, group: str, marker: commands.MarkerConfig, for netdev in sorted(recorded): remaining = len(state.filters.get(netdev, [])) - removed_filters.get(netdev, 0) if remaining <= 0 and state.ingress_qdisc.get(netdev) == "ingress": - script.qdisc_del.append(commands.qdisc_del(netdev)) + script.qdisc_del.append(commands.qdisc_del(netdev, bindings=state.bindings)) diff.changes.append(Change("qdisc", "remove", netdev, "ingress qdisc added by the tool")) if state.record is not None: script.record.append(commands.record_remove()) @@ -407,90 +427,7 @@ def compare_down(state: HostState, *, group: str, marker: commands.MarkerConfig, def compare_boot(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name: str, - marker: commands.MarkerConfig, adopt: bool = False, - check_hostname: bool = True) -> HostDiff: - """What ``apply --boot`` installs on one host: the parts of the plan that are missing. - - Restore missing state: add every missing - object, replace a differing object in place at its own reserved - preference, protocol or destination, restart markers whose rules differ or - that are gone, rewrite the record; remove nothing. ``adopt`` is accepted - for one signature with ``compare_up``; boot restore never removes, so - unowned objects are only ever marked in place at their own destination. - """ - diff = HostDiff(host.position, host.name, plan.group.label, "boot") - if _common_blockers(diff, state, check_hostname=True): - return diff - script = _Script() - if state.record is not None and state.record.get("group") != plan.group.label: - # compare_boot keeps another group's record alone; --boot only ever restores its own group. - return diff - for netdev in model.FABRIC_NETDEVS: - planned = {relay_filter.pref: relay_filter for relay_filter in host.filters - if relay_filter.in_netdev == netdev} - if planned and state.ingress_qdisc.get(netdev) is None: - script.qdisc_add.append(commands.qdisc_add(netdev)) - diff.changes.append(Change("qdisc", "add", netdev, "ingress")) - present: dict[int, list[FilterEntry]] = {} - for entry in state.reserved_filters(netdev): - present.setdefault(entry.pref, []).append(entry) - for pref, relay_filter in sorted(planned.items()): - entries = present.get(pref, []) - wanted = (f"0x{relay_filter.protocol:04x} -> 0x{relay_filter.new_type:04x}, dst " - f"{relay_filter.next_mac}, out {relay_filter.out_netdev}") - if len(entries) == 1 and entries[0].matches(relay_filter): - diff.changes.append(Change("filter", "keep", f"{netdev} pref {pref}", wanted)) - continue - if entries: - # The preference is the tool's; one wrong filter there is replaced, not left. - script.filter_del.extend(_filter_removal(entries)) - script.filter_add.append(commands.filter_add(relay_filter)) - before = "; ".join(entry.text() for entry in entries) - diff.changes.append(Change("filter", "replace" if entries else "add", f"{netdev} pref {pref}", - f"{before} -> {wanted}" if entries else wanted)) - for route in host.routes: - entries = [entry for entry in state.routes if entry.prefixlen == 32 - and entry.destination == route.destination] - equal = next((entry for entry in entries if _route_equal(entry, route.destination, route.netdev, - route.source)), None) - if equal is not None and equal.owned: - diff.changes.append(Change("route", "keep", f"{route.destination}/32", - f"dev {route.netdev} src {route.source}")) - continue - if entries and not all(entry.owned or state.is_relay_route(entry) for entry in entries): - diff.notes.append(f"route {route.destination}/32 is held by a route that is not a relay route; " - "boot restore leaves it alone") - continue - script.route_set.append(commands.route_replace(route.destination, route.netdev, route.source)) - before = "; ".join(entry.text() for entry in entries) - diff.changes.append(Change("route", "replace" if entries else "add", f"{route.destination}/32", - f"{before} -> dev {route.netdev} src {route.source}" if entries else - f"dev {route.netdev} src {route.source}")) - for route in host.routes: - neighbours = [entry for entry in state.relay_neighbours() - if (entry.destination, entry.dev) == (route.destination, route.netdev)] - if len(neighbours) == 1 and neighbours[0].mac == route.next_mac.lower(): - action = "keep" if neighbours[0].owned else "mark" - diff.changes.append(Change("neighbour", action, f"{route.destination} dev {route.netdev}", - route.next_mac, not neighbours[0].owned)) - if action == "mark": - script.neigh_set.append(commands.neigh_replace(route.destination, route.next_mac, route.netdev)) - continue - script.neigh_set.append(commands.neigh_replace(route.destination, route.next_mac, route.netdev)) - before = "; ".join(entry.text() for entry in neighbours) - diff.changes.append(Change("neighbour", "replace" if neighbours else "add", - f"{route.destination} dev {route.netdev}", - f"{before} -> {route.next_mac}" if neighbours else route.next_mac)) - _marker_changes(diff, script, state, host, marker) - recorded = set(state.record.get("qdiscs", [])) if state.record else set() - wanted_record = _record(host, plan, layout_name, marker, - sorted(recorded | {netdev for netdev in host.filter_netdevs})) - if state.record != wanted_record: - script.record.extend(commands.record_write(wanted_record)) - before = (f"group {state.record.get('group')}, plan {state.record.get('plan')}" if state.record - else "none") - diff.changes.append(Change("record", "write", commands.RECORD_PATH, - f"{before} -> group {plan.group.label}, layout {layout_name}, " - f"plan {plan.digest}")) - diff.commands = script.lines(host.name) if diff.pending else [] - return diff + marker: commands.MarkerConfig, adopt: bool, check_hostname: bool = True) -> HostDiff: + """Restore desired objects while retaining stale and foreign resources.""" + return _reconcile(state, host, plan, layout_name=layout_name, marker=marker, + adopt=adopt, check_hostname=check_hostname, policy=RESTORE) diff --git a/fabric-tool/fabric_tool/facts.py b/fabric-tool/fabric_tool/facts.py index d834529..d66e33b 100644 --- a/fabric-tool/fabric_tool/facts.py +++ b/fabric-tool/fabric_tool/facts.py @@ -13,8 +13,8 @@ function names are the topology file's (its defaults or its ``port0``/ ``port1`` lines). ``fabric-tool facts`` produces the document from host reads (:func:`from_states`); ``--facts`` files are merged (:func:`load`) and -validated against the topology (:func:`bind`, which also installs the role -table with the netdevs the hosts name). +validated against the topology (:func:`bind`, which returns immutable device +bindings with the host facts). """ from __future__ import annotations @@ -53,7 +53,7 @@ def from_states(states: dict[int, HostState], topology: Topology) -> dict[str, o if not state.reachable or topology.position_of(state.name) < 0 and position != state.position: continue functions: dict[str, dict[str, object]] = {} - for device in model.RDMA_DEVICES: + for device in state.bindings.devices: netdev = state.rdma.get(device, "") link = state.links.get(netdev) if link is None or len(link.addresses) != 1 or not link.mac: @@ -119,7 +119,7 @@ def bind(document: dict[str, object], topology: Topology) -> Facts: Every topology function must be bound on every host; a host must be a topology entry; an optional position must match; the same function must name the same network device on every host (SIRCL's rule for a fabric); - the role table is installed with those devices. + the returned facts retain those device bindings. """ rows = document.get("hosts") if not isinstance(rows, list) or not rows: @@ -139,6 +139,10 @@ def bind(document: dict[str, object], topology: Topology) -> Facts: if missing: raise FabricError(f"facts are missing {', '.join(missing)}; read every host of the topology " "(`facts`) or complete the facts files") + for name, (_, functions) in by_name.items(): + missing_functions = set(topology.functions) - functions.keys() + if missing_functions: + raise FabricError(f"facts for {name} lack functions {sorted(missing_functions)}") netdevs: dict[str, str] = {} for device in topology.functions: named = {str(by_name[name][1][device]["netdev"]) for name in topology.hosts} @@ -149,7 +153,7 @@ def bind(document: dict[str, object], topology: Topology) -> Facts: roles = tuple(model.Role(("cw_primary", "cw_secondary", "ccw_primary", "ccw_secondary")[index], device, netdevs[device], index // 2, bool(index % 2)) for index, device in enumerate(topology.functions)) - model.set_roles(roles) + bindings = model.FabricBindings(roles) hosts = [] for position, name in enumerate(topology.hosts): functions = by_name[name][1] @@ -159,7 +163,7 @@ def bind(document: dict[str, object], topology: Topology) -> Facts: ports.append(Port(str(bound["netdev"]), str(bound["mac"]), str(bound["address"]), bound["prefixlen"] if isinstance(bound["prefixlen"], int) else None)) hosts.append(HostFacts(position, name, tuple(ports))) - facts = Facts(hosts) + facts = Facts(hosts, bindings=bindings) problems = facts.problems() if problems: raise FabricError("; ".join(problems)) @@ -172,7 +176,7 @@ def problems_against_reads(facts: Facts, states: dict[int, HostState], topology: for position, state in sorted(states.items()): if not state.reachable or topology.position_of(state.name) != position: continue - for netdev in model.FABRIC_NETDEVS: + for netdev in facts.bindings.netdevs: bound = facts.port(position, netdev) if facts.has(position) else None reported = state.port(netdev) if bound is None or reported is None: diff --git a/fabric-tool/fabric_tool/model.py b/fabric-tool/fabric_tool/model.py index 04cfcfd..1afb4ee 100644 --- a/fabric-tool/fabric_tool/model.py +++ b/fabric-tool/fabric_tool/model.py @@ -13,8 +13,8 @@ port 1 secondary roceP2p1s0f1 enP2p1s0f1np1 A topology file may name other functions (``port0 ``, -``port1 ``); the tool sets the role table from it once, before any -planning (:func:`set_roles`), and every module reads the table at call time. +``port1 ``); an immutable role table follows the topology and its resolved facts through +planning, observation and command generation. A cable joins one port of one Spark to one port of another and carries two links (the primary functions of its ends and the secondary functions). A fabric is the set of cables a group owns, written @@ -63,49 +63,66 @@ def label(self) -> str: Role("ccw_secondary", "roceP2p1s0f1", "enP2p1s0f1np1", 1, True), ) -# The role table this process plans with: set once from the topology file -# (:func:`set_roles`) before any planning or command generation. -ROLES: tuple[Role, ...] = DEFAULT_ROLES -FABRIC_NETDEVS: tuple[str, ...] = tuple(role.netdev for role in ROLES) -RDMA_DEVICES: tuple[str, ...] = tuple(role.device for role in ROLES) +@dataclasses.dataclass(frozen=True) +class FabricBindings: + """Four validated RDMA functions and their Ethernet interfaces for one operation.""" + roles: tuple[Role, ...] = DEFAULT_ROLES -def set_roles(roles: Sequence[Role]) -> None: - """Install ``roles`` as this process's role table (the four functions, port 0 and 1, both classes).""" - global ROLES, FABRIC_NETDEVS, RDMA_DEVICES - roles = tuple(roles) - if len(roles) != 4: - raise FabricError(f"a role table holds four functions, got {len(roles)}") - if len({role.device for role in roles}) != 4 or len({role.netdev for role in roles}) != 4: - raise FabricError("a role table names one device or interface for two functions") - if sorted((role.port, role.secondary) for role in roles) != [(0, False), (0, True), (1, False), (1, True)]: - raise FabricError("a role table needs the primary and the secondary function of each port") - ROLES = roles - FABRIC_NETDEVS = tuple(role.netdev for role in ROLES) - RDMA_DEVICES = tuple(role.device for role in ROLES) + def __post_init__(self) -> None: + object.__setattr__(self, "roles", tuple(self.roles)) + if len(self.roles) != 4: + raise FabricError("a role table holds four functions") + for role in self.roles: + device_name(role.device) + device_name(role.netdev) + if len(set(self.devices)) != 4 or len(set(self.netdevs)) != 4: + raise FabricError("a role table names one device or interface for two functions") + if sorted((r.port, r.secondary) for r in self.roles) != [(0, False), (0, True), (1, False), (1, True)]: + raise FabricError("a role table needs both function classes of each port") + @property + def devices(self) -> tuple[str, ...]: + return tuple(role.device for role in self.roles) -def role_at(port: int, secondary: bool) -> Role: - for role in ROLES: - if role.port == port and role.secondary == secondary: - return role - raise FabricError(f"no function on port {port}") + @property + def netdevs(self) -> tuple[str, ...]: + return tuple(role.netdev for role in self.roles) + + def role_at(self, port: int, secondary: bool) -> Role: + return next(role for role in self.roles if (role.port, role.secondary) == (port, secondary)) + + def role_of(self, device: str) -> Role | None: + return next((role for role in self.roles if role.device == device), None) + def role_of_netdev(self, netdev: str) -> Role: + for role in self.roles: + if role.netdev == netdev: + return role + raise FabricError(f"{netdev!r} is not a fabric network device") -def role_of(device: str) -> Role | None: - """The role of an RDMA device name, or None.""" - for role in ROLES: - if role.device == device: - return role - return None + +def device_name(value: str) -> str: + """Device identifiers are data, with no shell syntax or path components.""" + if not re.fullmatch(r"[A-Za-z0-9_][A-Za-z0-9_.:-]{0,62}", value): + raise FabricError(f"invalid device identifier {value!r}") + return value + + +DEFAULT_BINDINGS = FabricBindings() +# Immutable defaults for callers constructing the standard DGX Spark layout. +ROLES = DEFAULT_BINDINGS.roles +FABRIC_NETDEVS = DEFAULT_BINDINGS.netdevs +RDMA_DEVICES = DEFAULT_BINDINGS.devices + + +def role_at(port: int, secondary: bool) -> Role: + return DEFAULT_BINDINGS.role_at(port, secondary) def role_of_netdev(netdev: str) -> Role: - """The role of a network device name; FabricError for a device outside the fabric.""" - for role in ROLES: - if role.netdev == netdev: - return role - raise FabricError(f"{netdev} is not one of the fabric network devices {', '.join(FABRIC_NETDEVS)}") + return DEFAULT_BINDINGS.role_of_netdev(netdev) + def class_name(secondary: bool) -> str: @@ -337,7 +354,7 @@ def to_json(self) -> dict[str, object]: } -def derive_lanes(fabric: Fabric, a: int, b: int, lanes: int = 2) -> tuple[LaneRoute, ...]: +def derive_lanes(fabric: Fabric, a: int, b: int, lanes: int = 2, *, bindings: FabricBindings = DEFAULT_BINDINGS) -> tuple[LaneRoute, ...]: """The lanes from position ``a`` to position ``b``. The shortest paths of the fabric (one, or two when the two ends are @@ -375,8 +392,8 @@ def leaves_smaller_through_port0(path: tuple[Step, ...]) -> bool: for lane in range(lanes): path = chosen[lane] secondary = lane == 1 - result.append(LaneRoute(lane, role_at(path[0].src_port, secondary), - role_at(path[-1].dst_port, secondary), path)) + result.append(LaneRoute(lane, bindings.role_at(path[0].src_port, secondary), + bindings.role_at(path[-1].dst_port, secondary), path)) return tuple(result) @@ -408,11 +425,11 @@ def max_relays(self) -> int: default=0) -def derive_routes(layout: Layout, lanes: int = 2) -> GroupRoutes: +def derive_routes(layout: Layout, lanes: int = 2, *, bindings: FabricBindings = DEFAULT_BINDINGS) -> GroupRoutes: """Route maps of every rank of a session on ``layout``.""" ranks = [] for rank, here in enumerate(layout.positions): - ranks.append({peer: derive_lanes(layout.fabric, here, there, lanes) + ranks.append({peer: derive_lanes(layout.fabric, here, there, lanes, bindings=bindings) for peer, there in enumerate(layout.positions) if peer != rank}) return GroupRoutes(layout, lanes, tuple(ranks)) @@ -440,8 +457,9 @@ def relay_load(routes: GroupRoutes) -> tuple[int, float]: return busiest, busiest / routes.lanes -def _lane_steps(layout: Layout, rank: int, peer: int, device: str) -> tuple[Role, tuple[Step, ...]] | None: - role = role_of(device) +def _lane_steps(layout: Layout, rank: int, peer: int, device: str, + bindings: FabricBindings) -> tuple[Role, tuple[Step, ...]] | None: + role = bindings.role_of(device) if role is None: return None steps = layout.fabric.walk(layout.positions[rank], role.port, layout.positions[peer], @@ -450,7 +468,8 @@ def _lane_steps(layout: Layout, rank: int, peer: int, device: str) -> tuple[Role def relay_queues(layout: Layout, - route_maps: Sequence[Mapping[int, Sequence[str]]]) -> dict[tuple[int, bool, int], + route_maps: Sequence[Mapping[int, Sequence[str]]], *, + bindings: FabricBindings = DEFAULT_BINDINGS) -> dict[tuple[int, bool, int], list[tuple[int, int, int]]]: """Lanes through every relay hairpin queue of a group. @@ -461,7 +480,7 @@ def relay_queues(layout: Layout, for rank, routes in enumerate(route_maps): for peer, devices in sorted(routes.items()): for lane, device in enumerate(devices): - found = _lane_steps(layout, rank, peer, device) + found = _lane_steps(layout, rank, peer, device, bindings) if found is None: continue role, steps = found diff --git a/fabric-tool/fabric_tool/ops.py b/fabric-tool/fabric_tool/ops.py index e06fb8c..7c830dd 100644 --- a/fabric-tool/fabric_tool/ops.py +++ b/fabric-tool/fabric_tool/ops.py @@ -102,23 +102,23 @@ def _parallel(jobs: Sequence[int], work: Callable[[int], T]) -> dict[int, T]: def gather(hosts: dict[int, HostTarget], positions: Iterable[int], executor: Executor, - marker: commands.MarkerConfig, *, timeout: float = READ_TIMEOUT) -> dict[int, HostState]: + marker: commands.MarkerConfig, *, timeout: float = READ_TIMEOUT, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> dict[int, HostState]: """Read every listed host (READ-ONLY REMOTE).""" - script = commands.read_script(marker) + script = commands.read_script(marker, bindings=bindings) def read(position: int) -> HostState: target = hosts[position] result = executor(target.ssh or "", script, timeout) return state_mod.parse(position, target.name, target.ssh or "", returncode=result.returncode, - stdout=result.stdout, stderr=result.stderr) + stdout=result.stdout, stderr=result.stderr, bindings=bindings) return {position: state for position, state in _parallel(sorted(set(positions)), read).items()} -def facts_from(states: dict[int, HostState]) -> Facts: +def facts_from(states: dict[int, HostState], *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> Facts: """The addresses and MACs the hosts report (only usable ports are included).""" - return Facts(HostFacts(position, state.name, state.ports()) - for position, state in sorted(states.items()) if state.reachable) + return Facts((HostFacts(position, state.name, state.ports()) + for position, state in sorted(states.items()) if state.reachable), bindings=bindings) def cable_problems(group: GroupSpec, facts: Facts) -> list[str]: @@ -127,8 +127,8 @@ def cable_problems(group: GroupSpec, facts: Facts) -> list[str]: problems = [] for cable in group.layout.fabric.cables: for secondary in (False, True): - here = facts.port(cable.a, model.role_at(cable.a_port, secondary).netdev) - there = facts.port(cable.b, model.role_at(cable.b_port, secondary).netdev) + here = facts.port(cable.a, facts.bindings.role_at(cable.a_port, secondary).netdev) + there = facts.port(cable.b, facts.bindings.role_at(cable.b_port, secondary).netdev) networks = (here.network(), there.network()) if None in networks: continue @@ -179,10 +179,10 @@ def evaluate(topology: Topology, states: dict[int, HostState], file_facts: Facts group = topology.group compared = sorted(set(positions if positions is not None else group.order)) outcome = Outcome(topology, group, mode, None) - problems = model.isolation_problems([model.derive_routes(group.layout, 2)]) + problems = model.isolation_problems([model.derive_routes(group.layout, 2, bindings=file_facts.bindings if file_facts else topology.bindings)]) if problems: raise FabricError("isolation: " + "; ".join(problems)) - read_facts = facts_from(states) + read_facts = facts_from(states, bindings=file_facts.bindings if file_facts else topology.bindings) if len(read_facts.positions) == len(group.members) and file_facts is None: facts = read_facts elif file_facts is not None: @@ -200,7 +200,7 @@ def evaluate(topology: Topology, states: dict[int, HostState], file_facts: Facts return outcome problems += [problem for position in compared for problem in states[position].fact_problems(check_hostname=False)] - member_facts = Facts([read_facts.host(p) for p in compared if read_facts.has(p)]) + member_facts = Facts([read_facts.host(p) for p in compared if read_facts.has(p)], bindings=read_facts.bindings) problems += member_facts.problems() plan = None if not problems: diff --git a/fabric-tool/fabric_tool/plan.py b/fabric-tool/fabric_tool/plan.py index 306e42c..ddccf6f 100644 --- a/fabric-tool/fabric_tool/plan.py +++ b/fabric-tool/fabric_tool/plan.py @@ -142,7 +142,8 @@ def port(self, netdev: str) -> Port | None: class Facts: """Addresses and MACs of the fabric functions of the hosts a plan uses.""" - def __init__(self, hosts: Iterable[HostFacts], *, symbolic: bool = False) -> None: + def __init__(self, hosts: Iterable[HostFacts], *, symbolic: bool = False, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> None: + self.bindings = bindings self.symbolic = symbolic self._hosts = {host.position: host for host in hosts} self._addresses: dict[str, list[tuple[int, str]]] = {} @@ -192,16 +193,17 @@ def problems(self) -> list[str]: return found @classmethod - def symbolic_for(cls, names: Sequence[str]) -> "Facts": + def symbolic_for(cls, names: Sequence[str], *, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> "Facts": """Placeholders ```` and ```` for every host of a layout.""" return cls((HostFacts(position, name, tuple(Port(netdev, f"<{name}:{netdev}:mac>", f"<{name}:{netdev}>") - for netdev in model.FABRIC_NETDEVS)) - for position, name in enumerate(names)), symbolic=True) + for netdev in bindings.netdevs)) + for position, name in enumerate(names)), symbolic=True, bindings=bindings) def port_from_text(netdev: str, mac: str, address: str, *, owner: str) -> Port: """A validated :class:`Port` from a MAC and ``a.b.c.d`` or ``a.b.c.d/len``.""" + model.device_name(netdev) mac = mac.strip().lower() if not _MAC.match(mac): raise FabricError(f"{owner} {netdev}: {mac!r} is not a MAC address") @@ -296,6 +298,7 @@ class HostPlan: group: str routes: tuple[OriginRoute, ...] filters: tuple[RelayFilter, ...] + bindings: model.FabricBindings = model.DEFAULT_BINDINGS @property def markers(self) -> tuple[MarkerRules, ...]: @@ -303,7 +306,7 @@ def markers(self) -> tuple[MarkerRules, ...]: for route in self.routes: by_device.setdefault(route.device, []).append((route.destination, route.tag)) return tuple(MarkerRules(device, tuple(sorted(rules, key=lambda rule: _address_key(rule[0])))) - for device, rules in sorted(by_device.items(), key=lambda item: model.RDMA_DEVICES.index(item[0]))) + for device, rules in sorted(by_device.items(), key=lambda item: self.bindings.devices.index(item[0]))) def marker(self, device: str) -> MarkerRules | None: for rules in self.markers: @@ -313,7 +316,7 @@ def marker(self, device: str) -> MarkerRules | None: @property def filter_netdevs(self) -> tuple[str, ...]: - return tuple(netdev for netdev in model.FABRIC_NETDEVS + return tuple(netdev for netdev in self.bindings.netdevs if any(relay_filter.in_netdev == netdev for relay_filter in self.filters)) def route_to(self, destination: str) -> OriginRoute | None: @@ -403,9 +406,9 @@ def _carry(path: tuple[model.Step, ...], secondary: bool, facts: Facts, relay_eg filters_at: dict[int, dict[tuple[str, int], RelayFilter]], label: str) -> None: hops = len(path) origin, target = path[0].src, path[-1].dst - local = model.role_at(path[0].src_port, secondary) - remote = model.role_at(path[-1].dst_port, secondary) - first = model.role_at(path[0].dst_port, secondary) + local = facts.bindings.role_at(path[0].src_port, secondary) + remote = facts.bindings.role_at(path[-1].dst_port, secondary) + first = facts.bindings.role_at(path[0].dst_port, secondary) route = OriginRoute( destination=facts.port(target, remote.netdev).address, netdev=local.netdev, device=local.device, source=facts.port(origin, local.netdev).address, next_mac=facts.port(path[0].dst, first.netdev).mac, @@ -421,9 +424,9 @@ def _carry(path: tuple[model.Step, ...], secondary: bool, facts: Facts, relay_eg relay = arrive.dst if leave.src != relay or leave.src_port != 1 - arrive.dst_port: raise FabricError(f"group {label}: the path {route.cables} does not pass through host {relay}") - in_role = model.role_at(arrive.dst_port, secondary) - out_role = model.role_at(leave.src_port, secondary if relay_egress == "same" else not secondary) - next_role = model.role_at(leave.dst_port, secondary) + in_role = facts.bindings.role_at(arrive.dst_port, secondary) + out_role = facts.bindings.role_at(leave.src_port, secondary if relay_egress == "same" else not secondary) + next_role = facts.bindings.role_at(leave.dst_port, secondary) relay_filter = RelayFilter( in_netdev=in_role.netdev, k=hops - 1 - index, out_netdev=out_role.netdev, next_mac=facts.port(leave.dst, next_role.netdev).mac, next_position=leave.dst, @@ -469,7 +472,7 @@ def build_group_plan(group: GroupSpec, facts: Facts, *, relay_egress: str, "--max-relays raises it, research-only)") for secondary in (False, True): _carry(path, secondary, facts, relay_egress, routes_at, filters_at, group.label) - sircl = model.derive_routes(layout, 2) + sircl = model.derive_routes(layout, 2, bindings=facts.bindings) lanes_of: dict[tuple[int, str], list[str]] = {} for rank, peers in enumerate(sircl.ranks): origin = layout.positions[rank] @@ -487,12 +490,12 @@ def build_group_plan(group: GroupSpec, facts: Facts, *, relay_egress: str, hosts = [] for position in group.order: planned = sorted(routes_at[position].values(), - key=lambda r: (model.FABRIC_NETDEVS.index(r.netdev), r.hops, _address_key(r.destination))) + key=lambda r: (facts.bindings.netdevs.index(r.netdev), r.hops, _address_key(r.destination))) planned = [dataclasses.replace(route, lanes=tuple(lanes_of.get((position, route.destination), ()))) for route in planned] filters = sorted(filters_at[position].values(), - key=lambda f: (model.FABRIC_NETDEVS.index(f.in_netdev), f.k)) - hosts.append(HostPlan(position, facts.name(position), group.label, tuple(planned), tuple(filters))) + key=lambda f: (facts.bindings.netdevs.index(f.in_netdev), f.k)) + hosts.append(HostPlan(position, facts.name(position), group.label, tuple(planned), tuple(filters), facts.bindings)) by_position = {host.position: host for host in hosts} for host in hosts: for route in host.routes: @@ -506,9 +509,10 @@ def build_group_plan(group: GroupSpec, facts: Facts, *, relay_egress: str, f"crosses hosts {outside} outside the group") maps = [sircl.route_map(rank) for rank in range(layout.world)] queues = [] - for (relay, secondary, egress_port), members_of_queue in sorted(model.relay_queues(layout, maps).items()): - in_role = model.role_at(1 - egress_port, secondary) - out_role = model.role_at(egress_port, secondary if relay_egress == "same" else not secondary) + for (relay, secondary, egress_port), members_of_queue in sorted( + model.relay_queues(layout, maps, bindings=facts.bindings).items()): + in_role = facts.bindings.role_at(1 - egress_port, secondary) + out_role = facts.bindings.role_at(egress_port, secondary if relay_egress == "same" else not secondary) queues.append(RelayQueue(relay, in_role.netdev, out_role.netdev, tuple(f"rank {r}->{p} lane {lane}" for r, p, lane in members_of_queue))) busiest, load = model.relay_load(sircl) @@ -518,7 +522,7 @@ def build_group_plan(group: GroupSpec, facts: Facts, *, relay_egress: str, def build_plan(group: GroupSpec, facts: Facts, *, max_relays: int = model.DEFAULT_MAX_RELAYS) -> GroupPlan: """The plan of a topology's group, checked for isolation.""" - problems = model.isolation_problems([model.derive_routes(group.layout, 2)]) + problems = model.isolation_problems([model.derive_routes(group.layout, 2, bindings=facts.bindings)]) plan = build_group_plan(group, facts, relay_egress=group.relay_egress, max_relays=max_relays) problems += isolation_problems([plan]) if problems: @@ -554,10 +558,10 @@ def trace(hosts: Mapping[int, HostPlan], facts: Facts, ring_size: int, origin: i mac, ethertype, here, out_netdev = route.next_mac, route.tag, origin, route.netdev hops: list[tuple[int, str]] = [] for _ in range(limit): - port = model.role_of_netdev(out_netdev).port + port = facts.bindings.role_of_netdev(out_netdev).port there = (here + 1) % ring_size if port == 0 else (here - 1) % ring_size receiver = facts.find_mac(mac) - if receiver is None or receiver[0] != there or model.role_of_netdev(receiver[1]).port != 1 - port: + if receiver is None or receiver[0] != there or facts.bindings.role_of_netdev(receiver[1]).port != 1 - port: return Trace("misdelivered", tuple(hops), f"a frame for {mac} leaves position {here} port {port}; " f"the cable ends at position {there} port {1 - port}") hops.append(receiver) @@ -597,7 +601,7 @@ def isolation_problems(plans: Sequence[GroupPlan]) -> list[str]: f"crosses {route.cables}, outside the group's cables {sorted(owned)}") for relay_filter in host.filters: for netdev in (relay_filter.in_netdev, relay_filter.out_netdev): - port = model.role_of_netdev(netdev).port + port = host.bindings.role_of_netdev(netdev).port if fabric.cable_at(host.position, port) is None: problems.append(f"{plan.group.label}: {host.name} relays through {netdev} (port {port}), " "whose cable the group does not own") diff --git a/fabric-tool/fabric_tool/report.py b/fabric-tool/fabric_tool/report.py index a9be00e..e209b1d 100644 --- a/fabric-tool/fabric_tool/report.py +++ b/fabric-tool/fabric_tool/report.py @@ -15,7 +15,6 @@ from . import commands, model from .diff import HostDiff -from .model import role_of_netdev from .ops import Outcome from .plan import relays_left from .state import HostState @@ -25,7 +24,7 @@ def _lookups(states: Mapping[int, HostState]) -> tuple[dict[str, str], dict[str, addresses, macs = {}, {} for state in states.values(): for name, link in state.links.items(): - if name not in model.FABRIC_NETDEVS: + if name not in state.bindings.netdevs: continue if link.mac: macs[link.mac] = f"{state.name} {name}" @@ -57,7 +56,7 @@ def render_show(states: Mapping[int, HostState], marker: commands.MarkerConfig) for problem in ([state.record_problem] if state.record_problem else []) + state.parse_problems: lines.append(f" problem: {problem}") ports = [] - for netdev in model.FABRIC_NETDEVS: + for netdev in state.bindings.netdevs: link = state.links.get(netdev) if link is None: ports.append(f"{netdev} missing") @@ -75,10 +74,10 @@ def render_show(states: Mapping[int, HostState], marker: commands.MarkerConfig) neighbours = {(n.destination, n.dev): n for n in state.relay_neighbours()} lines.append(f" routes: {len(relay_routes)} relay routes " f"({sum(1 for r in relay_routes if not r.owned)} unowned)") - for route in sorted(relay_routes, key=lambda r: (model.FABRIC_NETDEVS.index(r.dev) - if r.dev in model.FABRIC_NETDEVS else 9, r.destination)): + for route in sorted(relay_routes, key=lambda r: (state.bindings.netdevs.index(r.dev) + if r.dev in state.bindings.netdevs else 9, r.destination)): neighbour = neighbours.pop((route.destination, route.dev), None) - device = role_of_netdev(route.dev).device if route.dev in model.FABRIC_NETDEVS else None + device = state.bindings.role_of_netdev(route.dev).device if route.dev in state.bindings.netdevs else None value = tags.get((device, route.destination)) tag_text = f"tag 0x{value:04x}" if value is not None else "no tag" if neighbour is None: @@ -99,7 +98,7 @@ def render_show(states: Mapping[int, HostState], marker: commands.MarkerConfig) installed = (f"installed {log.get('installed')}/{len(log.get('rules', []))}" if "installed" in log else "no log") lines.append(f" {process.text()}; {installed} [{owner}]") - filters = [entry for netdev in model.FABRIC_NETDEVS for entry in state.reserved_filters(netdev)] + filters = [entry for netdev in state.bindings.netdevs for entry in state.reserved_filters(netdev)] lines.append(f" relay filters: {len(filters)}") for entry in filters: k = relays_left(entry.protocol) if entry.protocol is not None else None diff --git a/fabric-tool/fabric_tool/state.py b/fabric-tool/fabric_tool/state.py index f1e775a..020eec4 100644 --- a/fabric-tool/fabric_tool/state.py +++ b/fabric-tool/fabric_tool/state.py @@ -422,6 +422,7 @@ class HostState: name: str ssh: str reachable: bool + bindings: model.FabricBindings = model.DEFAULT_BINDINGS error: str = "" hostname: str = "" versions: str = "" @@ -455,7 +456,7 @@ def port(self, netdev: str) -> Port | None: return None def ports(self) -> tuple[Port, ...]: - return tuple(port for port in (self.port(netdev) for netdev in model.FABRIC_NETDEVS) if port is not None) + return tuple(port for port in (self.port(netdev) for netdev in self.bindings.netdevs) if port is not None) def fact_problems(self, *, check_hostname: bool = True) -> list[str]: if not self.reachable: @@ -464,11 +465,11 @@ def fact_problems(self, *, check_hostname: bool = True) -> list[str]: if check_hostname and self.hostname != self.name: problems.append(f"{self.name}: the host at {self.ssh} is named {self.hostname or 'nothing'}, the " "topology lists it as " + self.name) - for device, netdev in zip(model.RDMA_DEVICES, model.FABRIC_NETDEVS): + for device, netdev in zip(self.bindings.devices, self.bindings.netdevs): if self.rdma.get(device) != netdev: problems.append(f"{self.name}: RDMA device {device} belongs to network device " f"{self.rdma.get(device) or 'none'}, expected {netdev}") - for netdev in model.FABRIC_NETDEVS: + for netdev in self.bindings.netdevs: link = self.links.get(netdev) if link is None: problems.append(f"{self.name}: network device {netdev} is missing") @@ -491,7 +492,7 @@ def on_link(self, netdev: str, address: str) -> bool: return any(value in network for network in link.networks()) def is_relay_route(self, route: RouteEntry) -> bool: - return (route.prefixlen == 32 and route.dev in model.FABRIC_NETDEVS and route.scope == "link" + return (route.prefixlen == 32 and route.dev in self.bindings.netdevs and route.scope == "link" and not route.gateway and route.kind == "unicast" and not self.on_link(route.dev, route.destination)) def relay_routes(self) -> list[RouteEntry]: @@ -499,7 +500,7 @@ def relay_routes(self) -> list[RouteEntry]: return [route for route in self.routes if route.owned or self.is_relay_route(route)] def is_relay_neighbour(self, neighbour: NeighbourEntry) -> bool: - return (neighbour.permanent and neighbour.dev in model.FABRIC_NETDEVS + return (neighbour.permanent and neighbour.dev in self.bindings.netdevs and (neighbour.owned or not self.on_link(neighbour.dev, neighbour.destination))) def relay_neighbours(self) -> list[NeighbourEntry]: @@ -510,7 +511,7 @@ def reserved_filters(self, netdev: str) -> list[FilterEntry]: def foreign_tag_filters(self) -> list[FilterEntry]: """Filters outside the reserved preferences that match a relay tag (they could take relayed frames).""" - return [entry for netdev in model.FABRIC_NETDEVS for entry in self.filters.get(netdev, []) + return [entry for netdev in self.bindings.netdevs for entry in self.filters.get(netdev, []) if not entry.reserved and entry.protocol is not None and entry.protocol != ETH_P_IP and relays_left(entry.protocol)] @@ -546,9 +547,9 @@ def _parse_record(text: str, schema: str, problems: list[str], what: str) -> dic return None -def parse(position: int, name: str, ssh: str, *, returncode: int, stdout: str, stderr: str) -> HostState: +def parse(position: int, name: str, ssh: str, *, returncode: int, stdout: str, stderr: str, bindings: model.FabricBindings = model.DEFAULT_BINDINGS) -> HostState: """The :class:`HostState` of one host from its read script's output.""" - state = HostState(position, name, ssh, reachable=True) + state = HostState(position, name, ssh, reachable=True, bindings=bindings) sections = parse_sections(stdout) if "end" not in sections: state.reachable = bool(sections) @@ -563,12 +564,12 @@ def parse(position: int, name: str, ssh: str, *, returncode: int, stdout: str, s state.hostname = raw.get("hostname", "").strip() state.versions = " | ".join(line.strip() for line in raw.get("versions", "").splitlines() if line.strip()) state.links = parse_links(raw.get("links", ""), problems) - for device in model.RDMA_DEVICES: + for device in bindings.devices: netdevs = raw.get(f"rdma:{device}", "").split() state.rdma[device] = netdevs[0] if netdevs else "" state.routes = parse_routes(raw.get("routes", ""), problems) state.neighbours = parse_neighbours(raw.get("neighbours", ""), problems) - for netdev in model.FABRIC_NETDEVS: + for netdev in bindings.netdevs: state.ingress_qdisc[netdev] = parse_ingress_qdisc(raw.get(f"qdisc:{netdev}", ""), problems, netdev) state.filters[netdev] = parse_filters(raw.get(f"filters:{netdev}", ""), problems, netdev) state.markers = parse_markers(raw.get("markers", "")) @@ -577,7 +578,7 @@ def parse(position: int, name: str, ssh: str, *, returncode: int, stdout: str, s recorded = raw.get("marker-record", "").strip() state.marker_recorded = recorded if len(recorded) == 64 and set(recorded) <= set("0123456789abcdef") else None state.marker_owners = parse_owners(raw.get("marker-owners", "")) - for device in model.RDMA_DEVICES: + for device in bindings.devices: text = raw.get(f"marker-log:{device}", "").strip() first = text.splitlines()[0] if text else "" try: diff --git a/fabric-tool/fabric_tool/topology.py b/fabric-tool/fabric_tool/topology.py index 28cf118..bf4dd3d 100644 --- a/fabric-tool/fabric_tool/topology.py +++ b/fabric-tool/fabric_tool/topology.py @@ -17,8 +17,7 @@ 512 KiB hairpin queue); - ``net-sircl-topology``: the file's optional first key, as the plugin reads it. -:func:`load` parses a file, installs the role table it names -(:func:`fabric_tool.model.set_roles`) and returns the :class:`Topology`. Its +:func:`load` returns a validated :class:`Topology` with immutable device bindings. Its :attr:`Topology.group` is the one group the tool plans: the fabric of the topology's cables over positions 0..N-1, whole cycle or path, with the relay-egress default (``same`` for a whole cycle, @@ -53,6 +52,7 @@ class GroupSpec: layout: Layout relay_egress: str name: str = "topology" + bindings: model.FabricBindings = model.DEFAULT_BINDINGS @property def members(self) -> tuple[int, ...]: @@ -119,6 +119,10 @@ class Topology: functions: tuple[str, ...] # port 0 lane 0/1, port 1 lane 0/1 budget: int + @property + def bindings(self) -> model.FabricBindings: + return model.FabricBindings(_roles_of_functions(self.functions)) + @property def size(self) -> int: return len(self.hosts) @@ -177,6 +181,8 @@ def parse(text: str, *, path: str = "") -> Topology: except FabricError: raise FabricError(f"{path}:{lineno}: a cable is `cable .port<0|1> .port<0|1>`") from None elif key in ("port0", "port1"): + if len(rest) != 2: + raise FabricError(f"{path}:{lineno}: {key} requires exactly two device identifiers") port = int(key[-1]) for lane, name in enumerate(rest[:2]): functions[2 * port + lane] = name @@ -214,6 +220,7 @@ def parse(text: str, *, path: str = "") -> Topology: if fabric.kind != "cycle" and not _is_connected_path(fabric): raise FabricError(f"{path}: the cables do not join the hosts into one path or cycle") topology = Topology(path, tuple(hosts), cabling, tuple(fabric.cables), tuple(functions), budget) + topology.bindings # Validate identifiers before any host operation. return topology @@ -235,16 +242,16 @@ def _group_of(topology: Topology) -> GroupSpec: fabric = Fabric(topology.cables) layout = Layout(fabric, tuple(range(topology.size))) egress = "same" if fabric.kind == "cycle" else "sibling" - return GroupSpec(layout, egress, f"topology:{Path(topology.path).name}") + return GroupSpec(layout, egress, f"topology:{Path(topology.path).name}", topology.bindings) def load(path: str | Path) -> Topology: - """Read, parse and install the role table of a topology file.""" + """Read and validate a topology file without changing process state.""" file = Path(path) try: text = file.read_text(encoding="utf-8") except OSError as error: raise FabricError(f"cannot read the topology file {file}: {error}") from None topology = parse(text, path=str(file)) - model.set_roles(_roles_of_functions(topology.functions)) + topology.bindings # Validate identifiers before any host operation. return topology diff --git a/fabric-tool/tests/test_boot.py b/fabric-tool/tests/test_boot.py index cce5929..6491879 100644 --- a/fabric-tool/tests/test_boot.py +++ b/fabric-tool/tests/test_boot.py @@ -4,14 +4,17 @@ from fabric_tool import boot from fabric_tool import cli +import shlex def test_unit_text(): text = boot.unit_text() assert text.startswith("[Unit]") assert "After=network-online.target" in text - assert f"ExecStart={boot.DEFAULT_TOOL} apply --boot --topology {boot.TOPOLOGY_INPUT} " \ - f"--facts {boot.FACTS_INPUT}" in text + argv = shlex.split(next(line.removeprefix("ExecStart=") for line in text.splitlines() + if line.startswith("ExecStart="))) + assert argv == list(boot.RestoreInvocation().argv()) + assert "--execute" in argv assert "WantedBy=multi-user.target" in text diff --git a/fabric-tool/tests/test_operation_contracts.py b/fabric-tool/tests/test_operation_contracts.py new file mode 100644 index 0000000..79ea40b --- /dev/null +++ b/fabric-tool/tests/test_operation_contracts.py @@ -0,0 +1,87 @@ +"""Configuration identity, persisted invocation and reconciliation ownership contracts.""" +import dataclasses +import json +import shlex + +import pytest + +from fabric_tool import boot, cli, commands, diff, facts, model, ops, plan, state, topology +from test_facts import _document, RING4 + + +def custom_document(): + document = _document() + for host in document['hosts']: + for index, function in enumerate(host['functions'].values()): + function['netdev'] = f'fabric{index}' + return document + + +def test_plans_keep_their_bindings_after_other_configurations_are_resolved(): + topo = topology.parse(RING4) + customized = facts.bind(custom_document(), topo) + custom_plan = plan.build_plan(topo.group, customized) + before = custom_plan.to_json() + ordinary = facts.bind(_document(), topo) + plan.build_plan(topo.group, ordinary) + assert custom_plan.to_json() == before + assert any('fabric' in route.netdev for host in custom_plan.hosts for route in host.routes) + assert topo.bindings == model.DEFAULT_BINDINGS + assert customized.bindings != ordinary.bindings + + +@pytest.mark.parametrize('operation', ['apply', 'verify']) +def test_custom_facts_are_bound_before_the_first_host_read(tmp_path, monkeypatch, operation): + path = tmp_path / 'ring.topology' + path.write_text(RING4) + document = tmp_path / 'facts.json' + document.write_text(json.dumps(custom_document())) + class ReadReached(Exception): + pass + def gather(*args, bindings, **kwargs): + script = commands.read_script(commands.MarkerConfig(), bindings=bindings) + assert 'tc -j qdisc show dev fabric0 ' in script + assert 'tc -j qdisc show dev enp1s0f0np0 ' not in script + raise ReadReached() + monkeypatch.setattr(ops, 'gather', gather) + with pytest.raises(ReadReached): + cli.main([operation, '--topology', str(path), '--facts', str(document), '--host', 'node-0']) + + +def test_boot_preserves_preexisting_qdisc_ownership(): + topo = topology.parse(RING4) + built = plan.build_plan(topo.group, facts.bind(_document(), topo)) + host = next(host for host in built.hosts if host.filter_netdevs) + marker = commands.MarkerConfig() + observed = state.HostState(host.position, host.name, '', True, hostname=host.name) + for device in host.filter_netdevs: + observed.ingress_qdisc[device] = 'ingress' + restored = diff.compare_boot(observed, host, built, layout_name=topo.group.name, marker=marker, adopt=False) + record_line = next(line for line in restored.commands if 'tee ' + commands.RECORD_PATH in line) + observed.record = json.loads(shlex.split(record_line)[2]) + assert observed.record['qdiscs'] == [] + removed = diff.compare_down(observed, group=topo.group.label, marker=marker, adopt=False) + assert not any('tc qdisc del' in line for line in removed.commands) + + +def test_restore_invocation_retains_configuration_and_execution(): + invocation = boot.RestoreInvocation(marker='/opt/fabric/marker', max_relays=5, host='node-2', + skip_hostname_check=True) + text = boot.unit_text(invocation=invocation) + argv = shlex.split(next(line[len('ExecStart='):] for line in text.splitlines() if line.startswith('ExecStart='))) + parsed = cli._parser().parse_args(argv[1:]) + assert parsed.execute and parsed.boot + assert parsed.marker == invocation.marker and parsed.max_relays == 5 and parsed.host == 'node-2' + assert parsed.skip_hostname_check + + +@pytest.mark.parametrize('identifier', ['bad;name', 'bad/name', 'bad$name', '-option', 'bad name']) +def test_invalid_device_identifiers_are_rejected_before_generation(identifier): + with pytest.raises(model.FabricError, match='device identifier'): + topology.parse('hosts a b\ncabling path\nport0 ' + identifier + ' secondary\n') + + +def test_systemd_argument_escaping(): + assert boot.systemd_arg('a%$"\\b') == '"a%%$$\\"\\\\b"' + with pytest.raises(ValueError, match='control characters'): + boot.systemd_arg('line\nbreak') diff --git a/fabric-tool/tests/test_topology.py b/fabric-tool/tests/test_topology.py index bf37347..be3991a 100644 --- a/fabric-tool/tests/test_topology.py +++ b/fabric-tool/tests/test_topology.py @@ -36,9 +36,8 @@ def test_defaults_and_overrides(): custom = topology.parse(RING4 + "port0 mlx5_0 mlx5_2\nport1 mlx5_1 mlx5_3\nrelay_budget 262144\n") assert custom.functions == ("mlx5_0", "mlx5_2", "mlx5_1", "mlx5_3") assert custom.budget == 262144 - model.set_roles(topology._roles_of_functions(custom.functions)) - assert model.RDMA_DEVICES == ("mlx5_0", "mlx5_2", "mlx5_1", "mlx5_3") - model.set_roles(model.DEFAULT_ROLES) + assert custom.bindings.devices == ("mlx5_0", "mlx5_2", "mlx5_1", "mlx5_3") + assert ring.bindings.devices == model.DEFAULT_BINDINGS.devices def test_plugin_key_and_comments(): @@ -74,9 +73,9 @@ def test_group_order_walks_the_fabric(): assert crossed.group.ring_size == 5 -def test_load_installs_roles(tmp_path): +def test_load_preserves_default_bindings(tmp_path): path = tmp_path / "ring4.topology" path.write_text(RING4, encoding="utf-8") ring = topology.load(path) - assert [role.device for role in model.ROLES] == list(ring.functions) - model.set_roles(model.DEFAULT_ROLES) + assert ring.bindings.devices == ring.functions + assert model.DEFAULT_BINDINGS.roles == model.DEFAULT_ROLES From 8a30a92961fe4a4b1fa49a0b38228d9763b7dc3c Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 01:38:57 -0500 Subject: [PATCH 02/12] Make transport planning and emulator resource lifetimes explicit Share validated topology and admission planning between production and the queue oracle. Centralize scheduling accounting, retain registrations on release failure, bound receive completions, serialize worker membership, and lease reclaimable remote mappings. Preserve ext-net ABI and wire version 6. Validation: production/emulated builds, 26 plugin tests, five planning tests, three core executables, deterministic retirement barriers, 530 remote allocation lifetimes and source-inventory checks pass in an isolated Debian LXC. --- SOURCE.json | 39 +- net-sircl/Makefile | 8 +- net-sircl/ROUTE-ALLOWANCE.md | 2 +- net-sircl/net_sircl.c | 842 +----------------- net-sircl/net_sircl_admission.h | 208 +++++ net-sircl/net_sircl_config.h | 203 +++++ net-sircl/net_sircl_connection.h | 415 +++++++++ .../{net_sircl_routes.h => net_sircl_plan.c} | 39 +- net-sircl/net_sircl_plan.h | 24 + net-sircl/tests/request_contract_test.c | 41 + net-sircl/tests/route_model.c | 7 +- net-sircl/tests/test_net_sircl.py | 18 +- tests/test_release.py | 8 +- transport-core/Makefile | 11 +- transport-core/include/sircl_core/shm_verbs.c | 1 + transport-core/include/sircl_core/shm_verbs.h | 10 +- transport-core/src/shm_memory.c | 183 ++++ transport-core/src/shm_memory.h | 22 + transport-core/src/shm_verbs.c | 231 +---- transport-core/src/topology.c | 17 + transport-core/src/verbs_dl.c | 10 +- transport-core/tests/test_emulator_lifetime.c | 206 +++++ transport-core/tests/test_planning.py | 11 + 23 files changed, 1495 insertions(+), 1061 deletions(-) create mode 100644 net-sircl/net_sircl_admission.h create mode 100644 net-sircl/net_sircl_config.h create mode 100644 net-sircl/net_sircl_connection.h rename net-sircl/{net_sircl_routes.h => net_sircl_plan.c} (75%) create mode 100644 net-sircl/net_sircl_plan.h create mode 100644 net-sircl/tests/request_contract_test.c create mode 100644 transport-core/src/shm_memory.c create mode 100644 transport-core/src/shm_memory.h create mode 100644 transport-core/tests/test_emulator_lifetime.c diff --git a/SOURCE.json b/SOURCE.json index a73902e..c51069c 100644 --- a/SOURCE.json +++ b/SOURCE.json @@ -53,7 +53,7 @@ ] }, "archive_tool": "transport-core/tools/package.py", - "$comment": "source_sha256 checks shipped C/C++/header bytes. upstream_source_sha256 checks candidate bytes before standalone core version edits. Neither field claims the release binary has run on hardware.", + "$comment": "source_sha256 inventories every distributed C/C++ source and header, including tests and the privileged marker. Upstream provenance and historical measurement hashes identify separate source artifacts. Component versions and matching hashes do not qualify modified binaries on hardware.", "derived_from": { "project": "SparkRing", "commit": "37daef99c5304a6f65edc89b438b75453faa0149" @@ -113,11 +113,12 @@ "Standalone build, CI, archive tooling, documentation and synthetic examples retained from public v0.1.0.", "External SIRCL/libsircl comparison tests and proxy-adaptation tools remain excluded.", "0.1.2 adds the tuner v4 policy, finite request deadlines and sticky transport errors; wire remains 6.", - "Bundled transport-core stays at 0.1.1 ABI 1 with unchanged source identity.", + "Transport-core exposes version 0.1.1 ABI 1; its startup source identity is derived from the distributed implementation bytes.", "Fabric-tool 0.1.2 requires hardware-offloaded relay rules and returns failure for verify blockers.", "Corrected PyTorch graph lifetime check, channel and runtime matrices, fault-injection tests and public documentation." ], "source_sha256": { + "fabric-tool/mesh_marker.c": "5f330fba6e4c6c2e49d158b84fd76ef0c2ed710354753742503c09262b9c6d4a", "net-sircl/nccl/common.h": "60d138a9f2eb836161b2d0040901d38de5d28f7257b32f8b2d8b7f4e3935b0d1", "net-sircl/nccl/err.h": "aefbbb8f53d56b67c87bf84b8ea5a80ea0e8950d950eb6d66bb128975c90fb6b", "net-sircl/nccl/gin_v11.h": "77b7aae7fc0bdfb6eb1f87d339c11bd82a484b188ef249ebf32b87e5a2fa38cb", @@ -134,19 +135,28 @@ "net-sircl/nccl/net_v7.h": "b89008cd833b58d35a970a8defc2f7656c8160d2eb23f22c85be8c347e0491d1", "net-sircl/nccl/net_v8.h": "6918b9511868e55fb624f1cc9227435cdafbcd3dc5f33d6d33b84e4a46d5ca63", "net-sircl/nccl/net_v9.h": "cda52ae7269035da04bf1b16128639291d4f961ec5e3eea5988aacea4586bca4", + "net-sircl/nccl/tuner.h": "8450583204696fe008b01ab92cfc86d5e8e5bfe1b722b02360be58d599f00148", + "net-sircl/nccl/tuner_v4.h": "1164e13f7096c21c3c02fda1ddcb13d52a9d74e89a42cbf287ac74710861c9cd", "net-sircl/nccl/types.h": "204015ef7865117da6d643307d81df8f16736ccde3762e5110de516b34983890", - "net-sircl/net_sircl.c": "523eae3b82fe3d3786efffeb4dc4cc53fda406e20a7e00d4d5e470987a090086", + "net-sircl/net_sircl.c": "8c1fb7ea5d6930946a9689a6810a1b282e3d5fe25a4da56776e846a3be37fca6", "net-sircl/net_sircl.h": "edf9ea26f9c3efd22a514233004b9a0771da16dc55a627ae5ed5e834cd3fe746", + "net-sircl/net_sircl_admission.h": "ecb9ea2dcbd7eb43d4162ee0992899787c35767477d9c98c2139822645464173", "net-sircl/net_sircl_compat.h": "0053800750c2f061a1254d1db95e65e4317de000c1b52873c0fe2cec9afafdf9", + "net-sircl/net_sircl_config.h": "9aad3e63d9030dc03d70e132fc9fddaf5609966fa5a154c59e341ef21325c28f", + "net-sircl/net_sircl_connection.h": "4e323cb1900aea927febf0f20f68dbb2e2eef05f0d99107febc6cf78ad5ebd96", + "net-sircl/net_sircl_plan.c": "6fc1f03374562864b5b5898a54f4b2cf471e6d11003af83839e0f5a1f777e856", + "net-sircl/net_sircl_plan.h": "dcb857dce8247ff61756e216e90cfd40c6ce3a2b24f5e990b39ec561d2169526", "net-sircl/net_sircl_profile.h": "58b2d994f86fbc88fba4b4d90f332142c52610fcb069dbb2990356734ac076fe", - "net-sircl/net_sircl_routes.h": "4b27a16eac05320ca01532dec2abdedfe46052233454c178beee44f1742fa851", + "net-sircl/net_sircl_tuner.h": "30190717119d61bf1f25b184b1b1ad8f661ac8915c888e55ae013bff2a344bf1", "net-sircl/tests/abi_test.c": "6bc4f44a4cec8f95253ccdf3e3980ced419f01b6be5e41f7e7d1718714e4d91a", "net-sircl/tests/ack_test.c": "ba53451731662b8398c7e4dfd6ccab2008004e0343b1fd25f5fa8884599c6430", "net-sircl/tests/emulation/nccl_compat_e2e.cc": "87217f46e6b83c65e9630b1df1b8f54ac4595e27cb3086e95c12ddc1765568d5", + "net-sircl/tests/failure_test.c": "6c7c79f4e689b037ea74c6a2cb685794d624fffb515d2e3c5ec764958b155c42", "net-sircl/tests/layer_test.c": "7c677708799add8eba5d06187c1987054015e5b05252e47b010c592b25583f35", "net-sircl/tests/progress_cost_test.c": "b3d26360da2c4df8a5d63ad4e62672462c6ebff15b06d1c79e7887cc128f5fa0", "net-sircl/tests/relay_test.c": "651da26961b317e7189c27204f99c06cd7319b4d051cbe4677d69d95dfc7c13a", - "net-sircl/tests/route_model.c": "3b447323c2148bc4f678d1b7a5c692a95d4172ac25840d8476a96131224abafa", + "net-sircl/tests/request_contract_test.c": "3881b1f0ca107b600fb29a2b43478b687571a20b0495255cc3c635233d69c500", + "net-sircl/tests/route_model.c": "b365917435b11477b0e722e6df1bdcc2ddba427a847b02073b91eaa3f3bd76d2", "net-sircl/tests/settings_test.c": "81ab5d5b8b62223ff533f8d1d4680b734962649176c97fb731b46733761115cf", "net-sircl/tests/standin/fake_verbs/infiniband/verbs.h": "8c2173547a2169bb455d103b7842463168e75d4350f4434d92ab5dabc353c64c", "net-sircl/tests/standin/proxy_names.h": "962f0623b88648d1f8bc683168d0befd25dfe5dd7fe4c48a6f69b1e168b1964a", @@ -156,24 +166,23 @@ "transport-core/include/sircl_core/core.h": "2758f18ea6a627b90d759669553b8be72e79ca51273ffbf984587f71151d32e9", "transport-core/include/sircl_core/emulation_verbs.h": "4492551757c091045ac75150585a645f4f5682402e8cd4564d5116d31d0de3da", "transport-core/include/sircl_core/legacy_proxy_names.h": "94e302cb90785a3394ab3c1ca7cd454fbead8767e0fa7ad3d6e072afcf9db7f3", - "transport-core/include/sircl_core/shm_verbs.c": "c2b98078140b047c1ea368f0a660f23f04f50c7dcfee9beedb56a2605459e5fd", - "transport-core/include/sircl_core/shm_verbs.h": "26871d58fdb0204eb66c9bc86cbb55f6de0ce2382f6612354fe2297b4411d980", + "transport-core/include/sircl_core/shm_verbs.c": "27ac4ea05c5e15185fcf51106895655a9b34a08913232a664448f7fe2db70d15", + "transport-core/include/sircl_core/shm_verbs.h": "9ecdd4dc59aa1b17b7d1a9790901f73541ab9112831971de762d3189ee7fe085", "transport-core/include/sircl_core/verbs.h": "8ccc714b80220e54c868e59c7fc4034cac2afe3b8c23cc872ae52d2141e3b0f1", "transport-core/include/sircl_core/verbs_dl.c": "917eb77893adad8a62c053146ca8954d567b8e037a987a20a8e8393ac1f5f4eb", "transport-core/include/sircl_fabric.h": "5960d6fe55fba8c8f32a00bf747aecfd3a4b018db8248ce5134f75bd95843ebb", "transport-core/src/core.c": "3d32d0d6d58a2874573a3ba1ea1efddb5a96cbfc45b2bfd89e451fbd952549ef", "transport-core/src/fabric.c": "edc6a98d8a8e1524ea502fade00b07467b57f299911ea8642b74a479497465b9", - "transport-core/src/shm_verbs.c": "34c3a7a0e2724b71e735412dbcadda26de866b6d1554566e3212696cad5f1516", + "transport-core/src/shm_memory.c": "cacba720864ea531af0df6a25fe018c3a7bad682d632a6b6ae9ed4f43612ccf8", + "transport-core/src/shm_memory.h": "a7d4857229d5b0f8522f8d545de5c89bbc8c75bfebb0022db9e9ba9fb4a04189", + "transport-core/src/shm_verbs.c": "88d7237b5059e751f2ef38c02a805b29505de5dd3afcfdbca496866f5cbdcb80", "transport-core/src/sysfs.c": "747062778a2cab1744d43e602c724b1887ad6ba66428d62ee892b351f7f5b7c2", - "transport-core/src/topology.c": "9c6df8d56bef43094385f169e8be7bf072cd734db06249401efebf063a6ae2a3", - "transport-core/src/verbs_dl.c": "164017e58b2eb74e2137b897553e6509a11a4ad7b9c3e1dfc7d83b2585d60387", + "transport-core/src/topology.c": "a3f7c625832f95816d8cac09d625aada86b4fe29f30923acbc9c126af73a9d0a", + "transport-core/src/verbs_dl.c": "ea38fd0ef71bc215f8d97c4f836179aa9190dc87a34125a4a24a96e23bbc4d84", "transport-core/tests/fake_verbs/infiniband/verbs.h": "8c2173547a2169bb455d103b7842463168e75d4350f4434d92ab5dabc353c64c", "transport-core/tests/test_core.c": "af1228e52b14a1da826573e8eb604ca27ffaf603d3aa7f464b00a4b729f0c2c0", - "transport-core/tests/test_verbs.c": "ec84a8971e48c2fd098dc06d630733af2a5f21c6cd6e9eaa89dca67a9871c220", - "net-sircl/net_sircl_tuner.h": "30190717119d61bf1f25b184b1b1ad8f661ac8915c888e55ae013bff2a344bf1", - "net-sircl/nccl/tuner.h": "8450583204696fe008b01ab92cfc86d5e8e5bfe1b722b02360be58d599f00148", - "net-sircl/nccl/tuner_v4.h": "1164e13f7096c21c3c02fda1ddcb13d52a9d74e89a42cbf287ac74710861c9cd", - "net-sircl/tests/failure_test.c": "6c7c79f4e689b037ea74c6a2cb685794d624fffb515d2e3c5ec764958b155c42" + "transport-core/tests/test_emulator_lifetime.c": "93d92a046853f8bc60077053768e5cac005bab51961f2d1305050330cd4a02e4", + "transport-core/tests/test_verbs.c": "ec84a8971e48c2fd098dc06d630733af2a5f21c6cd6e9eaa89dca67a9871c220" }, "upstream_source_sha256": { "net-sircl/nccl/common.h": "60d138a9f2eb836161b2d0040901d38de5d28f7257b32f8b2d8b7f4e3935b0d1", diff --git a/net-sircl/Makefile b/net-sircl/Makefile index 45add1e..3532158 100644 --- a/net-sircl/Makefile +++ b/net-sircl/Makefile @@ -16,7 +16,7 @@ PREFIX ?= /usr/local CFLAGS ?= -std=gnu11 -O2 -g -Wall -Wextra -Werror -pthread STANDIN := tests/standin CORE ?= $(firstword $(wildcard ../../transport-core ../transport-core)) -CORE_SOURCES := $(CORE)/src/core.c $(CORE)/src/topology.c $(CORE)/src/sysfs.c +CORE_SOURCES := $(CORE)/src/core.c $(CORE)/src/topology.c $(CORE)/src/sysfs.c net_sircl_plan.c CORE_HEADERS := $(wildcard $(CORE)/include/sircl_core/*.h) CPPFLAGS += -I$(CORE)/include -include .core-build/core_identity.h @@ -27,7 +27,7 @@ libnccl-net-sircl.so: net_sircl.c net_sircl.h net_sircl_profile.h $(wildcard ncc emu: libnccl-net-sircl-emu.so -libnccl-net-sircl-emu.so: net_sircl.c net_sircl.h net_sircl_profile.h $(wildcard nccl/*.h) $(STANDIN)/shm_verbs.c VERSION $(CORE_SOURCES) $(CORE_HEADERS) $(CORE)/src/shm_verbs.c +libnccl-net-sircl-emu.so: net_sircl.c net_sircl.h net_sircl_profile.h $(wildcard nccl/*.h) $(STANDIN)/shm_verbs.c VERSION $(CORE_SOURCES) $(CORE_HEADERS) $(CORE)/src/shm_verbs.c $(CORE)/src/shm_memory.c $(CORE)/src/shm_memory.h $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -shared -DNET_SIRCL_RELEASE='"$(VERSION)"' -DNET_SIRCL_STANDIN -I. \ -I$(STANDIN)/fake_verbs -I$(STANDIN) net_sircl.c $(STANDIN)/shm_verbs.c $(CORE_SOURCES) -o $@ @@ -52,8 +52,8 @@ clean: .PHONY: all emu check install clean # The source digest covers transport-core sources, headers and tools, not the compiled library. -.core-build/core_identity.h: $(wildcard $(CORE)/src/*.c) $(wildcard $(CORE)/include/*.h) $(wildcard $(CORE)/include/sircl_core/*) $(wildcard $(CORE)/tools/*.py) $(CORE)/VERSION +.core-build/core_identity.h: $(wildcard $(CORE)/src/*.c $(CORE)/src/*.h) $(wildcard $(CORE)/include/*.h) $(wildcard $(CORE)/include/sircl_core/*) $(wildcard $(CORE)/tools/*.py) $(CORE)/VERSION $(PYTHON) $(CORE)/tools/identity.py --output $@ -libnccl-net-sircl.so libnccl-net-sircl-emu.so: .core-build/core_identity.h net_sircl_compat.h net_sircl_routes.h net_sircl_tuner.h +libnccl-net-sircl.so libnccl-net-sircl-emu.so: .core-build/core_identity.h net_sircl_compat.h net_sircl_plan.h net_sircl_tuner.h net_sircl_admission.h net_sircl_connection.h net_sircl_config.h CPPFLAGS += -DSIRCL_CORE_STATIC diff --git a/net-sircl/ROUTE-ALLOWANCE.md b/net-sircl/ROUTE-ALLOWANCE.md index 6644f59..f0d5709 100644 --- a/net-sircl/ROUTE-ALLOWANCE.md +++ b/net-sircl/ROUTE-ALLOWANCE.md @@ -10,7 +10,7 @@ Let B be the effective base budget, at most 327680. Let U(q) contain each source/function whose routes traverse queue q. The weight w(a) is the sum of relay hops over source/function a's routes. The base allowance is `W0(a) = min_q floor64(B*w(a)/sum(w(b), b in U(q)))`. Therefore the sum of -W0 over each queue's sources is at most B. `net_sircl_routes.h` reconstructs +W0 over each queue's sources is at most B. `net_sircl_plan.c` reconstructs forward and reverse lanes independently and requires reciprocal paths. For reconstructable routes on 2-8 hosts, if every W0 is at least 1280, assign: diff --git a/net-sircl/net_sircl.c b/net-sircl/net_sircl.c index feda727..812e309 100644 --- a/net-sircl/net_sircl.c +++ b/net-sircl/net_sircl.c @@ -52,7 +52,6 @@ __attribute__((visibility("default"))) const char net_sircl_core_source[] = SIRC #define MAX_NET_BYTES (1u << 30) /* NCCL's MAX_NET_SIZE: transfers fit 32-bit lengths */ #define SEND_DEPTH 1024 #define CQ_DEPTH 2048 -#define MAX_POSITIONS 64 #define MAX_WINDOWS 128 #define RELAY_QUEUE_BYTES 524288u /* Reserve 1/8 of each queue. Reverse ACKs cost at most 2/5 of the @@ -60,7 +59,7 @@ __attribute__((visibility("default"))) const char net_sircl_core_source[] = SIRC * The split policy instead bounds forward charge by 6B/5 and ACK debt by B/5. * Either policy obeys 7B/5 <= 7/8 * capacity. */ #define RELAY_BUDGET_DEFAULT (RELAY_QUEUE_BYTES * 5u / 8u) -#include "net_sircl_routes.h" +#include "net_sircl_plan.h" #define PEER_CHECK_EVERY 4096u /* test()/isend() calls between peer-loss checks of a waiting comm */ /* wr_id: kind in 56-63, ACK units (128 bytes) in 40-55, charge in 8-39, @@ -241,254 +240,7 @@ static void shared_free(void *p) { #endif } -/* -- settings -- */ -static long env_long(const char *name, long fallback) { - const char *v = getenv(name); - if (!v || !*v) return fallback; - char *end; - long x = strtol(v, &end, 10); - return *end ? fallback : x; -} - -/* Reject malformed or overflowing QP fields before opening devices; never truncate to uint8_t. */ -static ncclResult_t env_range(const char *name, int fallback, int min, int max, int *out) { - const char *v = getenv(name); - *out = fallback; - if (!v) return ncclSuccess; - for (const char *p = v; *p; ++p) - if (*p < '0' || *p > '9') goto invalid; - errno = 0; - char *end; - long x = strtol(v, &end, 10); - if (!*v || errno == ERANGE || *end || x < min || x > max) goto invalid; - *out = (int)x; - return ncclSuccess; -invalid: - WARN("net-sircl: %s must be a decimal integer in %d..%d (got '%s')", name, min, max, v); - return ncclInvalidArgument; -} - -static uint32_t oob_address(void) { - const char *a = getenv("NET_SIRCL_OOB_ADDR"); - struct in_addr in; - if (a && *a && inet_pton(AF_INET, a, &in) == 1) return in.s_addr; - const char *ifname = getenv("NCCL_SOCKET_IFNAME"); - if (ifname && *ifname && *ifname != '^' && *ifname != '=') { - struct ifaddrs *list, *i; - if (getifaddrs(&list) == 0) { - uint32_t found = 0; - for (i = list; i && !found; i = i->ifa_next) - if (i->ifa_addr && i->ifa_addr->sa_family == AF_INET && !strncmp(i->ifa_name, ifname, strlen(ifname))) - found = ((struct sockaddr_in *)i->ifa_addr)->sin_addr.s_addr; - freeifaddrs(list); - if (found) return found; - } - } - return htonl(INADDR_LOOPBACK); -} - -static int in_list(const char *list, const char *name) { - char copy[1024]; - snprintf(copy, sizeof copy, "%s", list); - for (char *save = NULL, *e = strtok_r(copy, ", ", &save); e; e = strtok_r(NULL, ", ", &save)) - if (!strcmp(e, name)) return 1; - return 0; -} - -static int dev_by_name(const char *name) { - for (int d = 0; d < g.ndevs; ++d) - if (!strcmp(g.devs[d].name, name)) return d; - return -1; -} - -/* -- routes: NET_SIRCL_ROUTES, NET_SIRCL_WINDOWS, NET_SIRCL_TOPOLOGY -- */ - -/* Overrides may reduce a direct window or the function allowances, never invent a route. - * Topology is the admission contract: unknown peers and changed routes fail closed. */ -static ncclResult_t route_overrides(void) { - const char *names[] = {"NET_SIRCL_ROUTES", "NET_SIRCL_WINDOWS"}; - for (int kind = 0; kind < 2; ++kind) { - const char *text = getenv(names[kind]); - if (!text) continue; - if (!*text || strlen(text) >= 2048 || text[0] == ',' || text[strlen(text)-1] == ',' || strstr(text, ",,")) - goto invalid; - char copy[2048]; - strcpy(copy, text); - uint64_t seen = 0; - for (char *save = NULL, *e = strtok_r(copy, ",", &save); e; e = strtok_r(NULL, ",", &save)) { - char *eq = strchr(e, '='); - if (!eq || eq == e) goto invalid; - *eq = 0; - for (char *q = e; *q; ++q) if (*q < '0' || *q > '9') goto invalid; - errno = 0; - char *end; - long peer = strtol(e, &end, 10); - if (errno || *end || peer < 0 || peer >= g.nhosts || peer == g.position || - !g.routes[peer].ndev || (seen & (UINT64_C(1) << peer))) goto invalid; - seen |= UINT64_C(1) << peer; - struct route *r = &g.routes[peer]; - if (!kind) { - char expected[160]; - snprintf(expected, sizeof expected, "%s/%s", g.devs[r->dev[0]].name, g.devs[r->dev[1]].name); - if (strcmp(expected, eq + 1)) goto invalid; - } else { - if (!eq[1]) goto invalid; - for (char *q = eq + 1; *q; ++q) if (*q < '0' || *q > '9') goto invalid; - errno = 0; - unsigned long cap = strtoul(eq + 1, &end, 10); - if (errno || *end || cap > MAX_NET_BYTES || (cap && cap < 1024)) goto invalid; - if (r->relays) { - if (!cap) goto invalid; - for (int d = 0; d < g.ndevs; ++d) - if (cap < g.relay_windows[d].cap) g.relay_windows[d].cap = (uint32_t)cap; - } else r->window = (uint32_t)cap; - } - } - continue; -invalid: - WARN("net-sircl: invalid %s; routes must match topology; relay windows cannot disable the function cap", names[kind]); - return ncclInvalidArgument; - } - return ncclSuccess; -} - -static int my_position_in(const struct sircl_core_topology *t) { - long p = g.position; - if (p >= 0) return (int)p; - char name[256] = {0}; - if (gethostname(name, sizeof name - 1)) return -1; - char *dot = strchr(name, '.'); - for (int i = 0; i < t->nhosts; ++i) { - if (!strcmp(t->host[i], name)) return i; - if (dot && (size_t)(dot - name) == strlen(t->host[i]) && !strncmp(t->host[i], name, (size_t)(dot - name))) - return i; - } - return -1; -} - -/* Routes and windows of every reachable peer from a topology file. */ -static int routes_from_topology(const char *path) { - struct sircl_core_topology t; - char err[512]; - if (sircl_core_topology_parse(path, &t, err, sizeof err)) { - WARN("net-sircl: NET_SIRCL_TOPOLOGY: %s", err); - return -1; - } - int me = my_position_in(&t); - if (me < 0 || me >= t.nhosts) { - WARN("net-sircl: NET_SIRCL_TOPOLOGY %s does not list this host; set NET_SIRCL_POSITION", path); - return -1; - } - if (t.budget < 65536 || t.budget > 393216) { - WARN("net-sircl: topology relay_budget must be in 65536..393216 bytes"); - return -1; - } - /* A port has one cable; this excludes ambiguous forwarding graphs. */ - unsigned occupied[MAX_POSITIONS] = {0}; - for (int i = 0; i < t.ncables; ++i) { - int a = t.cable[i].a, b = t.cable[i].b, pa = t.cable[i].pa, pb = t.cable[i].pb; - if ((occupied[a] & (1u << pa)) || (occupied[b] & (1u << pb))) { - WARN("net-sircl: topology connects a port more than once"); - return -1; - } - occupied[a] |= 1u << pa; - occupied[b] |= 1u << pb; - } - for (int a = 0; a < t.nhosts; ++a) - for (int b = a + 1; b < t.nhosts; ++b) - if (!strcmp(t.host[a], t.host[b])) return -1; - g.position = me; - g.nhosts = t.nhosts; - if (t.budget < (uint32_t)g.relay_budget) g.relay_budget = (int)t.budget; - /* Hash initialized parser output, with an effective budget; equal policy is required at connect. - * This is a compatibility fingerprint, not an authentication primitive. */ - t.budget = (uint32_t)g.relay_budget; - g.policy = UINT64_C(14695981039346656037); - for (size_t i = 0; i < sizeof t; ++i) - g.policy = (g.policy ^ ((const unsigned char *)&t)[i]) * UINT64_C(1099511628211); - uint32_t caps[MAX_POSITIONS][ROUTE_FUNCTIONS]; - g.route_derived = route_allowances(&t, (uint32_t)g.relay_budget, caps); - uint32_t ack_caps[MAX_POSITIONS][ROUTE_FUNCTIONS]; - split_allowances(&t, g.route_derived, caps, ack_caps); - /* Include the admission algorithm in the fingerprint as well as the wire - * version: equal topology alone does not make unequal policies compatible. */ - g.policy = (g.policy ^ NET_SIRCL_VERSION) * UINT64_C(1099511628211); - unsigned sources = t.nhosts > 2 ? (unsigned)t.nhosts - 2 : 1; - for (int d = 0; d < g.ndevs; ++d) { - int f = route_function(&t, g.devs[d].name); - g.relay_windows[d].cap = f >= 0 ? caps[me][f] : (uint32_t)g.relay_budget / sources / 64u * 64u; - g.relay_windows[d].ack_cap = f >= 0 ? ack_caps[me][f] : 0; - g.relay_windows[d].relay = 1; - } - for (int peer = 0; peer < t.nhosts; ++peer) { - if (peer == me) continue; - const char *fn[2]; - int relays = 0; - if (sircl_core_topology_route(&t, me, peer, fn, &relays) < 0) continue; - struct route *r = &g.routes[peer]; - r->ndev = 0; - for (int l = 0; l < NET_SIRCL_MAX_LANES; ++l) { - int d = dev_by_name(fn[l]); - if (d < 0) { - WARN("net-sircl: topology lane %s is not exposed; retain both route lanes in NET_SIRCL_HCA", fn[l]); - return -1; - } - r->dev[r->ndev++] = d; - } - r->relays = relays; - uint32_t a = g.relay_windows[r->dev[0]].cap, b = g.relay_windows[r->dev[1]].cap; - r->window = relays > 0 ? (a < b ? a : b) : 0; - } - return 0; -} - -/* Test hook: the routes a topology file gives `position`, as "=/::;...". */ -int net_sircl_topology_routes(const char *path, int position, char *out, size_t len) { - struct sircl_core_topology t; - char err[512]; - out[0] = '\0'; - if (sircl_core_topology_parse(path, &t, err, sizeof err)) { - snprintf(out, len, "error: %s", err); - return -1; - } - if (t.budget < 65536 || t.budget > 393216) { - snprintf(out, len, "error: relay_budget must be in 65536..393216 bytes"); - return -1; - } - uint32_t budget = t.budget < RELAY_BUDGET_DEFAULT ? t.budget : RELAY_BUDGET_DEFAULT; - uint32_t caps[MAX_POSITIONS][ROUTE_FUNCTIONS]; - int derived = route_allowances(&t, budget, caps); - uint32_t ack_caps[MAX_POSITIONS][ROUTE_FUNCTIONS]; - split_allowances(&t, derived, caps, ack_caps); - size_t used = 0; - for (int peer = 0; peer < t.nhosts; ++peer) { - const char *fn[2]; - int relays = 0; - if (peer == position || sircl_core_topology_route(&t, position, peer, fn, &relays) < 0) continue; - uint32_t a = caps[position][route_function(&t, fn[0])], b = caps[position][route_function(&t, fn[1])]; - int n = snprintf(out + used, len - used, "%d=%s/%s:%d:%u;", peer, fn[0], fn[1], relays, - relays > 0 ? (a < b ? a : b) : 0u); - if (n < 0 || (size_t)n >= len - used) return -1; - used += (size_t)n; - } - return 0; -} - -static struct window *window_for(int d, int position, uint32_t cap) { - if (!cap) return NULL; - pthread_mutex_lock(&g.lock); - struct window *w = NULL; - for (int i = 0; i < g.nwindows && !w; ++i) - if (g.windows[i].dev == d && g.windows[i].position == position) w = &g.windows[i]; - if (!w && g.nwindows < MAX_WINDOWS) { - w = &g.windows[g.nwindows++]; - memset(w, 0, sizeof *w); - w->dev = d, w->position = position, w->cap = cap; - pthread_mutex_init(&w->lock, NULL); - } - pthread_mutex_unlock(&g.lock); - return w; -} +#include "net_sircl_config.h" /* Abstract socket ownership has no stale file after a crash. Production containers must use * the host network namespace, as RDMA deployments do; separate namespaces cannot share this guard. */ @@ -749,422 +501,9 @@ static ncclResult_t sircl_get_properties(int d, ncclNetProperties_v12_t *p) { } /* -- sockets: small, ordered control messages -- */ -static int set_nonblocking(int fd) { - int flags = fcntl(fd, F_GETFL, 0); - return flags < 0 ? -1 : fcntl(fd, F_SETFL, flags | O_NONBLOCK); -} - -static int send_all(int fd, const void *buf, size_t len) { - const char *p = buf; - int64_t deadline = now_ms() + 10000; - while (len) { - ssize_t n = send(fd, p, len, MSG_NOSIGNAL); - if (n < 0 && (errno == EAGAIN || errno == EINTR)) { - if (now_ms() > deadline) return -1; - struct pollfd pf = {fd, POLLOUT, 0}; - poll(&pf, 1, 100); - continue; - } - if (n <= 0) return -1; - p += n; - len -= (size_t)n; - } - return 0; -} - -/* Progress a receive of `len` bytes; 1 when complete, 0 when more is due, -1 on failure or end of stream. */ -static int recv_some(int fd, void *buf, size_t len, size_t *got) { - while (*got < len) { - ssize_t n = recv(fd, (char *)buf + *got, len - *got, 0); - if (n < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) return 0; - if (n < 0 && errno == EINTR) continue; - if (n <= 0) return -1; - *got += (size_t)n; - } - return 1; -} - -/* The peer's end of the comm's socket closed: its process ended or it closed the comm. */ -static int peer_gone(struct comm *c) { - if (c->fd < 0) return 0; - struct pollfd pf = {c->fd, POLLIN | POLLRDHUP, 0}; - if (poll(&pf, 1, 0) <= 0) return 0; - if (pf.revents & (POLLHUP | POLLERR | POLLRDHUP)) return 1; - char b; - return (pf.revents & POLLIN) && recv(c->fd, &b, 1, MSG_PEEK) == 0; -} - -/* -- queue pairs -- */ -static void window_join(struct window *w, struct comm *c) { - pthread_mutex_lock(&w->lock); - c->next = w->members; - w->members = c; - pthread_mutex_unlock(&w->lock); -} - -static void comm_destroy(struct comm *c) { - if (!c) return; - if (c->win) pthread_mutex_lock(&c->win->lock); - /* Stop the QP before retiring its local accounting. An abandoned relay write may still be - * in the fabric: poison the allowance instead of lending its credit to another comm. */ - if (c->qp) sircl_core_destroy_qp(c->qp); - if (c->win) { - /* Queued requests belong to the comm; never retain them after free. */ - struct req **pending = &c->win->pending_head; - c->win->pending_tail = NULL; - while (*pending) { - if ((*pending)->c == c) *pending = (*pending)->pending_next; - else { - c->win->pending_tail = *pending; - pending = &(*pending)->pending_next; - } - } - struct comm **link = &c->win->members; - while (*link && *link != c) link = &(*link)->next; - if (*link) *link = c->next; - if (c->inflight) { - if (c->win->relay) c->win->error = ncclRemoteError; - else sircl_core_window_release(&c->win->inflight, c->inflight); - } - pthread_mutex_unlock(&c->win->lock); - } - if (profile_enabled) profile_close(c); - if (c->cq) sircl_core_destroy_cq(c->cq); - if (c->ctrl_mr) sircl_core_dereg_mr(c->ctrl_mr); - shared_free(c->ctrl); - if (c->fd >= 0) close(c->fd); - free(c); -} - -static struct comm *comm_create(int d, int is_send) { - struct comm *c = calloc(1, sizeof *c); - if (!c) return NULL; - c->dev = d; - c->is_send = is_send; - c->fd = -1; - c->lane = -1; - struct dev *dv = &g.devs[d]; - c->cq = sircl_core_create_cq(dv->ctx, CQ_DEPTH); - c->qp = c->cq ? sircl_core_create_rc_qp(dv->pd, c->cq, SEND_DEPTH, 16) : NULL; - c->ctrl = shared_alloc(sizeof *c->ctrl); - c->ctrl_mr = c->ctrl ? sircl_core_reg_mr(dv->pd, c->ctrl, sizeof *c->ctrl, - IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE) : NULL; - if (!c->cq || !c->qp || !c->ctrl || !c->ctrl_mr) { - WARN("net-sircl: queue pair setup on %s failed", dv->name); - comm_destroy(c); - return NULL; - } - if (sircl_core_qp_init(c->qp, dv->port, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE)) { - WARN("net-sircl: queue pair to INIT on %s failed", dv->name); - comm_destroy(c); - return NULL; - } - return c; -} - -static void meta_fill(struct comm *c, struct net_sircl_meta *m) { - struct dev *dv = &g.devs[c->dev]; - memset(m, 0, sizeof *m); - m->magic = NET_SIRCL_MAGIC; - m->qpn = c->qp->qp_num; - memcpy(m->gid, dv->gid.raw, 16); - m->mtu = (uint32_t)dv->mtu; - m->ctrl_rkey = c->ctrl_mr->rkey; - m->ctrl_addr = (uint64_t)(uintptr_t)c->ctrl; - m->position = g.position; - m->lane = c->lane; - m->policy = g.policy; -} - -/* Fail fast when this function's interface has no route to the peer's address: a peer beyond a cable needs - * a relay table on the hosts between, and without one RTR would only time out after about a minute. */ -static ncclResult_t route_check(struct comm *c, const struct net_sircl_meta *r) { -#ifdef NET_SIRCL_STANDIN - (void)c; (void)r; - return ncclSuccess; -#else - struct dev *dv = &g.devs[c->dev]; - static const uint8_t mapped[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; - if (!dv->netdev[0] || memcmp(r->gid, mapped, 12) || !env_long("NET_SIRCL_ROUTE_CHECK", 1)) return ncclSuccess; - int fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) return ncclSuccess; - ncclResult_t result = ncclSuccess; - if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, dv->netdev, (socklen_t)strlen(dv->netdev)) == 0) { - struct sockaddr_in sa; - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_port = htons(4791); - memcpy(&sa.sin_addr.s_addr, r->gid + 12, 4); - if (connect(fd, (struct sockaddr *)&sa, sizeof sa) && (errno == ENETUNREACH || errno == EHOSTUNREACH)) { - char ip[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, &sa.sin_addr, ip, sizeof ip); - WARN("net-sircl: no route from %s (%s) to %s, the peer at position %d: a peer beyond a cable needs a relay " - "table on the hosts between (README, Peers beyond a cable)", dv->name, dv->netdev, ip, r->position); - result = ncclSystemError; - } - } - close(fd); - return result; -#endif -} - -static ncclResult_t comm_ready(struct comm *c, const struct net_sircl_meta *r) { - struct dev *dv = &g.devs[c->dev]; - if (r->magic != NET_SIRCL_MAGIC) { - WARN("net-sircl: peer metadata has magic %08x", r->magic); - return ncclRemoteError; - } - if (r->policy != g.policy || r->position < 0 || r->position >= g.nhosts || - !g.routes[r->position].ndev) { - WARN("net-sircl: peer topology/budget disagreement or unknown position %d", r->position); - return ncclRemoteError; - } - ncclResult_t rc = route_check(c, r); - if (rc != ncclSuccess) return rc; - struct sircl_core_qp_peer peer = { - .qpn = r->qpn, .mtu = r->mtu < (uint32_t)dv->mtu ? r->mtu : (uint32_t)dv->mtu, - .port = dv->port, .gid_index = (uint8_t)dv->gid_index, .hop_limit = 64, - .traffic_class = (uint8_t)g.traffic_class - }; - if (peer.mtu < IBV_MTU_256 || peer.mtu > IBV_MTU_4096) return ncclRemoteError; - c->mtu_bytes = 128u << peer.mtu; - memcpy(peer.gid, r->gid, 16); - if (sircl_core_qp_rtr(c->qp, &peer)) { - WARN("net-sircl: queue pair to RTR on %s failed: %s (peer position %d unreachable from this function?)", - dv->name, strerror(errno), r->position); - return ncclSystemError; - } - if (sircl_core_qp_rts(c->qp, (unsigned)g.ib_timeout, (unsigned)g.ib_retry_cnt)) { - WARN("net-sircl: queue pair to RTS on %s failed: %s", dv->name, strerror(errno)); - return ncclSystemError; - } - c->rctrl_addr = r->ctrl_addr; - c->rctrl_rkey = r->ctrl_rkey; - c->peer_position = r->position; - const struct route *route = &g.routes[r->position]; - c->win = route->relays ? &g.relay_windows[c->dev] : - c->is_send ? window_for(c->dev, r->position, route->window) : NULL; - if (c->is_send && route->window && !c->win) return ncclSystemError; - if (c->win) window_join(c->win, c); - return ncclSuccess; -} - -static const struct route *route_of(int position) { - if (position < 0 || position >= MAX_POSITIONS || g.routes[position].ndev == 0) return NULL; - return &g.routes[position]; -} - -/* The connector's lane and function toward `position`: NCCL's device when it is one of the route's lanes - * (NCCL spreads its channels over the devices, which keeps both PCI functions of a cable busy), else the - * route's lanes in turn. Without a route, NCCL's device and no lane. */ -static int connect_dev(int position, int nccl_dev, int *lane) { - struct route *r = (struct route *)route_of(position); - *lane = -1; - if (!r) return nccl_dev; - for (int l = 0; l < r->ndev; ++l) - if (r->dev[l] == nccl_dev) { - *lane = l; - return nccl_dev; - } - pthread_mutex_lock(&g.lock); - *lane = (int)(r->next++ % (unsigned)r->ndev); - pthread_mutex_unlock(&g.lock); - return r->dev[*lane]; -} - -/* The acceptor's function: the connector's lane of this side's route toward the connector, so both ends of - * the queue pair are the same function class on the same path. */ -static int accept_dev(int position, int lane, int listen_dev) { - const struct route *r = route_of(position); - if (!r) return listen_dev; - if (lane >= 0 && lane < r->ndev) return r->dev[lane]; - for (int l = 0; l < r->ndev; ++l) - if (r->dev[l] == listen_dev) return listen_dev; - return r->dev[0]; -} - -/* -- listen / connect / accept -- */ -static ncclResult_t sircl_listen(void *ctx, int d, void *handle, void **listenComm) { - (void)ctx; - if (d < 0 || d >= g.ndevs) return ncclInvalidArgument; - struct net_sircl_handle *h = handle; - memset(handle, 0, NCCL_NET_HANDLE_MAXSIZE); - int fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) return ncclSystemError; - struct sockaddr_in sa; - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = htonl(INADDR_ANY); - socklen_t len = sizeof sa; - if (bind(fd, (struct sockaddr *)&sa, sizeof sa) || listen(fd, 128) || - getsockname(fd, (struct sockaddr *)&sa, &len) || set_nonblocking(fd)) { - close(fd); - return ncclSystemError; - } - h->magic = NET_SIRCL_MAGIC; - h->version = NET_SIRCL_VERSION; - h->port = sa.sin_port; - h->addr = g.oob_addr; - h->position = g.position; - h->pending = 0; - struct listen_comm *l = calloc(1, sizeof *l); - if (!l) { - close(fd); - return ncclSystemError; - } - l->fd = fd; - l->dev = d; - *listenComm = l; - return ncclSuccess; -} - -static void pending_drop(struct pending *p) { - if (!p) return; - if (p->c) comm_destroy(p->c); - if (p->fd >= 0) close(p->fd); - free(p); -} - -static ncclResult_t connect_fail(struct net_sircl_handle *h, struct pending *p, ncclResult_t r) { - h->pending = 0; - pending_drop(p); - return r; -} +#include "net_sircl_admission.h" +#include "net_sircl_connection.h" -static ncclResult_t sircl_connect(void *ctx, int d, void *handle, void **sendComm, - ncclNetDeviceHandle_v12_t **sendDevComm) { - (void)ctx; - (void)sendDevComm; - *sendComm = NULL; - struct net_sircl_handle *h = handle; - if (h->magic != NET_SIRCL_MAGIC || h->version != NET_SIRCL_VERSION) { - WARN("net-sircl: handle magic %08x version %u", h->magic, h->version); - return ncclInvalidArgument; - } - if (!route_of(h->position)) return ncclInvalidArgument; - struct pending *p = (struct pending *)(uintptr_t)h->pending; - if (!p) { - p = calloc(1, sizeof *p); - if (!p) return ncclSystemError; - p->deadline_ms = now_ms() + g.connect_timeout_ms; - int lane = -1; - p->dev = connect_dev(h->position, d, &lane); - p->fd = socket(AF_INET, SOCK_STREAM, 0); - if (p->fd < 0 || set_nonblocking(p->fd)) return connect_fail(h, p, ncclSystemError); - int one = 1; - setsockopt(p->fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof one); - struct sockaddr_in sa; - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_port = h->port; - sa.sin_addr.s_addr = h->addr; - if (connect(p->fd, (struct sockaddr *)&sa, sizeof sa) && errno != EINPROGRESS) { - WARN("net-sircl: connecting to the listener: %s", strerror(errno)); - return connect_fail(h, p, ncclSystemError); - } - p->c = comm_create(p->dev, 1); - if (!p->c) return connect_fail(h, p, ncclSystemError); - p->c->lane = lane; - p->state = P_CONNECTING; - h->pending = (uint64_t)(uintptr_t)p; - } - if (now_ms() > p->deadline_ms) { - WARN("net-sircl: connecting to position %d timed out after %d ms (NET_SIRCL_CONNECT_TIMEOUT_MS)", h->position, - g.connect_timeout_ms); - return connect_fail(h, p, ncclSystemError); - } - if (p->state == P_CONNECTING) { - struct pollfd pf = {p->fd, POLLOUT, 0}; - if (poll(&pf, 1, 0) <= 0) return ncclSuccess; - int err = 0; - socklen_t len = sizeof err; - getsockopt(p->fd, SOL_SOCKET, SO_ERROR, &err, &len); - if (err) { - WARN("net-sircl: connecting to the listener: %s", strerror(err)); - return connect_fail(h, p, ncclSystemError); - } - meta_fill(p->c, &p->mine); - if (send_all(p->fd, &p->mine, sizeof p->mine)) return connect_fail(h, p, ncclSystemError); - p->state = P_WAIT_META; - } - if (p->state == P_WAIT_META) { - int r = recv_some(p->fd, &p->theirs, sizeof p->theirs, &p->got); - if (r < 0) return connect_fail(h, p, ncclRemoteError); - if (r == 0) return ncclSuccess; - ncclResult_t rr = comm_ready(p->c, &p->theirs); - if (rr != ncclSuccess) return connect_fail(h, p, rr); - /* Ready: this queue pair is at RTS, so the acceptor may let its side write (as NCCL's IB transport - * finishes its connect). */ - uint8_t ready = 1; - if (send_all(p->fd, &ready, 1)) return connect_fail(h, p, ncclSystemError); - p->c->fd = p->fd; - p->fd = -1; - *sendComm = p->c; - INFO("net-sircl: send comm on %s (lane %d) to position %d, window %u", g.devs[p->c->dev].name, p->c->lane, - p->c->peer_position, p->c->win ? p->c->win->cap : 0u); - p->c = NULL; - h->pending = 0; - free(p); - } - return ncclSuccess; -} - -static ncclResult_t accept_fail(struct listen_comm *l, ncclResult_t r) { - pending_drop(l->accepting); - l->accepting = NULL; - return r; -} - -static ncclResult_t sircl_accept(void *listenComm, void **recvComm, ncclNetDeviceHandle_v12_t **recvDevComm) { - (void)recvDevComm; - *recvComm = NULL; - struct listen_comm *l = listenComm; - struct pending *p = l->accepting; - if (!p) { - int fd = accept(l->fd, NULL, NULL); - if (fd < 0) return (errno == EAGAIN || errno == EWOULDBLOCK) ? ncclSuccess : ncclSystemError; - p = calloc(1, sizeof *p); - if (!p) { - close(fd); - return ncclSystemError; - } - p->fd = fd; - set_nonblocking(fd); - p->state = P_WAIT_META; - p->deadline_ms = now_ms() + g.connect_timeout_ms; - l->accepting = p; - } - if (now_ms() > p->deadline_ms) { - WARN("net-sircl: accepting a connection timed out after %d ms (NET_SIRCL_CONNECT_TIMEOUT_MS)", - g.connect_timeout_ms); - return accept_fail(l, ncclSystemError); - } - if (p->state == P_WAIT_META) { - int r = recv_some(p->fd, &p->theirs, sizeof p->theirs, &p->got); - if (r < 0) return accept_fail(l, ncclRemoteError); - if (r == 0) return ncclSuccess; - p->c = comm_create(accept_dev(p->theirs.position, p->theirs.lane, l->dev), 0); - if (!p->c) return accept_fail(l, ncclSystemError); - p->c->lane = p->theirs.lane; - meta_fill(p->c, &p->mine); - if (send_all(p->fd, &p->mine, sizeof p->mine)) return accept_fail(l, ncclSystemError); - ncclResult_t rr = comm_ready(p->c, &p->theirs); - if (rr != ncclSuccess) return accept_fail(l, rr); - p->state = P_WAIT_READY; - } - int r = recv_some(p->fd, &p->ready, 1, &p->ready_got); - if (r < 0) return accept_fail(l, ncclRemoteError); - if (r == 0) return ncclSuccess; - p->c->fd = p->fd; - p->fd = -1; - *recvComm = p->c; - p->c = NULL; - l->accepting = NULL; - free(p); - return ncclSuccess; -} - -/* -- memory -- */ static ncclResult_t sircl_reg_mr(void *comm, void *data, size_t size, int type, void **mhandle) { struct comm *c = comm; if (type != NCCL_PTR_HOST) { @@ -1207,7 +546,10 @@ static ncclResult_t sircl_dereg_mr(void *comm, void *mhandle) { (void)comm; struct mr *m = mhandle; if (!m) return ncclSuccess; - if (m->ib) sircl_core_dereg_mr(m->ib); + if (m->ib && sircl_core_dereg_mr(m->ib)) { + WARN("net-sircl: memory deregistration failed; registration ownership retained"); + return ncclSystemError; + } shared_free(m->shadow); free(m); return ncclSuccess; @@ -1230,63 +572,6 @@ static int post_write(struct comm *c, uint64_t laddr, uint32_t lkey, uint32_t le (signaled ? IBV_SEND_SIGNALED : 0) | (inline_data ? IBV_SEND_INLINE : 0), wr_id); } -/* Charge 64-byte buffer strides plus 128 bytes of frame overhead and one 128-byte ACK - * per packet. RC send completion proves both the write and its ACK have left the relay path. - * The reserve counts both directions, even if the hardware gives them independent queues. */ -static uint64_t write_charge(struct comm *c, uint32_t bytes) { - if (!c->win || !c->win->relay) return bytes; - uint64_t packets = bytes ? ((uint64_t)bytes + c->mtu_bytes - 1) / c->mtu_bytes : 1; - return (((uint64_t)bytes + 63u) & ~UINT64_C(63)) + packets * 256u; -} - -static uint64_t ack_charge(struct comm *c, uint32_t bytes) { - if (!c->win || !c->win->ack_cap) return 0; - return 128u * (bytes ? ((uint64_t)bytes + c->mtu_bytes - 1) / c->mtu_bytes : 1); -} - -static int window_take(struct window *w, uint64_t bytes) { - return !w->error && sircl_core_window_claim(&w->inflight, &w->max_inflight, w->cap, bytes, 0); -} - -/* Reserve both resources atomically under the shared window lock. No WR is - * posted while holding only one resource, so there is no resource wait cycle. */ -static int window_take_ack(struct window *w, uint64_t bytes, uint64_t ack) { - if (w->ack_cap && ack > w->ack_cap - w->ack_inflight) return 0; - if (!window_take(w, bytes)) return 0; - w->ack_inflight += ack; - return 1; -} - -/* Caller holds the window lock. Fit the available charge, retaining at least two - * independently completed pieces per full allowance when two 4 KiB pieces fit. - * Avoid tiny residual writes unless they finish a request or the entire allowance - * is smaller: otherwise packet/CQE overhead defeats the larger completion chunks. */ -static uint32_t chunk_bytes(struct comm *c, uint32_t left) { - uint32_t hi = left < g.chunk ? left : g.chunk, lo = 0; - if (c->win->ack_cap) { - uint64_t packet_bytes = (c->win->ack_cap - c->win->ack_inflight) / 128u * c->mtu_bytes; - if (packet_bytes < hi) hi = (uint32_t)packet_bytes; - } - uint64_t cap = c->win->cap; - uint64_t available = cap - c->win->inflight; - uint64_t target = cap >= 2 * write_charge(c, 4096) ? cap / 2 : cap; - if (available < target) target = available; - /* Saturated channels are the common retry case: avoid a binary search when - * even the smallest useful piece must wait for a completion. */ - uint32_t minimum = cap >= write_charge(c, 4096) ? (left < 4096 ? left : 4096) : 1; - if (target < write_charge(c, minimum)) return 0; - if (hi < minimum) return 0; - if (write_charge(c, hi) <= target) return hi; - while (lo < hi) { - uint32_t mid = lo + (hi - lo + 1) / 2; - if (write_charge(c, mid) <= target) lo = mid; - else hi = mid - 1; - } - if (lo < left) lo &= ~63u; - if (lo < 4096 && lo < left && cap >= write_charge(c, 4096)) return 0; - return lo; -} - /* Post what the window allows of a send, then its size and done words. */ static ncclResult_t send_progress(struct comm *c, struct req *q) { while (q->posted < q->total) { @@ -1296,28 +581,22 @@ static ncclResult_t send_progress(struct comm *c, struct req *q) { if (!piece) return ncclSuccess; uint64_t charge = write_charge(c, piece); uint64_t ack = ack_charge(c, piece); - if (c->win && !window_take_ack(c->win, charge, ack)) return c->win->error; + if (!admission_reserve(c, charge, ack)) return c->win->error; if (post_write(c, q->laddr + q->posted, q->lkey, piece, q->raddr + q->posted, q->rkey, 0, c->win != NULL, WR_ACK_ID(WR_DATA, charge, q->slot, ack))) { - if (c->win) { - sircl_core_window_release(&c->win->inflight, charge); - c->win->ack_inflight -= ack; - c->win->error = ncclSystemError; - } + admission_cancel(c, charge, ack); WARN("net-sircl: posting %u payload bytes: %s", piece, strerror(errno)); return ncclSystemError; } q->posted += piece; c->chunks++; - if (c->win) c->inflight += charge; } if (!q->final_posted) { uint64_t charge = c->win && c->win->relay ? 2 * write_charge(c, 4) : 0; uint64_t ack = 2 * ack_charge(c, 4); - int blocked = charge && !window_take_ack(c->win, charge, ack); + int blocked = !admission_reserve(c, charge, ack); if (profile_enabled) profile_wait(c, q, blocked); if (blocked) return c->win->error; - c->inflight += charge; uint32_t size = q->total, seq = q->seq + 1; uint64_t base = c->rctrl_addr; if (post_write(c, (uint64_t)(uintptr_t)&size, 0, 4, base + offsetof(struct net_sircl_ctrl, done_size) + 4 * q->slot, @@ -1410,8 +689,7 @@ static ncclResult_t recv_progress(struct comm *c, struct req *q) { if (q->cts_posted) return ncclSuccess; uint64_t charge = c->win ? write_charge(c, sizeof(struct net_sircl_cts)) + write_charge(c, 4) : 0; uint64_t ack = ack_charge(c, sizeof(struct net_sircl_cts)) + ack_charge(c, 4); - if (charge && !window_take_ack(c->win, charge, ack)) return c->win->error; - c->inflight += charge; + if (!admission_reserve(c, charge, ack)) return c->win->error; struct net_sircl_cts *e = &c->ctrl->cts[q->slot]; uint32_t seq = q->seq + 1; uint64_t base = c->rctrl_addr; @@ -1427,40 +705,6 @@ static ncclResult_t recv_progress(struct comm *c, struct req *q) { return ncclSuccess; } -static void pending_append(struct window *w, struct req *q) { - q->pending_next = NULL; - if (w->pending_tail) w->pending_tail->pending_next = q; - else w->pending_head = q; - w->pending_tail = q; -} - -/* FIFO requests, independent of CQ ownership. A blocked head retains its turn - * until all its writes are posted. Both resources are acquired together by - * the ordinary posting functions. Enqueueing reserves no credit; posted WRs - * keep their charge until RC completion. A visit stops when credit is short. */ -static ncclResult_t advance_pending(struct window *w) { - while (w->pending_head) { - struct req *q = w->pending_head; - ncclResult_t r = q->is_send ? send_progress(q->c, q) : recv_progress(q->c, q); - if (r != ncclSuccess) return r; - int finished = q->is_send ? q->final_posted : q->cts_posted; - if (!finished) return ncclSuccess; - w->pending_head = q->pending_next; - if (!w->pending_head) w->pending_tail = NULL; - q->pending_next = NULL; - if (profile_enabled) profile_wait(q->c, q, 0); - } - return ncclSuccess; -} - -static ncclResult_t submit_progress(struct comm *c, struct req *q) { - if (!c->win || !c->win->relay) - return q->is_send ? send_progress(c, q) : recv_progress(c, q); - pending_append(c->win, q); - if (profile_enabled && q->is_send && c->win->pending_head != q) profile_wait(c, q, 1); - return advance_pending(c->win); -} - static ncclResult_t irecv_locked(void *recvComm, int n, void **data, size_t *sizes, int *tags, void **mhandles, void **phandles, void **request) { (void)phandles; @@ -1485,6 +729,7 @@ static ncclResult_t irecv_locked(void *recvComm, int n, void **data, size_t *siz q->c = c; q->seq = c->seq++; q->slot = slot; + q->total = e->size; q->user = data[0]; q->shadow = (m && m->shadow) ? (uint8_t *)(uintptr_t)e->addr : NULL; ncclResult_t r = submit_progress(c, q); @@ -1531,12 +776,7 @@ static ncclResult_t drain(struct comm *c) { uint64_t id = wc[i].wr_id; int kind = (int)(id >> 56); uint32_t slot = (uint32_t)(id & 0xff); - if (c->win) { - uint64_t bytes = WR_CHARGE(id); - c->win->ack_inflight -= WR_ACK(id); - c->inflight -= bytes; - sircl_core_window_release(&c->win->inflight, bytes); - } + admission_complete(c, id); if (profile_enabled) profile_complete(c, id); if (kind == WR_FINAL && slot < NET_SIRCL_SLOTS) c->reqs[slot].done = 1; if (kind == WR_CTS && slot < NET_SIRCL_SLOTS) c->reqs[slot].cts_done = 1; @@ -1545,48 +785,6 @@ static ncclResult_t drain(struct comm *c) { return n < 0 ? ncclSystemError : ncclSuccess; } -/* Post a windowed comm's waiting payload or CTS writes, oldest request first. */ -static ncclResult_t advance(struct comm *c) { - for (uint32_t s = c->head; s != c->seq; ++s) { - struct req *q = &c->reqs[s % NET_SIRCL_SLOTS]; - if (!q->used) continue; - ncclResult_t r = q->is_send ? send_progress(c, q) : recv_progress(c, q); - if (r != ncclSuccess) return r; - if (q->is_send ? !q->final_posted : !q->cts_posted) break; - } - return ncclSuccess; -} - -/* Caller holds the shared window lock across progress and request retirement. */ -static ncclResult_t poll_cq(struct comm *c) { - if (c->error) return c->error; - if (!c->win) return drain(c); - struct window *w = c->win; - if (w->error) return w->error; - for (struct comm *m = w->members; m; m = m->next) { - /* Every relay CQE carries positive charge, including CTS and final pairs. - * A zero balance proves there is nothing to reap; receive done words are - * still checked by test_locked. Explicit direct windows have zero-charge - * final CQEs and must retain unconditional polling. */ - ncclResult_t r = ncclSuccess; - if (!w->relay || m->inflight) r = drain(m); - if (r != ncclSuccess) return w->error = r; - /* Reuse completed credit before polling unrelated CQs, granting it to - * the oldest waiting request rather than preferentially to the CQ owner. */ - r = w->relay ? advance_pending(w) : advance(m); - if (r != ncclSuccess) return w->error = r; - } - /* Rotate CQ visits; relay admission has its own FIFO order. */ - if (w->members && w->members->next) { - struct comm *first = w->members, *last = first; - while (last->next) last = last->next; - w->members = first->next; - first->next = NULL; - last->next = first; - } - return ncclSuccess; -} - static ncclResult_t test_locked(void *request, int *done, int *sizes) { struct req *q = request; struct comm *c = q->c; @@ -1601,6 +799,12 @@ static ncclResult_t test_locked(void *request, int *done, int *sizes) { if (__atomic_load_n(&c->ctrl->done_seq[q->slot], __ATOMIC_ACQUIRE) != q->seq + 1) return check_wait(c, q->started_ms); uint32_t got = __atomic_load_n(&c->ctrl->done_size[q->slot], __ATOMIC_ACQUIRE); + if (got > q->total) { + WARN("net-sircl: receive completion length %u exceeds capacity %u", got, q->total); + c->error = ncclRemoteError; + if (c->win) c->win->error = ncclRemoteError; + return ncclRemoteError; + } if (q->shadow && got) memcpy(q->user, q->shadow, got); if (sizes) *sizes = (int)got; } @@ -1622,13 +826,11 @@ static ncclResult_t sircl_test(void *request, int *done, int *sizes) { /* Closing never waits for the peer: outstanding requests are abandoned with their queue pair. */ static ncclResult_t sircl_close_send(void *sendComm) { - comm_destroy(sendComm); - return ncclSuccess; + return comm_destroy(sendComm); } static ncclResult_t sircl_close_recv(void *recvComm) { - comm_destroy(recvComm); - return ncclSuccess; + return comm_destroy(recvComm); } static ncclResult_t sircl_close_listen(void *listenComm) { diff --git a/net-sircl/net_sircl_admission.h b/net-sircl/net_sircl_admission.h new file mode 100644 index 0000000..23c28e7 --- /dev/null +++ b/net-sircl/net_sircl_admission.h @@ -0,0 +1,208 @@ +/* Private admission implementation. The including translation unit supplies protocol posting + * and CQ-drain callbacks; accounting, membership and FIFO ownership live here. Callers hold the + * shared window lock across reservation, completion and retirement. */ +static ncclResult_t send_progress(struct comm *, struct req *); +static ncclResult_t recv_progress(struct comm *, struct req *); +static ncclResult_t drain(struct comm *); + +static struct window *window_for(int d, int position, uint32_t cap) { + if (!cap) return NULL; + pthread_mutex_lock(&g.lock); + struct window *w = NULL; + for (int i = 0; i < g.nwindows && !w; ++i) + if (g.windows[i].dev == d && g.windows[i].position == position) w = &g.windows[i]; + if (!w && g.nwindows < MAX_WINDOWS) { + w = &g.windows[g.nwindows++]; + memset(w, 0, sizeof *w); + w->dev = d, w->position = position, w->cap = cap; + pthread_mutex_init(&w->lock, NULL); + } + pthread_mutex_unlock(&g.lock); + return w; +} + +static void window_join(struct window *w, struct comm *c) { + pthread_mutex_lock(&w->lock); + c->next = w->members; + w->members = c; + pthread_mutex_unlock(&w->lock); +} + +static void admission_leave_locked(struct comm *c) { + /* Queued requests belong to the comm; never retain them after free. */ + struct req **pending = &c->win->pending_head; + c->win->pending_tail = NULL; + while (*pending) { + if ((*pending)->c == c) *pending = (*pending)->pending_next; + else { + c->win->pending_tail = *pending; + pending = &(*pending)->pending_next; + } + } + struct comm **link = &c->win->members; + while (*link && *link != c) link = &(*link)->next; + if (*link) *link = c->next; + if (c->inflight) { + if (c->win->relay) c->win->error = ncclRemoteError; + else sircl_core_window_release(&c->win->inflight, c->inflight); + } +} + +/* Charge 64-byte buffer strides plus 128 bytes of frame overhead and one 128-byte ACK + * per packet. RC send completion proves both the write and its ACK have left the relay path. + * The reserve counts both directions, even if the hardware gives them independent queues. */ +static uint64_t write_charge(struct comm *c, uint32_t bytes) { + if (!c->win || !c->win->relay) return bytes; + uint64_t packets = bytes ? ((uint64_t)bytes + c->mtu_bytes - 1) / c->mtu_bytes : 1; + return (((uint64_t)bytes + 63u) & ~UINT64_C(63)) + packets * 256u; +} + +static uint64_t ack_charge(struct comm *c, uint32_t bytes) { + if (!c->win || !c->win->ack_cap) return 0; + return 128u * (bytes ? ((uint64_t)bytes + c->mtu_bytes - 1) / c->mtu_bytes : 1); +} + +static int window_take(struct window *w, uint64_t bytes) { + return !w->error && sircl_core_window_claim(&w->inflight, &w->max_inflight, w->cap, bytes, 0); +} + +/* Reserve both resources atomically under the shared window lock. No WR is + * posted while holding only one resource, so there is no resource wait cycle. */ +static int window_take_ack(struct window *w, uint64_t bytes, uint64_t ack) { + if (w->ack_cap && ack > w->ack_cap - w->ack_inflight) return 0; + if (!window_take(w, bytes)) return 0; + w->ack_inflight += ack; + return 1; +} + +/* Caller holds the window lock. Fit the available charge, retaining at least two + * independently completed pieces per full allowance when two 4 KiB pieces fit. + * Avoid tiny residual writes unless they finish a request or the entire allowance + * is smaller: otherwise packet/CQE overhead defeats the larger completion chunks. */ +static uint32_t chunk_bytes(struct comm *c, uint32_t left) { + uint32_t hi = left < g.chunk ? left : g.chunk, lo = 0; + if (c->win->ack_cap) { + uint64_t packet_bytes = (c->win->ack_cap - c->win->ack_inflight) / 128u * c->mtu_bytes; + if (packet_bytes < hi) hi = (uint32_t)packet_bytes; + } + uint64_t cap = c->win->cap; + uint64_t available = cap - c->win->inflight; + uint64_t target = cap >= 2 * write_charge(c, 4096) ? cap / 2 : cap; + if (available < target) target = available; + /* Saturated channels are the common retry case: avoid a binary search when + * even the smallest useful piece must wait for a completion. */ + uint32_t minimum = cap >= write_charge(c, 4096) ? (left < 4096 ? left : 4096) : 1; + if (target < write_charge(c, minimum)) return 0; + if (hi < minimum) return 0; + if (write_charge(c, hi) <= target) return hi; + while (lo < hi) { + uint32_t mid = lo + (hi - lo + 1) / 2; + if (write_charge(c, mid) <= target) lo = mid; + else hi = mid - 1; + } + if (lo < left) lo &= ~63u; + if (lo < 4096 && lo < left && cap >= write_charge(c, 4096)) return 0; + return lo; +} + +/* Reservation ownership includes the comm share before any provider call. */ +static int admission_reserve(struct comm *c, uint64_t bytes, uint64_t ack) { + if (!c->win) return 1; + if (!window_take_ack(c->win, bytes, ack)) return 0; + c->inflight += bytes; + return 1; +} + +/* Cancel only work the provider did not accept. Partial control pairs retain debt. */ +static void admission_cancel(struct comm *c, uint64_t bytes, uint64_t ack) { + if (!c->win) return; + sircl_core_window_release(&c->win->inflight, bytes); + c->win->ack_inflight -= ack; + c->inflight -= bytes; + c->win->error = ncclSystemError; +} + +static void admission_complete(struct comm *c, uint64_t id) { + if (!c->win) return; + uint64_t bytes = WR_CHARGE(id); + c->win->ack_inflight -= WR_ACK(id); + c->inflight -= bytes; + sircl_core_window_release(&c->win->inflight, bytes); +} + +static void pending_append(struct window *w, struct req *q) { + q->pending_next = NULL; + if (w->pending_tail) w->pending_tail->pending_next = q; + else w->pending_head = q; + w->pending_tail = q; +} + +/* FIFO requests, independent of CQ ownership. A blocked head retains its turn + * until all its writes are posted. Both resources are acquired together by + * the ordinary posting functions. Enqueueing reserves no credit; posted WRs + * keep their charge until RC completion. A visit stops when credit is short. */ +static ncclResult_t advance_pending(struct window *w) { + while (w->pending_head) { + struct req *q = w->pending_head; + ncclResult_t r = q->is_send ? send_progress(q->c, q) : recv_progress(q->c, q); + if (r != ncclSuccess) return r; + int finished = q->is_send ? q->final_posted : q->cts_posted; + if (!finished) return ncclSuccess; + w->pending_head = q->pending_next; + if (!w->pending_head) w->pending_tail = NULL; + q->pending_next = NULL; + if (profile_enabled) profile_wait(q->c, q, 0); + } + return ncclSuccess; +} + +static ncclResult_t submit_progress(struct comm *c, struct req *q) { + if (!c->win || !c->win->relay) + return q->is_send ? send_progress(c, q) : recv_progress(c, q); + pending_append(c->win, q); + if (profile_enabled && q->is_send && c->win->pending_head != q) profile_wait(c, q, 1); + return advance_pending(c->win); +} + +/* Post a windowed comm's waiting payload or CTS writes, oldest request first. */ +static ncclResult_t advance(struct comm *c) { + for (uint32_t s = c->head; s != c->seq; ++s) { + struct req *q = &c->reqs[s % NET_SIRCL_SLOTS]; + if (!q->used) continue; + ncclResult_t r = q->is_send ? send_progress(c, q) : recv_progress(c, q); + if (r != ncclSuccess) return r; + if (q->is_send ? !q->final_posted : !q->cts_posted) break; + } + return ncclSuccess; +} + +/* Caller holds the shared window lock across progress and request retirement. */ +static ncclResult_t poll_cq(struct comm *c) { + if (c->error) return c->error; + if (!c->win) return drain(c); + struct window *w = c->win; + if (w->error) return w->error; + for (struct comm *m = w->members; m; m = m->next) { + /* Every relay CQE carries positive charge, including CTS and final pairs. + * A zero balance proves there is nothing to reap; receive done words are + * still checked by test_locked. Explicit direct windows have zero-charge + * final CQEs and must retain unconditional polling. */ + ncclResult_t r = ncclSuccess; + if (!w->relay || m->inflight) r = drain(m); + if (r != ncclSuccess) return w->error = r; + /* Reuse completed credit before polling unrelated CQs, granting it to + * the oldest waiting request rather than preferentially to the CQ owner. */ + r = w->relay ? advance_pending(w) : advance(m); + if (r != ncclSuccess) return w->error = r; + } + /* Rotate CQ visits; relay admission has its own FIFO order. */ + if (w->members && w->members->next) { + struct comm *first = w->members, *last = first; + while (last->next) last = last->next; + w->members = first->next; + first->next = NULL; + last->next = first; + } + return ncclSuccess; +} + diff --git a/net-sircl/net_sircl_config.h b/net-sircl/net_sircl_config.h new file mode 100644 index 0000000..ed7b245 --- /dev/null +++ b/net-sircl/net_sircl_config.h @@ -0,0 +1,203 @@ +/* Private configuration boundary: validated settings and topology-to-device binding. */ +/* -- settings -- */ +static long env_long(const char *name, long fallback) { + const char *v = getenv(name); + if (!v || !*v) return fallback; + char *end; + long x = strtol(v, &end, 10); + return *end ? fallback : x; +} + +/* Reject malformed or overflowing QP fields before opening devices; never truncate to uint8_t. */ +static ncclResult_t env_range(const char *name, int fallback, int min, int max, int *out) { + const char *v = getenv(name); + *out = fallback; + if (!v) return ncclSuccess; + for (const char *p = v; *p; ++p) + if (*p < '0' || *p > '9') goto invalid; + errno = 0; + char *end; + long x = strtol(v, &end, 10); + if (!*v || errno == ERANGE || *end || x < min || x > max) goto invalid; + *out = (int)x; + return ncclSuccess; +invalid: + WARN("net-sircl: %s must be a decimal integer in %d..%d (got '%s')", name, min, max, v); + return ncclInvalidArgument; +} + +static uint32_t oob_address(void) { + const char *a = getenv("NET_SIRCL_OOB_ADDR"); + struct in_addr in; + if (a && *a && inet_pton(AF_INET, a, &in) == 1) return in.s_addr; + const char *ifname = getenv("NCCL_SOCKET_IFNAME"); + if (ifname && *ifname && *ifname != '^' && *ifname != '=') { + struct ifaddrs *list, *i; + if (getifaddrs(&list) == 0) { + uint32_t found = 0; + for (i = list; i && !found; i = i->ifa_next) + if (i->ifa_addr && i->ifa_addr->sa_family == AF_INET && !strncmp(i->ifa_name, ifname, strlen(ifname))) + found = ((struct sockaddr_in *)i->ifa_addr)->sin_addr.s_addr; + freeifaddrs(list); + if (found) return found; + } + } + return htonl(INADDR_LOOPBACK); +} + +static int in_list(const char *list, const char *name) { + char copy[1024]; + snprintf(copy, sizeof copy, "%s", list); + for (char *save = NULL, *e = strtok_r(copy, ", ", &save); e; e = strtok_r(NULL, ", ", &save)) + if (!strcmp(e, name)) return 1; + return 0; +} + +static int dev_by_name(const char *name) { + for (int d = 0; d < g.ndevs; ++d) + if (!strcmp(g.devs[d].name, name)) return d; + return -1; +} + +/* -- routes: NET_SIRCL_ROUTES, NET_SIRCL_WINDOWS, NET_SIRCL_TOPOLOGY -- */ + +/* Overrides may reduce a direct window or the function allowances, never invent a route. + * Topology is the admission contract: unknown peers and changed routes fail closed. */ +static ncclResult_t route_overrides(void) { + const char *names[] = {"NET_SIRCL_ROUTES", "NET_SIRCL_WINDOWS"}; + for (int kind = 0; kind < 2; ++kind) { + const char *text = getenv(names[kind]); + if (!text) continue; + if (!*text || strlen(text) >= 2048 || text[0] == ',' || text[strlen(text)-1] == ',' || strstr(text, ",,")) + goto invalid; + char copy[2048]; + strcpy(copy, text); + uint64_t seen = 0; + for (char *save = NULL, *e = strtok_r(copy, ",", &save); e; e = strtok_r(NULL, ",", &save)) { + char *eq = strchr(e, '='); + if (!eq || eq == e) goto invalid; + *eq = 0; + for (char *q = e; *q; ++q) if (*q < '0' || *q > '9') goto invalid; + errno = 0; + char *end; + long peer = strtol(e, &end, 10); + if (errno || *end || peer < 0 || peer >= g.nhosts || peer == g.position || + !g.routes[peer].ndev || (seen & (UINT64_C(1) << peer))) goto invalid; + seen |= UINT64_C(1) << peer; + struct route *r = &g.routes[peer]; + if (!kind) { + char expected[160]; + snprintf(expected, sizeof expected, "%s/%s", g.devs[r->dev[0]].name, g.devs[r->dev[1]].name); + if (strcmp(expected, eq + 1)) goto invalid; + } else { + if (!eq[1]) goto invalid; + for (char *q = eq + 1; *q; ++q) if (*q < '0' || *q > '9') goto invalid; + errno = 0; + unsigned long cap = strtoul(eq + 1, &end, 10); + if (errno || *end || cap > MAX_NET_BYTES || (cap && cap < 1024)) goto invalid; + if (r->relays) { + if (!cap) goto invalid; + for (int d = 0; d < g.ndevs; ++d) + if (cap < g.relay_windows[d].cap) g.relay_windows[d].cap = (uint32_t)cap; + } else r->window = (uint32_t)cap; + } + } + continue; +invalid: + WARN("net-sircl: invalid %s; routes must match topology; relay windows cannot disable the function cap", names[kind]); + return ncclInvalidArgument; + } + return ncclSuccess; +} + +static int my_position_in(const struct sircl_core_topology *t) { + long p = g.position; + if (p >= 0) return (int)p; + char name[256] = {0}; + if (gethostname(name, sizeof name - 1)) return -1; + char *dot = strchr(name, '.'); + for (int i = 0; i < t->nhosts; ++i) { + if (!strcmp(t->host[i], name)) return i; + if (dot && (size_t)(dot - name) == strlen(t->host[i]) && !strncmp(t->host[i], name, (size_t)(dot - name))) + return i; + } + return -1; +} + +/* Routes and windows of every reachable peer from a topology file. */ +static int routes_from_topology(const char *path) { + struct sircl_route_plan plan; + char err[512]; + if (sircl_route_plan_load(path, (uint32_t)g.relay_budget, NET_SIRCL_VERSION, &plan, err, sizeof err)) { + WARN("net-sircl: NET_SIRCL_TOPOLOGY: %s", err); + return -1; + } + const struct sircl_core_topology t = plan.topology; + int me = my_position_in(&t); + if (me < 0 || me >= t.nhosts) { + WARN("net-sircl: NET_SIRCL_TOPOLOGY %s does not list this host; set NET_SIRCL_POSITION", path); + return -1; + } + g.position = me; + g.nhosts = t.nhosts; + g.relay_budget = (int)plan.budget; + g.policy = plan.policy; + g.route_derived = plan.derived; + unsigned sources = t.nhosts > 2 ? (unsigned)t.nhosts - 2 : 1; + for (int d = 0; d < g.ndevs; ++d) { + int f = sircl_route_function(&t, g.devs[d].name); + g.relay_windows[d].cap = f >= 0 ? plan.caps[me][f] : (uint32_t)g.relay_budget / sources / 64u * 64u; + g.relay_windows[d].ack_cap = f >= 0 ? plan.acks[me][f] : 0; + g.relay_windows[d].relay = 1; + } + for (int peer = 0; peer < t.nhosts; ++peer) { + if (peer == me) continue; + const char *fn[2]; + int relays = 0; + if (sircl_core_topology_route(&t, me, peer, fn, &relays) < 0) continue; + struct route *r = &g.routes[peer]; + r->ndev = 0; + for (int l = 0; l < NET_SIRCL_MAX_LANES; ++l) { + int d = dev_by_name(fn[l]); + if (d < 0) { + WARN("net-sircl: topology lane %s is not exposed; retain both route lanes in NET_SIRCL_HCA", fn[l]); + return -1; + } + r->dev[r->ndev++] = d; + } + r->relays = relays; + uint32_t a = g.relay_windows[r->dev[0]].cap, b = g.relay_windows[r->dev[1]].cap; + r->window = relays > 0 ? (a < b ? a : b) : 0; + } + return 0; +} + +/* Test hook: the routes a topology file gives `position`, as "=/::;...". */ +int net_sircl_topology_routes(const char *path, int position, char *out, size_t len) { + if (!out || !len) return -1; + struct sircl_route_plan plan; + char err[512]; + out[0] = '\0'; + if (sircl_route_plan_load(path, RELAY_BUDGET_DEFAULT, NET_SIRCL_VERSION, &plan, err, sizeof err)) { + snprintf(out, len, "error: %s", err); + return -1; + } + const struct sircl_core_topology t = plan.topology; + if (position < 0 || position >= t.nhosts) { + snprintf(out, len, "error: position is outside the topology"); + return -1; + } + size_t used = 0; + for (int peer = 0; peer < t.nhosts; ++peer) { + const char *fn[2]; + int relays = 0; + if (peer == position || sircl_core_topology_route(&t, position, peer, fn, &relays) < 0) continue; + uint32_t a = plan.caps[position][sircl_route_function(&t, fn[0])], b = plan.caps[position][sircl_route_function(&t, fn[1])]; + int n = snprintf(out + used, len - used, "%d=%s/%s:%d:%u;", peer, fn[0], fn[1], relays, + relays > 0 ? (a < b ? a : b) : 0u); + if (n < 0 || (size_t)n >= len - used) return -1; + used += (size_t)n; + } + return 0; +} + diff --git a/net-sircl/net_sircl_connection.h b/net-sircl/net_sircl_connection.h new file mode 100644 index 0000000..416e6ca --- /dev/null +++ b/net-sircl/net_sircl_connection.h @@ -0,0 +1,415 @@ +/* Private connection lifecycle: nonblocking metadata exchange, QP ownership and retryable teardown. */ +static int set_nonblocking(int fd) { + int flags = fcntl(fd, F_GETFL, 0); + return flags < 0 ? -1 : fcntl(fd, F_SETFL, flags | O_NONBLOCK); +} + +static int send_all(int fd, const void *buf, size_t len) { + const char *p = buf; + int64_t deadline = now_ms() + 10000; + while (len) { + ssize_t n = send(fd, p, len, MSG_NOSIGNAL); + if (n < 0 && (errno == EAGAIN || errno == EINTR)) { + if (now_ms() > deadline) return -1; + struct pollfd pf = {fd, POLLOUT, 0}; + poll(&pf, 1, 100); + continue; + } + if (n <= 0) return -1; + p += n; + len -= (size_t)n; + } + return 0; +} + +/* Progress a receive of `len` bytes; 1 when complete, 0 when more is due, -1 on failure or end of stream. */ +static int recv_some(int fd, void *buf, size_t len, size_t *got) { + while (*got < len) { + ssize_t n = recv(fd, (char *)buf + *got, len - *got, 0); + if (n < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) return 0; + if (n < 0 && errno == EINTR) continue; + if (n <= 0) return -1; + *got += (size_t)n; + } + return 1; +} + +/* The peer's end of the comm's socket closed: its process ended or it closed the comm. */ +static int peer_gone(struct comm *c) { + if (c->fd < 0) return 0; + struct pollfd pf = {c->fd, POLLIN | POLLRDHUP, 0}; + if (poll(&pf, 1, 0) <= 0) return 0; + if (pf.revents & (POLLHUP | POLLERR | POLLRDHUP)) return 1; + char b; + return (pf.revents & POLLIN) && recv(c->fd, &b, 1, MSG_PEEK) == 0; +} + +/* -- queue pairs -- */ +static ncclResult_t comm_destroy(struct comm *c) { + if (!c) return ncclSuccess; + if (c->win) pthread_mutex_lock(&c->win->lock); + /* Stop the QP before retiring its local accounting. An abandoned relay write may still be + * in the fabric: poison the allowance instead of lending its credit to another comm. */ + if (c->qp) { + if (sircl_core_destroy_qp(c->qp)) { + if (c->win) pthread_mutex_unlock(&c->win->lock); + WARN("net-sircl: queue pair destruction failed; communicator ownership retained"); + return c->error = ncclSystemError; + } + c->qp = NULL; + } + if (c->win) { + admission_leave_locked(c); + pthread_mutex_unlock(&c->win->lock); + c->win = NULL; + } + if (c->ctrl_mr) { + if (sircl_core_dereg_mr(c->ctrl_mr)) { + WARN("net-sircl: control registration release failed; communicator ownership retained"); + return c->error = ncclSystemError; + } + c->ctrl_mr = NULL; + } + if (c->cq) { + if (sircl_core_destroy_cq(c->cq)) { + WARN("net-sircl: completion queue destruction failed; communicator ownership retained"); + return c->error = ncclSystemError; + } + c->cq = NULL; + } + if (profile_enabled) profile_close(c); + shared_free(c->ctrl); + if (c->fd >= 0) close(c->fd); + free(c); + return ncclSuccess; +} + +static struct comm *comm_create(int d, int is_send) { + struct comm *c = calloc(1, sizeof *c); + if (!c) return NULL; + c->dev = d; + c->is_send = is_send; + c->fd = -1; + c->lane = -1; + struct dev *dv = &g.devs[d]; + c->cq = sircl_core_create_cq(dv->ctx, CQ_DEPTH); + c->qp = c->cq ? sircl_core_create_rc_qp(dv->pd, c->cq, SEND_DEPTH, 16) : NULL; + c->ctrl = shared_alloc(sizeof *c->ctrl); + c->ctrl_mr = c->ctrl ? sircl_core_reg_mr(dv->pd, c->ctrl, sizeof *c->ctrl, + IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE) : NULL; + if (!c->cq || !c->qp || !c->ctrl || !c->ctrl_mr) { + WARN("net-sircl: queue pair setup on %s failed", dv->name); + comm_destroy(c); + return NULL; + } + if (sircl_core_qp_init(c->qp, dv->port, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE)) { + WARN("net-sircl: queue pair to INIT on %s failed", dv->name); + comm_destroy(c); + return NULL; + } + return c; +} + +static void meta_fill(struct comm *c, struct net_sircl_meta *m) { + struct dev *dv = &g.devs[c->dev]; + memset(m, 0, sizeof *m); + m->magic = NET_SIRCL_MAGIC; + m->qpn = c->qp->qp_num; + memcpy(m->gid, dv->gid.raw, 16); + m->mtu = (uint32_t)dv->mtu; + m->ctrl_rkey = c->ctrl_mr->rkey; + m->ctrl_addr = (uint64_t)(uintptr_t)c->ctrl; + m->position = g.position; + m->lane = c->lane; + m->policy = g.policy; +} + +/* Fail fast when this function's interface has no route to the peer's address: a peer beyond a cable needs + * a relay table on the hosts between, and without one RTR would only time out after about a minute. */ +static ncclResult_t route_check(struct comm *c, const struct net_sircl_meta *r) { +#ifdef NET_SIRCL_STANDIN + (void)c; (void)r; + return ncclSuccess; +#else + struct dev *dv = &g.devs[c->dev]; + static const uint8_t mapped[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; + if (!dv->netdev[0] || memcmp(r->gid, mapped, 12) || !env_long("NET_SIRCL_ROUTE_CHECK", 1)) return ncclSuccess; + int fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) return ncclSuccess; + ncclResult_t result = ncclSuccess; + if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, dv->netdev, (socklen_t)strlen(dv->netdev)) == 0) { + struct sockaddr_in sa; + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; + sa.sin_port = htons(4791); + memcpy(&sa.sin_addr.s_addr, r->gid + 12, 4); + if (connect(fd, (struct sockaddr *)&sa, sizeof sa) && (errno == ENETUNREACH || errno == EHOSTUNREACH)) { + char ip[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &sa.sin_addr, ip, sizeof ip); + WARN("net-sircl: no route from %s (%s) to %s, the peer at position %d: a peer beyond a cable needs a relay " + "table on the hosts between (README, Peers beyond a cable)", dv->name, dv->netdev, ip, r->position); + result = ncclSystemError; + } + } + close(fd); + return result; +#endif +} + +static ncclResult_t comm_ready(struct comm *c, const struct net_sircl_meta *r) { + struct dev *dv = &g.devs[c->dev]; + if (r->magic != NET_SIRCL_MAGIC) { + WARN("net-sircl: peer metadata has magic %08x", r->magic); + return ncclRemoteError; + } + if (r->policy != g.policy || r->position < 0 || r->position >= g.nhosts || + !g.routes[r->position].ndev) { + WARN("net-sircl: peer topology/budget disagreement or unknown position %d", r->position); + return ncclRemoteError; + } + ncclResult_t rc = route_check(c, r); + if (rc != ncclSuccess) return rc; + struct sircl_core_qp_peer peer = { + .qpn = r->qpn, .mtu = r->mtu < (uint32_t)dv->mtu ? r->mtu : (uint32_t)dv->mtu, + .port = dv->port, .gid_index = (uint8_t)dv->gid_index, .hop_limit = 64, + .traffic_class = (uint8_t)g.traffic_class + }; + if (peer.mtu < IBV_MTU_256 || peer.mtu > IBV_MTU_4096) return ncclRemoteError; + c->mtu_bytes = 128u << peer.mtu; + memcpy(peer.gid, r->gid, 16); + if (sircl_core_qp_rtr(c->qp, &peer)) { + WARN("net-sircl: queue pair to RTR on %s failed: %s (peer position %d unreachable from this function?)", + dv->name, strerror(errno), r->position); + return ncclSystemError; + } + if (sircl_core_qp_rts(c->qp, (unsigned)g.ib_timeout, (unsigned)g.ib_retry_cnt)) { + WARN("net-sircl: queue pair to RTS on %s failed: %s", dv->name, strerror(errno)); + return ncclSystemError; + } + c->rctrl_addr = r->ctrl_addr; + c->rctrl_rkey = r->ctrl_rkey; + c->peer_position = r->position; + const struct route *route = &g.routes[r->position]; + c->win = route->relays ? &g.relay_windows[c->dev] : + c->is_send ? window_for(c->dev, r->position, route->window) : NULL; + if (c->is_send && route->window && !c->win) return ncclSystemError; + if (c->win) window_join(c->win, c); + return ncclSuccess; +} + +static const struct route *route_of(int position) { + if (position < 0 || position >= MAX_POSITIONS || g.routes[position].ndev == 0) return NULL; + return &g.routes[position]; +} + +/* The connector's lane and function toward `position`: NCCL's device when it is one of the route's lanes + * (NCCL spreads its channels over the devices, which keeps both PCI functions of a cable busy), else the + * route's lanes in turn. Without a route, NCCL's device and no lane. */ +static int connect_dev(int position, int nccl_dev, int *lane) { + struct route *r = (struct route *)route_of(position); + *lane = -1; + if (!r) return nccl_dev; + for (int l = 0; l < r->ndev; ++l) + if (r->dev[l] == nccl_dev) { + *lane = l; + return nccl_dev; + } + pthread_mutex_lock(&g.lock); + *lane = (int)(r->next++ % (unsigned)r->ndev); + pthread_mutex_unlock(&g.lock); + return r->dev[*lane]; +} + +/* The acceptor's function: the connector's lane of this side's route toward the connector, so both ends of + * the queue pair are the same function class on the same path. */ +static int accept_dev(int position, int lane, int listen_dev) { + const struct route *r = route_of(position); + if (!r) return listen_dev; + if (lane >= 0 && lane < r->ndev) return r->dev[lane]; + for (int l = 0; l < r->ndev; ++l) + if (r->dev[l] == listen_dev) return listen_dev; + return r->dev[0]; +} + +/* -- listen / connect / accept -- */ +static ncclResult_t sircl_listen(void *ctx, int d, void *handle, void **listenComm) { + (void)ctx; + if (d < 0 || d >= g.ndevs) return ncclInvalidArgument; + struct net_sircl_handle *h = handle; + memset(handle, 0, NCCL_NET_HANDLE_MAXSIZE); + int fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) return ncclSystemError; + struct sockaddr_in sa; + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; + sa.sin_addr.s_addr = htonl(INADDR_ANY); + socklen_t len = sizeof sa; + if (bind(fd, (struct sockaddr *)&sa, sizeof sa) || listen(fd, 128) || + getsockname(fd, (struct sockaddr *)&sa, &len) || set_nonblocking(fd)) { + close(fd); + return ncclSystemError; + } + h->magic = NET_SIRCL_MAGIC; + h->version = NET_SIRCL_VERSION; + h->port = sa.sin_port; + h->addr = g.oob_addr; + h->position = g.position; + h->pending = 0; + struct listen_comm *l = calloc(1, sizeof *l); + if (!l) { + close(fd); + return ncclSystemError; + } + l->fd = fd; + l->dev = d; + *listenComm = l; + return ncclSuccess; +} + +static void pending_drop(struct pending *p) { + if (!p) return; + if (p->c) comm_destroy(p->c); + if (p->fd >= 0) close(p->fd); + free(p); +} + +static ncclResult_t connect_fail(struct net_sircl_handle *h, struct pending *p, ncclResult_t r) { + h->pending = 0; + pending_drop(p); + return r; +} + +static ncclResult_t sircl_connect(void *ctx, int d, void *handle, void **sendComm, + ncclNetDeviceHandle_v12_t **sendDevComm) { + (void)ctx; + (void)sendDevComm; + *sendComm = NULL; + struct net_sircl_handle *h = handle; + if (h->magic != NET_SIRCL_MAGIC || h->version != NET_SIRCL_VERSION) { + WARN("net-sircl: handle magic %08x version %u", h->magic, h->version); + return ncclInvalidArgument; + } + if (!route_of(h->position)) return ncclInvalidArgument; + struct pending *p = (struct pending *)(uintptr_t)h->pending; + if (!p) { + p = calloc(1, sizeof *p); + if (!p) return ncclSystemError; + p->deadline_ms = now_ms() + g.connect_timeout_ms; + int lane = -1; + p->dev = connect_dev(h->position, d, &lane); + p->fd = socket(AF_INET, SOCK_STREAM, 0); + if (p->fd < 0 || set_nonblocking(p->fd)) return connect_fail(h, p, ncclSystemError); + int one = 1; + setsockopt(p->fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof one); + struct sockaddr_in sa; + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; + sa.sin_port = h->port; + sa.sin_addr.s_addr = h->addr; + if (connect(p->fd, (struct sockaddr *)&sa, sizeof sa) && errno != EINPROGRESS) { + WARN("net-sircl: connecting to the listener: %s", strerror(errno)); + return connect_fail(h, p, ncclSystemError); + } + p->c = comm_create(p->dev, 1); + if (!p->c) return connect_fail(h, p, ncclSystemError); + p->c->lane = lane; + p->state = P_CONNECTING; + h->pending = (uint64_t)(uintptr_t)p; + } + if (now_ms() > p->deadline_ms) { + WARN("net-sircl: connecting to position %d timed out after %d ms (NET_SIRCL_CONNECT_TIMEOUT_MS)", h->position, + g.connect_timeout_ms); + return connect_fail(h, p, ncclSystemError); + } + if (p->state == P_CONNECTING) { + struct pollfd pf = {p->fd, POLLOUT, 0}; + if (poll(&pf, 1, 0) <= 0) return ncclSuccess; + int err = 0; + socklen_t len = sizeof err; + getsockopt(p->fd, SOL_SOCKET, SO_ERROR, &err, &len); + if (err) { + WARN("net-sircl: connecting to the listener: %s", strerror(err)); + return connect_fail(h, p, ncclSystemError); + } + meta_fill(p->c, &p->mine); + if (send_all(p->fd, &p->mine, sizeof p->mine)) return connect_fail(h, p, ncclSystemError); + p->state = P_WAIT_META; + } + if (p->state == P_WAIT_META) { + int r = recv_some(p->fd, &p->theirs, sizeof p->theirs, &p->got); + if (r < 0) return connect_fail(h, p, ncclRemoteError); + if (r == 0) return ncclSuccess; + ncclResult_t rr = comm_ready(p->c, &p->theirs); + if (rr != ncclSuccess) return connect_fail(h, p, rr); + /* Ready: this queue pair is at RTS, so the acceptor may let its side write (as NCCL's IB transport + * finishes its connect). */ + uint8_t ready = 1; + if (send_all(p->fd, &ready, 1)) return connect_fail(h, p, ncclSystemError); + p->c->fd = p->fd; + p->fd = -1; + *sendComm = p->c; + INFO("net-sircl: send comm on %s (lane %d) to position %d, window %u", g.devs[p->c->dev].name, p->c->lane, + p->c->peer_position, p->c->win ? p->c->win->cap : 0u); + p->c = NULL; + h->pending = 0; + free(p); + } + return ncclSuccess; +} + +static ncclResult_t accept_fail(struct listen_comm *l, ncclResult_t r) { + pending_drop(l->accepting); + l->accepting = NULL; + return r; +} + +static ncclResult_t sircl_accept(void *listenComm, void **recvComm, ncclNetDeviceHandle_v12_t **recvDevComm) { + (void)recvDevComm; + *recvComm = NULL; + struct listen_comm *l = listenComm; + struct pending *p = l->accepting; + if (!p) { + int fd = accept(l->fd, NULL, NULL); + if (fd < 0) return (errno == EAGAIN || errno == EWOULDBLOCK) ? ncclSuccess : ncclSystemError; + p = calloc(1, sizeof *p); + if (!p) { + close(fd); + return ncclSystemError; + } + p->fd = fd; + set_nonblocking(fd); + p->state = P_WAIT_META; + p->deadline_ms = now_ms() + g.connect_timeout_ms; + l->accepting = p; + } + if (now_ms() > p->deadline_ms) { + WARN("net-sircl: accepting a connection timed out after %d ms (NET_SIRCL_CONNECT_TIMEOUT_MS)", + g.connect_timeout_ms); + return accept_fail(l, ncclSystemError); + } + if (p->state == P_WAIT_META) { + int r = recv_some(p->fd, &p->theirs, sizeof p->theirs, &p->got); + if (r < 0) return accept_fail(l, ncclRemoteError); + if (r == 0) return ncclSuccess; + p->c = comm_create(accept_dev(p->theirs.position, p->theirs.lane, l->dev), 0); + if (!p->c) return accept_fail(l, ncclSystemError); + p->c->lane = p->theirs.lane; + meta_fill(p->c, &p->mine); + if (send_all(p->fd, &p->mine, sizeof p->mine)) return accept_fail(l, ncclSystemError); + ncclResult_t rr = comm_ready(p->c, &p->theirs); + if (rr != ncclSuccess) return accept_fail(l, rr); + p->state = P_WAIT_READY; + } + int r = recv_some(p->fd, &p->ready, 1, &p->ready_got); + if (r < 0) return accept_fail(l, ncclRemoteError); + if (r == 0) return ncclSuccess; + p->c->fd = p->fd; + p->fd = -1; + *recvComm = p->c; + p->c = NULL; + l->accepting = NULL; + free(p); + return ncclSuccess; +} + +/* -- memory -- */ diff --git a/net-sircl/net_sircl_routes.h b/net-sircl/net_sircl_plan.c similarity index 75% rename from net-sircl/net_sircl_routes.h rename to net-sircl/net_sircl_plan.c index b3479bc..efa3c5a 100644 --- a/net-sircl/net_sircl_routes.h +++ b/net-sircl/net_sircl_plan.c @@ -1,12 +1,10 @@ -/* Static relay admission for the complete topology route set. See ROUTE-ALLOWANCE.md. - * This is plugin policy, not a change to transport-core's route selection. */ -#ifndef NET_SIRCL_ROUTES_H -#define NET_SIRCL_ROUTES_H - +/* Relay admission uses the complete validated topology, independent of device discovery. */ +#include "net_sircl_plan.h" +#include +#include #define ROUTE_MODEL_HOSTS 8 -#define ROUTE_FUNCTIONS 4 -static int route_function(const struct sircl_core_topology *t, const char *name) { +int sircl_route_function(const struct sircl_core_topology *t, const char *name) { for (int f = 0; f < ROUTE_FUNCTIONS; ++f) if (!strcmp(t->fn[f / 2][f % 2], name)) return f; return -1; @@ -14,7 +12,7 @@ static int route_function(const struct sircl_core_topology *t, const char *name) /* Return 1 only when every forward/reverse lane can be reconstructed exactly. * Otherwise retain the aggregate bound, including for larger topologies. */ -static int route_allowances(const struct sircl_core_topology *t, uint32_t budget, +int sircl_route_allowances(const struct sircl_core_topology *t, uint32_t budget, uint32_t caps[MAX_POSITIONS][ROUTE_FUNCTIONS]) { unsigned sources = t->nhosts > 2 ? (unsigned)t->nhosts - 2 : 1; uint32_t fallback = budget / sources / 64u * 64u; @@ -46,7 +44,7 @@ static int route_allowances(const struct sircl_core_topology *t, uint32_t budget if (sircl_core_topology_route(t, s, d, fn, &relays) < 0) continue; if (sircl_core_topology_route(t, d, s, back, &reverse_relays) != 2 || reverse_relays != relays) return 0; for (int lane = 0; lane < 2; ++lane) { - int f = route_function(t, fn[lane]); + int f = sircl_route_function(t, fn[lane]); if (f < 0) return 0; int origin = s * ROUTE_FUNCTIONS + f, u = s, port = f / 2; weight[origin] += (unsigned)relays; @@ -84,7 +82,7 @@ static int route_allowances(const struct sircl_core_topology *t, uint32_t budget * reverse ACK debt B/5. Both use the SAME source weights. Rounding only lowers * allowances. Tiny shares retain the aggregate policy for the whole topology: * every admitted source must be able to reserve a two-packet control pair. */ -static int split_allowances(const struct sircl_core_topology *t, int derived, +int sircl_split_allowances(const struct sircl_core_topology *t, int derived, uint32_t caps[MAX_POSITIONS][ROUTE_FUNCTIONS], uint32_t ack[MAX_POSITIONS][ROUTE_FUNCTIONS]) { memset(ack, 0, MAX_POSITIONS * ROUTE_FUNCTIONS * sizeof(uint32_t)); @@ -99,4 +97,23 @@ static int split_allowances(const struct sircl_core_topology *t, int derived, } return 1; } -#endif + +int sircl_route_plan_load(const char *path, uint32_t budget, unsigned wire, + struct sircl_route_plan *plan, char *error, size_t len) { + memset(plan, 0, sizeof *plan); + struct sircl_core_topology *t = &plan->topology; + if (sircl_core_topology_parse(path, t, error, len)) return -1; + if (t->budget < 65536 || t->budget > 393216 || budget < 65536 || budget > 327680) { + snprintf(error, len, "relay_budget must be 65536..393216; effective budget ceiling 65536..327680"); + return -1; + } + plan->budget = t->budget < budget ? t->budget : budget; + t->budget = plan->budget; + plan->derived = sircl_route_allowances(t, plan->budget, plan->caps); + sircl_split_allowances(t, plan->derived, plan->caps, plan->acks); + plan->policy = UINT64_C(14695981039346656037); + for (size_t i = 0; i < sizeof *t; ++i) + plan->policy = (plan->policy ^ ((const unsigned char *)t)[i]) * UINT64_C(1099511628211); + plan->policy = (plan->policy ^ wire) * UINT64_C(1099511628211); + return 0; +} diff --git a/net-sircl/net_sircl_plan.h b/net-sircl/net_sircl_plan.h new file mode 100644 index 0000000..755037d --- /dev/null +++ b/net-sircl/net_sircl_plan.h @@ -0,0 +1,24 @@ +/* Private topology planning contract shared by the plugin and CPU oracle. */ +#ifndef NET_SIRCL_PLAN_H +#define NET_SIRCL_PLAN_H +#include +#define MAX_POSITIONS SIRCL_CORE_MAX_POSITIONS +#define ROUTE_FUNCTIONS 4 +struct sircl_route_plan { + struct sircl_core_topology topology; + uint32_t caps[MAX_POSITIONS][ROUTE_FUNCTIONS]; + uint32_t acks[MAX_POSITIONS][ROUTE_FUNCTIONS]; + uint64_t policy; + uint32_t budget; + int derived; +}; +#define SIRCL_PLAN_PRIVATE __attribute__((visibility("hidden"))) +SIRCL_PLAN_PRIVATE int sircl_route_function(const struct sircl_core_topology *, const char *); +SIRCL_PLAN_PRIVATE int sircl_route_allowances(const struct sircl_core_topology *, uint32_t, + uint32_t [MAX_POSITIONS][ROUTE_FUNCTIONS]); +SIRCL_PLAN_PRIVATE int sircl_split_allowances(const struct sircl_core_topology *, int, + uint32_t [MAX_POSITIONS][ROUTE_FUNCTIONS], + uint32_t [MAX_POSITIONS][ROUTE_FUNCTIONS]); +/* Deterministic, with no device discovery or process-global configuration. */ +SIRCL_PLAN_PRIVATE int sircl_route_plan_load(const char *, uint32_t, unsigned, struct sircl_route_plan *, char *, size_t); +#endif diff --git a/net-sircl/tests/request_contract_test.c b/net-sircl/tests/request_contract_test.c new file mode 100644 index 0000000..0dde7b9 --- /dev/null +++ b/net-sircl/tests/request_contract_test.c @@ -0,0 +1,41 @@ +/* Private protocol seam: registration ownership and receive capacity under provider faults. */ +#include "../net_sircl.c" +#include + +int main(int argc, char **argv) { + assert(argc == 2); + assert(!setenv("NET_SIRCL_TOPOLOGY", argv[1], 1)); + assert(!setenv("NET_SIRCL_POSITION", "0", 1)); + void *context = NULL; + assert(sircl_init(&context, 0, NULL, NULL, NULL) == ncclSuccess); + struct comm *c = comm_create(0, 0); assert(c); + unsigned char data[16] = {0}; + void *registration = NULL; + assert(sircl_reg_mr(c, data, sizeof data, NCCL_PTR_HOST, ®istration) == ncclSuccess); + struct mr *mr = registration; + assert(mr->ib && mr->shadow); + assert(!setenv("SIRCL_EMU_FAIL_DEREG", "1", 1)); + assert(sircl_dereg_mr(c, registration) == ncclSystemError); + assert(mr->ib && mr->shadow && mr->size == sizeof data); + assert(!unsetenv("SIRCL_EMU_FAIL_DEREG")); + assert(sircl_dereg_mr(c, registration) == ncclSuccess); + + struct req *q = &c->reqs[0]; + q->used = 1; q->c = c; q->total = sizeof data; q->cts_done = 1; + q->user = data; q->shadow = data; q->seq = 0; q->slot = 0; + c->ctrl->done_seq[0] = 1; + c->ctrl->done_size[0] = sizeof data + 1; + int done = -1, size = -1; + assert(sircl_test(q, &done, &size) == ncclRemoteError); + assert(done == 0 && size == -1 && q->used); + assert(c->error == ncclRemoteError); + for (unsigned i = 0; i < sizeof data; ++i) assert(data[i] == 0); + assert(!setenv("SIRCL_EMU_FAIL_DEREG", "1", 1)); + assert(sircl_close_recv(c) == ncclSystemError); + assert(!c->qp && c->ctrl_mr && c->ctrl); + assert(!unsetenv("SIRCL_EMU_FAIL_DEREG")); + assert(sircl_close_recv(c) == ncclSuccess); + assert(sircl_finalize(context) == ncclSuccess); + puts("request contracts: failed registration release retains ownership; oversized completion rejected"); + return 0; +} diff --git a/net-sircl/tests/route_model.c b/net-sircl/tests/route_model.c index af0b554..4ccaec2 100644 --- a/net-sircl/tests/route_model.c +++ b/net-sircl/tests/route_model.c @@ -1,11 +1,12 @@ /* Expose the production allocator to the independent Python route/queue oracle. */ -#include "../net_sircl.c" +#include "../net_sircl_plan.h" +#include int test_route_caps(const char *path, uint32_t budget, uint32_t *out) { struct sircl_core_topology t; char err[512]; if (sircl_core_topology_parse(path, &t, err, sizeof err)) return -1; uint32_t caps[MAX_POSITIONS][ROUTE_FUNCTIONS]; - int derived = route_allowances(&t, budget, caps); + int derived = sircl_route_allowances(&t, budget, caps); memcpy(out, caps, t.nhosts * ROUTE_FUNCTIONS * sizeof(uint32_t)); return derived; } @@ -15,7 +16,7 @@ int test_split_caps(const char *path, uint32_t budget, uint32_t *out, uint32_t * char err[512]; if (sircl_core_topology_parse(path, &t, err, sizeof err)) return -1; uint32_t caps[MAX_POSITIONS][ROUTE_FUNCTIONS], ack[MAX_POSITIONS][ROUTE_FUNCTIONS]; - int split = split_allowances(&t, route_allowances(&t, budget, caps), caps, ack); + int split = sircl_split_allowances(&t, sircl_route_allowances(&t, budget, caps), caps, ack); memcpy(out, caps, t.nhosts * ROUTE_FUNCTIONS * sizeof(uint32_t)); memcpy(acks, ack, t.nhosts * ROUTE_FUNCTIONS * sizeof(uint32_t)); return split; diff --git a/net-sircl/tests/test_net_sircl.py b/net-sircl/tests/test_net_sircl.py index 05a315a..072f1e3 100644 --- a/net-sircl/tests/test_net_sircl.py +++ b/net-sircl/tests/test_net_sircl.py @@ -22,6 +22,7 @@ STANDIN = HERE / "tests" / "standin" CORE = next(p for p in (HERE.parents[1] / "transport-core", HERE.parent / "transport-core") if (p / "VERSION").is_file()) CORE_SOURCES = [str(CORE / "src" / f) for f in ("core.c", "topology.c", "sysfs.c")] +CORE_SOURCES += [str(HERE / "net_sircl_plan.c")] FLAGS = ["-std=gnu11", "-O2", "-Wall", "-Wextra", "-Werror", "-pthread"] STANDIN_FLAGS = ["-I", str(CORE / "include"), "-DNET_SIRCL_STANDIN", "-I", str(HERE), "-I", str(STANDIN / "fake_verbs"), "-I", str(STANDIN)] @@ -47,6 +48,19 @@ def tearDownClass(cls): cls.build.cleanup() # -- layer tests -- + def test_registration_and_receive_capacity_contracts(self): + exe = Path(self.build.name) / "request_contract_test" + subprocess.run([os.environ.get("CC", "cc"), *FLAGS, *STANDIN_FLAGS, + str(HERE / "tests/request_contract_test.c"), str(STANDIN / "shm_verbs.c"), + *CORE_SOURCES, "-o", str(exe)], check=True) + env = dict(os.environ, SIRCL_EMU_FABRIC=f"/sircl-contract-{os.getpid()}") + try: + result = subprocess.run([str(exe), str(self.topology)], env=env, + capture_output=True, text=True, timeout=10) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + finally: + (Path("/dev/shm") / env["SIRCL_EMU_FABRIC"].lstrip("/")).unlink(missing_ok=True) + def test_silent_and_lost_peers_fail_and_close(self): exe = Path(self.build.name) / "failure_test" subprocess.run([os.environ.get("CC", "cc"), *FLAGS, *STANDIN_FLAGS, @@ -381,8 +395,8 @@ def test_route_allowances_all_queues_and_reverse_acks(self): # tree and P2P routes and every multiplicity of channels on those routes. libpath = Path(self.build.name) / "route_model.so" subprocess.run([os.environ.get("CC", "cc"), *FLAGS, *STANDIN_FLAGS, "-shared", "-fPIC", - str(HERE / "tests" / "route_model.c"), str(STANDIN / "shm_verbs.c"), - *CORE_SOURCES, "-o", str(libpath)], check=True) + str(HERE / "tests" / "route_model.c"), str(HERE / "net_sircl_plan.c"), + str(CORE / "src/topology.c"), "-o", str(libpath)], check=True) lib = ctypes.CDLL(str(libpath)) lib.test_route_caps.argtypes = [ctypes.c_char_p, ctypes.c_uint32, ctypes.POINTER(ctypes.c_uint32)] names = ["emu0", "emu1", "emu2", "emu3"] diff --git a/tests/test_release.py b/tests/test_release.py index 4d48bb2..ae3a6ce 100644 --- a/tests/test_release.py +++ b/tests/test_release.py @@ -15,6 +15,11 @@ class ReleaseTests(unittest.TestCase): def test_release_transport_source_bytes_match_manifest(self): manifest = json.loads((ROOT / "SOURCE.json").read_text()) + excluded = {".git", "build", ".core-build", "dist", "test-results", ".codegraph"} + sources = {path.relative_to(ROOT).as_posix() for path in ROOT.rglob("*") + if path.is_file() and path.suffix in {".c", ".h", ".cc", ".cpp", ".cxx", ".hpp"} + and not set(path.relative_to(ROOT).parts) & excluded} + self.assertEqual(set(manifest["source_sha256"]), sources) for name, expected in manifest["source_sha256"].items(): with self.subTest(path=name): self.assertEqual(hashlib.sha256((ROOT / name).read_bytes()).hexdigest(), expected) @@ -43,7 +48,8 @@ def test_archive_reproducible_and_complete(self): "net-sircl/net_sircl_tuner.h", "net-sircl/nccl/tuner_v4.h", "examples/torch_teardown.py", "scripts/check_teardown.py", "scripts/check_channels.py", "scripts/check_compat.py", - "net-sircl/PROFILING.md", "net-sircl/net_sircl_routes.h", + "net-sircl/PROFILING.md", "net-sircl/net_sircl_plan.h", + "net-sircl/net_sircl_plan.c", "net-sircl/net_sircl_admission.h", "net-sircl/net_sircl_profile.h", "net-sircl/net_sircl_compat.h", "fabric-tool/LICENSE", "fabric-tool/NOTICE", "fabric-tool/VERSION", "fabric-tool/mesh_marker.c", "fabric-tool/fabric_tool/cli.py", diff --git a/transport-core/Makefile b/transport-core/Makefile index d7ac368..747e9a3 100644 --- a/transport-core/Makefile +++ b/transport-core/Makefile @@ -16,17 +16,20 @@ $(BUILD)/libsircl-core.a: $(OBJECTS) $(AR) rcs $@ $^ $(BUILD)/test_core: tests/test_core.c $(BUILD)/libsircl-core.a $(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $@ -$(BUILD)/test_verbs: tests/test_verbs.c src/shm_verbs.c | $(BUILD) +$(BUILD)/test_verbs: tests/test_verbs.c src/shm_verbs.c src/shm_memory.c | $(BUILD) $(CC) $(CPPFLAGS) -Itests/fake_verbs $(CFLAGS) $(filter %.c,$^) -o $@ -check: all $(BUILD)/test_core $(BUILD)/test_verbs +$(BUILD)/test_emulator_lifetime: tests/test_emulator_lifetime.c src/shm_verbs.c src/shm_memory.c | $(BUILD) + $(CC) $(CPPFLAGS) -Itests/fake_verbs $(CFLAGS) -DSIRCL_EMU_TEST_HOOKS $(filter %.c,$^) -o $@ +check: all $(BUILD)/test_core $(BUILD)/test_verbs $(BUILD)/test_emulator_lifetime $(BUILD)/test_core $(BUILD)/test_verbs + $(BUILD)/test_emulator_lifetime $(PYTHON) -m unittest discover -s tests -p 'test_*.py' -v clean: rm -rf $(BUILD) .PHONY: all check clean # The source digest covers transport-core sources, headers and tools, not the compiled library. -$(BUILD)/core_identity.h: $(wildcard ./src/*.c) $(wildcard ./include/*.h) $(wildcard ./include/sircl_core/*) $(wildcard ./tools/*.py) ./VERSION +$(BUILD)/core_identity.h: $(wildcard ./src/*.c ./src/*.h) $(wildcard ./include/*.h) $(wildcard ./include/sircl_core/*) $(wildcard ./tools/*.py) ./VERSION $(PYTHON) ./tools/identity.py --output $@ -$(OBJECTS) $(BUILD)/verbs_dl.o $(BUILD)/test_verbs: $(BUILD)/core_identity.h +$(OBJECTS) $(BUILD)/verbs_dl.o $(BUILD)/test_verbs $(BUILD)/test_emulator_lifetime: $(BUILD)/core_identity.h diff --git a/transport-core/include/sircl_core/shm_verbs.c b/transport-core/include/sircl_core/shm_verbs.c index def8f0e..306ae7d 100644 --- a/transport-core/include/sircl_core/shm_verbs.c +++ b/transport-core/include/sircl_core/shm_verbs.c @@ -1 +1,2 @@ #include "../../src/shm_verbs.c" +#include "../../src/shm_memory.c" diff --git a/transport-core/include/sircl_core/shm_verbs.h b/transport-core/include/sircl_core/shm_verbs.h index dc35e4b..b0ba306 100644 --- a/transport-core/include/sircl_core/shm_verbs.h +++ b/transport-core/include/sircl_core/shm_verbs.h @@ -1,8 +1,7 @@ /* Control interface of the shared-memory verbs stand-in (shm_verbs.c). * - * The stand-in implements the libibverbs subset that SIRCL's native proxy - * uses (the declarations of fake_verbs/infiniband/verbs.h, renamed sccl_emu_* - * by proxy_names.h) across processes of one host, so several processes, or + * The stand-in implements the libibverbs subset declared by the bundled + * emulation_verbs.h, renamed sccl_emu_* by legacy_proxy_names.h across processes of one host, so several processes, or * several threads of one process, act as the ranks of a group on one GPU. * * Fabric. One POSIX shared-memory segment (SIRCL_EMU_FABRIC, default @@ -30,9 +29,8 @@ * (flag lines) are release stores. A signaled or failed write leaves a * completion on the sender's completion queue. * - * Diagnostics. sccl_emu_report() describes the queue pairs of this process and - * the writes that failed; the library writes it into its link dumps - * (LIBSIRCL_LINK_DUMP). + * Diagnostics. sccl_emu_report() describes local queue pairs and failed writes + * as bounded JSON for callers and tests. * * Settings read at attach: SIRCL_EMU_FABRIC (segment name), SIRCL_EMU_SEED * (interleaving seed, default 1), SIRCL_EMU_LATENCY_NS (each write executes no diff --git a/transport-core/src/shm_memory.c b/transport-core/src/shm_memory.c new file mode 100644 index 0000000..f4b7ca2 --- /dev/null +++ b/transport-core/src/shm_memory.c @@ -0,0 +1,183 @@ +/* Shared-memory allocation and bounded mapping leases for the verbs emulator. */ +#define _GNU_SOURCE +#include "shm_memory.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +static pthread_mutex_t segments_lock = PTHREAD_MUTEX_INITIALIZER; +static sv_segment segments[SV_SEGMENTS]; +static uint64_t segment_clock; +static pthread_cond_t segment_retired = PTHREAD_COND_INITIALIZER; + +static void segment_tag(char *out, size_t len) { + const char *tag = getenv("SIRCL_EMU_SEGMENT_TAG"); + if (tag && *tag) { + snprintf(out, len, "%s", tag); + return; + } + unsigned long long start = 0; + char stat[1024] = {0}; + FILE *f = fopen("/proc/self/stat", "r"); + if (f) { + size_t n = fread(stat, 1, sizeof stat - 1, f); + stat[n] = 0; + fclose(f); + /* Field 2 (the command, in parentheses) may hold spaces: count fields after its closing parenthesis. + * Field 3 follows it; field 22 is the 20th after. */ + char *p = strrchr(stat, ')'); + for (int field = 3; p && *p && field <= 22; ++field) { + p = strchr(p + 1, ' '); + if (p && field == 22) start = strtoull(p + 1, NULL, 10); + } + } + snprintf(out, len, "%d-%llx", (int)getpid(), start); +} + +void *sccl_emu_segment_alloc(size_t bytes, char *err, size_t err_len) { + size_t page = (size_t)sysconf(_SC_PAGESIZE); + bytes = (bytes + page - 1) / page * page; + char tag[32], name[SV_NAME]; + segment_tag(tag, sizeof tag); + /* A name that exists already belongs to a segment another process left (or holds): take the fabric's + * next serial instead. It is never unlinked here; its owner may live in another PID namespace. */ + int fd = -1; + for (int attempt = 0; attempt < 64; ++attempt) { + uint32_t serial = sircl_emu_next_segment(); + if (!serial) { snprintf(err, err_len, "emulation fabric is not attached"); return NULL; } + snprintf(name, sizeof name, "/sircl-emu-seg-%s-%u", tag, serial); + fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600); + if (fd >= 0 || errno != EEXIST) break; + } + if (fd < 0) { + snprintf(err, err_len, "emulation segment %s: shm_open: %s", name, strerror(errno)); + return NULL; + } + if (ftruncate(fd, (off_t)bytes) != 0) { + snprintf(err, err_len, "emulation segment %s of %zu bytes: ftruncate: %s", name, bytes, strerror(errno)); + close(fd); + shm_unlink(name); + return NULL; + } + void *base = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + close(fd); + if (base == MAP_FAILED) { + snprintf(err, err_len, "emulation segment %s: mmap: %s", name, strerror(errno)); + shm_unlink(name); + return NULL; + } + pthread_mutex_lock(&segments_lock); + int slot = -1; + for (int i = 0; i < SV_SEGMENTS; ++i) + if (!segments[i].used) { + slot = i; + break; + } + if (slot < 0) { + for (int i = 0; i < SV_SEGMENTS; ++i) + if (!segments[i].owned && !segments[i].leases && + (slot < 0 || segments[i].touched < segments[slot].touched)) slot = i; + if (slot >= 0) { + munmap(segments[slot].base, segments[slot].bytes); + memset(&segments[slot], 0, sizeof segments[slot]); + } + } + if (slot < 0) { + pthread_mutex_unlock(&segments_lock); + munmap(base, bytes); + shm_unlink(name); + snprintf(err, err_len, "more than %d emulation segments in one process", SV_SEGMENTS); + return NULL; + } + snprintf(segments[slot].name, SV_NAME, "%s", name); + segments[slot].base = base; + segments[slot].bytes = bytes; + segments[slot].owned = 1; + segments[slot].used = 1; + pthread_mutex_unlock(&segments_lock); + return base; +} + +void sccl_emu_segment_free(void *base) { + pthread_mutex_lock(&segments_lock); + for (int i = 0; i < SV_SEGMENTS; ++i) { + if (segments[i].used && segments[i].owned && segments[i].base == base) { + while (segments[i].leases) pthread_cond_wait(&segment_retired, &segments_lock); + munmap(segments[i].base, segments[i].bytes); + shm_unlink(segments[i].name); + segments[i].used = 0; + break; + } + } + pthread_mutex_unlock(&segments_lock); +} + + +int sircl_emu_owned_segment(uint64_t addr, uint64_t length, char *name, size_t len, uint64_t *offset) { + int found = 0; + pthread_mutex_lock(&segments_lock); + for (int i = 0; i < SV_SEGMENTS; ++i) { + sv_segment *s = &segments[i]; + uint64_t base = (uint64_t)(uintptr_t)s->base; + if (s->used && s->owned && addr >= base && addr - base <= s->bytes && length <= s->bytes - (addr - base)) { + snprintf(name, len, "%s", s->name); + *offset = addr - base; + found = 1; + break; + } + } + pthread_mutex_unlock(&segments_lock); + return found; +} + +/* This process's mapping of the named segment, mapped on first use. */ +sv_segment *sircl_emu_mapping_acquire(const char *name) { + pthread_mutex_lock(&segments_lock); + for (int i = 0; i < SV_SEGMENTS; ++i) { + if (segments[i].used && !strcmp(segments[i].name, name)) { + segments[i].leases++; + segments[i].touched = ++segment_clock; + pthread_mutex_unlock(&segments_lock); + return &segments[i]; + } + } + sv_segment *slot = NULL; + for (int i = 0; i < SV_SEGMENTS; ++i) { + sv_segment *candidate = &segments[i]; + if (!candidate->used) { slot = candidate; break; } + if (!candidate->owned && !candidate->leases && (!slot || candidate->touched < slot->touched)) + slot = candidate; + } + if (!slot) { pthread_mutex_unlock(&segments_lock); return NULL; } + int fd = shm_open(name, O_RDWR, 0600); + struct stat st; + void *base = MAP_FAILED; + if (fd >= 0 && fstat(fd, &st) == 0 && st.st_size > 0) + base = mmap(NULL, (size_t)st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (fd >= 0) close(fd); + if (base == MAP_FAILED) { pthread_mutex_unlock(&segments_lock); return NULL; } + if (slot->used) munmap(slot->base, slot->bytes); + memset(slot, 0, sizeof *slot); + snprintf(slot->name, SV_NAME, "%s", name); + slot->base = base; + slot->bytes = (size_t)st.st_size; + slot->used = 1; + slot->leases = 1; + slot->touched = ++segment_clock; + pthread_mutex_unlock(&segments_lock); + return slot; +} + +void sircl_emu_mapping_release(sv_segment *mapping) { + pthread_mutex_lock(&segments_lock); + mapping->leases--; + pthread_cond_broadcast(&segment_retired); + pthread_mutex_unlock(&segments_lock); +} + diff --git a/transport-core/src/shm_memory.h b/transport-core/src/shm_memory.h new file mode 100644 index 0000000..6d59863 --- /dev/null +++ b/transport-core/src/shm_memory.h @@ -0,0 +1,22 @@ +/* Private ownership contract for emulator shared-memory mappings. */ +#ifndef SIRCL_EMU_MEMORY_H +#define SIRCL_EMU_MEMORY_H +#include +#include +#define SV_NAME 64 +#define SV_SEGMENTS 512 +typedef struct { + char name[SV_NAME]; + uint8_t *base; + size_t bytes; + int owned; + int used; + unsigned leases; + uint64_t touched; +} sv_segment; +/* The registry supplies globally unique segment serials; zero means unattached. */ +uint32_t sircl_emu_next_segment(void); +int sircl_emu_owned_segment(uint64_t, uint64_t, char *, size_t, uint64_t *); +sv_segment *sircl_emu_mapping_acquire(const char *); +void sircl_emu_mapping_release(sv_segment *); +#endif diff --git a/transport-core/src/shm_verbs.c b/transport-core/src/shm_verbs.c index 6d0b4be..7e15033 100644 --- a/transport-core/src/shm_verbs.c +++ b/transport-core/src/shm_verbs.c @@ -1,5 +1,5 @@ -/* Shared-memory verbs stand-in: the libibverbs subset of SIRCL's native proxy - * across the processes of one host. shm_verbs.h describes the model. */ +/* Shared-memory libibverbs subset for plugin CPU and single-host NCCL tests. + * sircl_core/shm_verbs.h describes its execution and memory model. */ #define _GNU_SOURCE #ifndef SCCL_RENAME_VERBS #define SCCL_RENAME_VERBS 1 @@ -33,7 +33,6 @@ #define SV_INLINE 16 #define SV_LOCAL_QPS 1024 #define SV_LOCAL_CQS 256 -#define SV_SEGMENTS 512 /* -- shared registry --------------------------------------------------------------------------- */ @@ -163,13 +162,7 @@ int sccl_emu_attach(char *err, size_t err_len) { /* -- local state ------------------------------------------------------------------------------- */ -typedef struct { - char name[SV_NAME]; - uint8_t *base; - size_t bytes; - int owned; - int used; -} sv_segment; +#include "shm_memory.h" typedef struct { struct ibv_cq cq; @@ -202,8 +195,6 @@ typedef struct { } sv_lqp; static pthread_mutex_t local = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t segments_lock = PTHREAD_MUTEX_INITIALIZER; -static sv_segment segments[SV_SEGMENTS]; static sv_cq cqs[SV_LOCAL_CQS]; static sv_lqp *qps[SV_LOCAL_QPS]; static int nqps; @@ -211,19 +202,23 @@ static uint32_t generations; static struct ibv_device devices[SV_MAX_DEVICES]; static pthread_t executor; static int executor_running; -static volatile int executor_stop; -/* The executor's lifecycle (started by the first queue pair's create, stopped and joined by the last - * destroy) is guarded on its own lock: create and destroy run concurrently, and a join that a new - * create's thread can overtake loses the new executor (tests/test_shm_verbs.py's executor race). */ +static int executor_stop; +/* Membership and worker transitions hold executor_lock before local. The worker only needs local. + * Joining releases local so the worker can retire; creators cannot publish until joining finishes. */ static pthread_mutex_t executor_lock = PTHREAD_MUTEX_INITIALIZER; -static int executor_users; +#ifdef SIRCL_EMU_TEST_HOOKS +extern void sircl_emu_test_hook(const char *event); +#define EMU_HOOK(event) sircl_emu_test_hook(event) +#else +#define EMU_HOOK(event) ((void)0) +#endif static uint64_t executed; /* Diagnostics (sccl_emu_report): the newest SV_ERRORS writes that did not succeed, and the completions the * stand-in could not deliver (a full completion queue; a queue pair destroyed while its write executed). */ #define SV_ERRORS 64 typedef struct { - uint64_t ns; /* CLOCK_REALTIME, the clock of the native proxy's event trace */ + uint64_t ns; /* CLOCK_REALTIME nanoseconds for failed-write diagnostics */ uint64_t wr_id, remote_addr; uint32_t qp_num, dest_qp_num, rkey, length; int32_t status, signaled, is_inline, peer_pid, peer_alive, delivered; @@ -279,150 +274,14 @@ int sccl_emu_add_device(const char *name, const uint8_t gid[16]) { * time in clock ticks since boot (field 22 of /proc/self/stat, hexadecimal), so a process of another PID * namespace that reuses the pid (containers sharing the host's /dev/shm) names its segments otherwise; * SIRCL_EMU_SEGMENT_TAG (a test setting) replaces it. */ -static void segment_tag(char *out, size_t len) { - const char *tag = getenv("SIRCL_EMU_SEGMENT_TAG"); - if (tag && *tag) { - snprintf(out, len, "%s", tag); - return; - } - unsigned long long start = 0; - char stat[1024] = {0}; - FILE *f = fopen("/proc/self/stat", "r"); - if (f) { - size_t n = fread(stat, 1, sizeof stat - 1, f); - stat[n] = 0; - fclose(f); - /* Field 2 (the command, in parentheses) may hold spaces: count fields after its closing parenthesis. - * Field 3 follows it; field 22 is the 20th after. */ - char *p = strrchr(stat, ')'); - for (int field = 3; p && *p && field <= 22; ++field) { - p = strchr(p + 1, ' '); - if (p && field == 22) start = strtoull(p + 1, NULL, 10); - } - } - snprintf(out, len, "%d-%llx", (int)getpid(), start); -} - -void *sccl_emu_segment_alloc(size_t bytes, char *err, size_t err_len) { - if (!F) { - snprintf(err, err_len, "emulation fabric is not attached"); - return NULL; - } - size_t page = (size_t)sysconf(_SC_PAGESIZE); - bytes = (bytes + page - 1) / page * page; - char tag[40], name[SV_NAME]; - segment_tag(tag, sizeof tag); - /* A name that exists already belongs to a segment another process left (or holds): take the fabric's - * next serial instead. It is never unlinked here; its owner may live in another PID namespace. */ - int fd = -1; - for (int attempt = 0; attempt < 64; ++attempt) { - fab_lock(); - uint32_t serial = ++F->next_segment; - fab_unlock(); - snprintf(name, sizeof name, "/sircl-emu-seg-%s-%u", tag, serial); - fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600); - if (fd >= 0 || errno != EEXIST) break; - } - if (fd < 0) { - snprintf(err, err_len, "emulation segment %s: shm_open: %s", name, strerror(errno)); - return NULL; - } - if (ftruncate(fd, (off_t)bytes) != 0) { - snprintf(err, err_len, "emulation segment %s of %zu bytes: ftruncate: %s", name, bytes, strerror(errno)); - close(fd); - shm_unlink(name); - return NULL; - } - void *base = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - close(fd); - if (base == MAP_FAILED) { - snprintf(err, err_len, "emulation segment %s: mmap: %s", name, strerror(errno)); - shm_unlink(name); - return NULL; - } - pthread_mutex_lock(&segments_lock); - int slot = -1; - for (int i = 0; i < SV_SEGMENTS; ++i) - if (!segments[i].used) { - slot = i; - break; - } - if (slot < 0) { - pthread_mutex_unlock(&segments_lock); - munmap(base, bytes); - shm_unlink(name); - snprintf(err, err_len, "more than %d emulation segments in one process", SV_SEGMENTS); - return NULL; - } - snprintf(segments[slot].name, SV_NAME, "%s", name); - segments[slot].base = base; - segments[slot].bytes = bytes; - segments[slot].owned = 1; - segments[slot].used = 1; - pthread_mutex_unlock(&segments_lock); - return base; -} - -void sccl_emu_segment_free(void *base) { - pthread_mutex_lock(&segments_lock); - for (int i = 0; i < SV_SEGMENTS; ++i) { - if (segments[i].used && segments[i].owned && segments[i].base == base) { - munmap(segments[i].base, segments[i].bytes); - shm_unlink(segments[i].name); - segments[i].used = 0; - break; - } - } - pthread_mutex_unlock(&segments_lock); -} - uint64_t sccl_emu_executed(void) { return __atomic_load_n(&executed, __ATOMIC_RELAXED); } -/* The owned segment holding [addr, addr + length), or -1. */ -static int owned_segment(uint64_t addr, uint64_t length) { - for (int i = 0; i < SV_SEGMENTS; ++i) { - sv_segment *s = &segments[i]; - uint64_t base = (uint64_t)(uintptr_t)s->base; - if (s->used && s->owned && addr >= base && addr + length <= base + s->bytes) return i; - } - return -1; -} - -/* This process's mapping of the named segment, mapped on first use. */ -static uint8_t *mapped(const char *name, uint64_t *bytes) { - pthread_mutex_lock(&segments_lock); - for (int i = 0; i < SV_SEGMENTS; ++i) { - if (segments[i].used && !strcmp(segments[i].name, name)) { - uint8_t *base = segments[i].base; - *bytes = segments[i].bytes; - pthread_mutex_unlock(&segments_lock); - return base; - } - } - uint8_t *base = NULL; - int fd = shm_open(name, O_RDWR, 0600); - struct stat st; - if (fd >= 0 && fstat(fd, &st) == 0) { - void *p = mmap(NULL, (size_t)st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (p != MAP_FAILED) { - for (int i = 0; i < SV_SEGMENTS; ++i) { - if (!segments[i].used) { - snprintf(segments[i].name, SV_NAME, "%s", name); - segments[i].base = p; - segments[i].bytes = (size_t)st.st_size; - segments[i].owned = 0; - segments[i].used = 1; - base = p; - *bytes = (uint64_t)st.st_size; - break; - } - } - if (!base) munmap(p, (size_t)st.st_size); - } - } - if (fd >= 0) close(fd); - pthread_mutex_unlock(&segments_lock); - return base; +uint32_t sircl_emu_next_segment(void) { + if (!F) return 0; + fab_lock(); + uint32_t serial = ++F->next_segment; + fab_unlock(); + return serial; } /* -- execution --------------------------------------------------------------------------------- */ @@ -561,7 +420,7 @@ static int execute_one(void) { uint32_t generation = q->generation; int errored = q->errored; sv_lqp snapshot = *q; - pthread_mutex_unlock(&local); + /* Keep QP ownership until the source read and completion have retired. */ enum ibv_wc_status status = IBV_WC_WR_FLUSH_ERR; char segment[SV_NAME]; @@ -575,20 +434,20 @@ static int execute_one(void) { fab_unlock(); } if (status == IBV_WC_SUCCESS) { - uint64_t bytes = 0; - uint8_t *base = mapped(segment, &bytes); - if (!base || seg_offset + w.length > bytes) { + sv_segment *mapping = sircl_emu_mapping_acquire(segment); + EMU_HOOK("executing"); + if (!mapping || seg_offset > mapping->bytes || w.length > mapping->bytes - seg_offset) { status = IBV_WC_REM_ACCESS_ERR; snprintf(reason, sizeof reason, "destination segment %s is not mapped or is shorter than offset %llu + %u", segment, (unsigned long long)seg_offset, w.length); } else { - apply(base + seg_offset, source, w.length); + apply(mapping->base + seg_offset, source, w.length); } + if (mapping) sircl_emu_mapping_release(mapping); } int peer_alive = status != IBV_WC_SUCCESS && peer_pid ? pid_alive(peer_pid) : 0; uint64_t when = status != IBV_WC_SUCCESS ? realtime_ns() : 0; __atomic_fetch_add(&executed, 1, __ATOMIC_RELAXED); - pthread_mutex_lock(&local); int delivered = 0, wants = w.signaled || status != IBV_WC_SUCCESS; if (qps[index] == q && q->generation == generation) { if (status != IBV_WC_SUCCESS) q->errored = 1; @@ -670,7 +529,7 @@ static void *executor_main(void *arg) { (void)arg; const struct timespec nap = {0, 10000}; unsigned idle = 0; - while (!executor_stop) { + while (!__atomic_load_n(&executor_stop, __ATOMIC_ACQUIRE)) { if (execute_one()) { idle = 0; continue; @@ -771,17 +630,10 @@ int ibv_dealloc_pd(struct ibv_pd *pd) { } struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access) { - pthread_mutex_lock(&segments_lock); - int s = owned_segment((uint64_t)(uintptr_t)addr, length); char name[SV_NAME] = {0}; uint64_t offset = 0; - if (s >= 0) { - snprintf(name, sizeof name, "%s", segments[s].name); - offset = (uint64_t)(uintptr_t)addr - (uint64_t)(uintptr_t)segments[s].base; - } - pthread_mutex_unlock(&segments_lock); - if (s < 0) { - errno = EINVAL; /* only memory from sccl_emu_segment_alloc can be registered */ + if (!sircl_emu_owned_segment((uint64_t)(uintptr_t)addr, length, name, sizeof name, &offset)) { + errno = EINVAL; return NULL; } struct ibv_mr *mr = calloc(1, sizeof *mr); @@ -885,6 +737,8 @@ struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) { errno = ENOMEM; return NULL; } + EMU_HOOK("create_waiting"); + pthread_mutex_lock(&executor_lock); q->capacity = (int)attr->cap.max_send_wr; q->device = pd->context->fv_index; fab_lock(); @@ -921,6 +775,7 @@ struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) { } free(q->queue); free(q); + pthread_mutex_unlock(&executor_lock); errno = ENOMEM; return NULL; } @@ -934,14 +789,15 @@ struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) { q->qp.fv_index = slot; qps[slot] = q; nqps++; - executor_users++; pthread_mutex_unlock(&local); - pthread_mutex_lock(&executor_lock); + int start_error = 0; if (!executor_running) { - executor_stop = 0; - if (pthread_create(&executor, NULL, executor_main, NULL) == 0) executor_running = 1; + __atomic_store_n(&executor_stop, 0, __ATOMIC_RELEASE); + start_error = pthread_create(&executor, NULL, executor_main, NULL); + if (!start_error) executor_running = 1; } pthread_mutex_unlock(&executor_lock); + if (start_error) { ibv_destroy_qp(&q->qp); errno = start_error; return NULL; } return &q->qp; } @@ -985,24 +841,25 @@ int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask) { } int ibv_destroy_qp(struct ibv_qp *qp) { + EMU_HOOK("retire_waiting"); + pthread_mutex_lock(&executor_lock); + EMU_HOOK("retire_locked"); pthread_mutex_lock(&local); sv_lqp *q = qps[qp->fv_index]; qps[qp->fv_index] = NULL; - nqps--; - int left = --executor_users; + int left = --nqps; pthread_mutex_unlock(&local); - pthread_mutex_lock(&executor_lock); - if (left == 0 && executor_running) { - executor_stop = 1; - executor_running = 0; + if (!left && executor_running) { + __atomic_store_n(&executor_stop, 1, __ATOMIC_RELEASE); pthread_join(executor, NULL); + executor_running = 0; } - pthread_mutex_unlock(&executor_lock); fab_lock(); F->qp[q->shared].used = 0; fab_unlock(); free(q->queue); free(q); + pthread_mutex_unlock(&executor_lock); return 0; } diff --git a/transport-core/src/topology.c b/transport-core/src/topology.c index 2417293..3c40122 100644 --- a/transport-core/src/topology.c +++ b/transport-core/src/topology.c @@ -95,6 +95,23 @@ int sircl_core_topology_parse(const char *path, struct sircl_core_topology *t, c snprintf(err, len, "%s: a cable joins a host index outside 0-%d", path, t->nhosts - 1); return -1; } + unsigned occupied[MAX_POSITIONS] = {0}; + for (int c = 0; c < t->ncables; ++c) { + int a = t->cable[c].a, b = t->cable[c].b; + unsigned pa = 1u << t->cable[c].pa, pb = 1u << t->cable[c].pb; + if ((occupied[a] & pa) || (occupied[b] & pb)) { + snprintf(err, len, "%s: topology connects a port more than once", path); + return -1; + } + occupied[a] |= pa; + occupied[b] |= pb; + } + for (int a = 0; a < t->nhosts; ++a) + for (int b = a + 1; b < t->nhosts; ++b) + if (!strcmp(t->host[a], t->host[b])) { + snprintf(err, len, "%s: hosts names one host twice", path); + return -1; + } return 0; } diff --git a/transport-core/src/verbs_dl.c b/transport-core/src/verbs_dl.c index 0d894b7..ccbb804 100644 --- a/transport-core/src/verbs_dl.c +++ b/transport-core/src/verbs_dl.c @@ -1,10 +1,6 @@ -/* The libibverbs entry points that SIRCL's native proxy and point-to-point - * library call (proxy_hw.c, p2p_hw.c), resolved from libibverbs.so.1 at first use, so the library loads on hosts - * without rdma-core and binds the process's own libibverbs where one is - * loaded. Data-path calls (ibv_post_send, ibv_poll_cq) are inline in the - * rdma-core header and dispatch through the device context; they need no - * symbol. Every definition here is hidden: the library exports only the NCCL - * API and its libsircl extension. */ +/* Optional hidden libibverbs loader for consumers without a link-time rdma-core dependency. + * Symbols resolve from libibverbs.so.1 on first use. Data-path inline calls dispatch through the + * device context. The net-sircl plugin links libibverbs directly and does not use this loader. */ #define _GNU_SOURCE #include #include diff --git a/transport-core/tests/test_emulator_lifetime.c b/transport-core/tests/test_emulator_lifetime.c new file mode 100644 index 0000000..9a6eb85 --- /dev/null +++ b/transport-core/tests/test_emulator_lifetime.c @@ -0,0 +1,206 @@ +/* Public verbs lifecycle contracts with barriers at worker and membership transitions. */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define SCCL_RENAME_VERBS +#include +#include + +static pthread_mutex_t barrier_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t barrier = PTHREAD_COND_INITIALIZER; +enum { NORMAL, MEMBERSHIP, WORK }; +static int mode, retiring, creating, executing, released; + +void sircl_emu_test_hook(const char *event) { + pthread_mutex_lock(&barrier_lock); + if (mode == MEMBERSHIP && !strcmp(event, "retire_locked")) { + retiring = 1; + pthread_cond_broadcast(&barrier); + while (!released) pthread_cond_wait(&barrier, &barrier_lock); + } else if (mode == MEMBERSHIP && !strcmp(event, "create_waiting")) { + creating = 1; + pthread_cond_broadcast(&barrier); + } else if (mode == WORK && !strcmp(event, "executing")) { + executing = 1; + pthread_cond_broadcast(&barrier); + while (!released) pthread_cond_wait(&barrier, &barrier_lock); + } else if (mode == WORK && !strcmp(event, "retire_waiting")) { + retiring = 1; + pthread_cond_broadcast(&barrier); + } + pthread_mutex_unlock(&barrier_lock); +} + +static void wait_event(int *event) { + pthread_mutex_lock(&barrier_lock); + while (!*event) pthread_cond_wait(&barrier, &barrier_lock); + pthread_mutex_unlock(&barrier_lock); +} + +static void release_barrier(void) { + pthread_mutex_lock(&barrier_lock); + released = 1; + pthread_cond_broadcast(&barrier); + pthread_mutex_unlock(&barrier_lock); +} + +static void io(int fd, void *data, size_t size, int writing) { + size_t offset = 0; + while (offset < size) { + ssize_t n = writing ? write(fd, (char *)data + offset, size - offset) + : read(fd, (char *)data + offset, size - offset); + assert(n > 0); + offset += (size_t)n; + } +} + +struct endpoint { struct ibv_context *ctx; struct ibv_pd *pd; struct ibv_cq *cq; struct ibv_qp *qp; uint8_t gid[16]; }; +static struct endpoint endpoint(unsigned id) { + struct endpoint e = {0}; + e.gid[15] = (uint8_t)id; + char error[256], name[32]; + assert(!sccl_emu_attach(error, sizeof error)); + snprintf(name, sizeof name, "lifetime%u", id); + assert(sccl_emu_add_device(name, e.gid) >= 0); + e.ctx = sircl_core_open_named_device(name); assert(e.ctx); + e.pd = sircl_core_alloc_pd(e.ctx); assert(e.pd); + e.cq = sircl_core_create_cq(e.ctx, 32); assert(e.cq); + e.qp = sircl_core_create_rc_qp(e.pd, e.cq, 32, 16); assert(e.qp); + return e; +} + +static void connect_qp(struct endpoint *e, uint32_t peer, const uint8_t *gid) { + assert(!sircl_core_qp_init(e->qp, 1, IBV_ACCESS_REMOTE_WRITE)); + struct sircl_core_qp_peer remote = {.qpn = peer, .mtu = IBV_MTU_4096, .port = 1, .hop_limit = 64}; + memcpy(remote.gid, gid, 16); + assert(!sircl_core_qp_rtr(e->qp, &remote)); + assert(!sircl_core_qp_rts(e->qp, 14, 7)); +} + +static void completion(struct endpoint *e) { + struct ibv_wc wc; + int n = 0; + for (int i = 0; i < 10000 && !n; ++i) { + n = sircl_core_poll_cq(e->cq, 1, &wc); + if (!n) usleep(100); + } + assert(n == 1 && wc.status == IBV_WC_SUCCESS); +} + +static void cleanup(struct endpoint *e) { + assert(!sircl_core_destroy_qp(e->qp)); + assert(!sircl_core_destroy_cq(e->cq)); + assert(!sircl_core_dealloc_pd(e->pd)); + assert(!sircl_core_close_device(e->ctx)); +} + +struct region { uint64_t address; uint32_t key; }; +static void mapping_lifetimes(void) { + int forward[2], back[2]; + assert(!pipe(forward) && !pipe(back)); + pid_t child = fork(); assert(child >= 0); + if (!child) { + close(forward[1]); close(back[0]); + struct endpoint e = endpoint(2); + io(back[1], &e.qp->qp_num, sizeof(uint32_t), 1); + uint32_t peer; io(forward[0], &peer, sizeof peer, 0); + uint8_t gid[16] = {0}; gid[15] = 1; + connect_qp(&e, peer, gid); + for (unsigned i = 0; i < 530; ++i) { + char error[256]; + uint32_t *mem = sccl_emu_segment_alloc(4096, error, sizeof error); assert(mem); + struct ibv_mr *mr = sircl_core_reg_mr(e.pd, mem, 4096, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); assert(mr); + struct region r = {(uintptr_t)mem, mr->rkey}; + io(back[1], &r, sizeof r, 1); + uint32_t expected; io(forward[0], &expected, sizeof expected, 0); + assert(*mem == expected); + assert(!sircl_core_dereg_mr(mr)); + sccl_emu_segment_free(mem); + } + cleanup(&e); + _exit(0); + } + close(forward[0]); close(back[1]); + struct endpoint e = endpoint(1); + uint32_t peer; io(back[0], &peer, sizeof peer, 0); + io(forward[1], &e.qp->qp_num, sizeof(uint32_t), 1); + uint8_t gid[16] = {0}; gid[15] = 2; + connect_qp(&e, peer, gid); + for (unsigned i = 0; i < 530; ++i) { + struct region r; io(back[0], &r, sizeof r, 0); + uint32_t value = i + 1; + assert(!sircl_core_post_write(e.qp, (uintptr_t)&value, 0, 4, r.address, r.key, + IBV_SEND_INLINE | IBV_SEND_SIGNALED, i)); + completion(&e); + io(forward[1], &value, sizeof value, 1); + } + char error[256]; + void *owned = sccl_emu_segment_alloc(4096, error, sizeof error); assert(owned); + sccl_emu_segment_free(owned); + cleanup(&e); + int status; assert(waitpid(child, &status, 0) == child && WIFEXITED(status) && !WEXITSTATUS(status)); + close(forward[1]); close(back[0]); +} + +static void *retire(void *arg) { assert(!sircl_core_destroy_qp(arg)); return NULL; } +static void *create(void *arg) { + struct endpoint *e = arg; + e->qp = sircl_core_create_rc_qp(e->pd, e->cq, 32, 16); assert(e->qp); + return NULL; +} + +static void worker_lifetime(void) { + struct endpoint e = endpoint(3); + struct ibv_qp *original = e.qp; + pthread_t destroying, creator; + mode = MEMBERSHIP; + assert(!pthread_create(&destroying, NULL, retire, original)); + wait_event(&retiring); + assert(!pthread_create(&creator, NULL, create, &e)); + wait_event(&creating); + release_barrier(); + assert(!pthread_join(destroying, NULL) && !pthread_join(creator, NULL)); + mode = NORMAL; + connect_qp(&e, e.qp->qp_num, e.gid); + char error[256]; + uint32_t *mem = sccl_emu_segment_alloc(4096, error, sizeof error); assert(mem); + struct ibv_mr *mr = sircl_core_reg_mr(e.pd, mem, 4096, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); assert(mr); + mem[0] = 73; + assert(!sircl_core_post_write(e.qp, (uintptr_t)mem, mr->lkey, 4, (uintptr_t)(mem + 1), mr->rkey, IBV_SEND_SIGNALED, 1)); + completion(&e); assert(mem[1] == 73); + struct ibv_qp *keeper = sircl_core_create_rc_qp(e.pd, e.cq, 32, 16); assert(keeper); + pthread_mutex_lock(&barrier_lock); + mode = WORK; retiring = executing = released = 0; + pthread_mutex_unlock(&barrier_lock); + assert(!sircl_core_post_write(e.qp, (uintptr_t)mem, mr->lkey, 4, (uintptr_t)(mem + 1), mr->rkey, IBV_SEND_SIGNALED, 2)); + wait_event(&executing); + assert(!pthread_create(&destroying, NULL, retire, e.qp)); + wait_event(&retiring); + assert(pthread_tryjoin_np(destroying, NULL) == EBUSY); + release_barrier(); + assert(!pthread_join(destroying, NULL)); + completion(&e); + mode = NORMAL; + e.qp = keeper; + assert(!sircl_core_dereg_mr(mr)); sccl_emu_segment_free(mem); + cleanup(&e); +} + +int main(void) { + char fabric[80]; snprintf(fabric, sizeof fabric, "/sircl-lifetime-%d", (int)getpid()); + assert(!setenv("SIRCL_EMU_FABRIC", fabric, 1)); + mapping_lifetimes(); + worker_lifetime(); + assert(!shm_unlink(fabric)); + puts("emulator: 530 remote lifetimes, serialized membership and work retirement exact"); + return 0; +} diff --git a/transport-core/tests/test_planning.py b/transport-core/tests/test_planning.py index 4179eca..41df6b7 100644 --- a/transport-core/tests/test_planning.py +++ b/transport-core/tests/test_planning.py @@ -63,6 +63,17 @@ def test_topology_rejects_cable_capacity_overflow(self): self.assertEqual(self.lib.sircl_core_topology_parse(str(f).encode(), out, error, len(error)), -1) self.assertIn(b"too many cables", error.value) + def test_topology_rejects_ambiguous_ports_and_duplicate_hosts(self): + for text, expected in ( + ("hosts a b c\ncabling explicit\ncable 0.port0 1.port1\ncable 0.port0 2.port1\n", b"port more than once"), + ("hosts a a\ncabling path\n", b"host twice")): + path = self.root / "invalid.topology" + path.write_text(text) + out = ctypes.create_string_buffer(16384) + error = ctypes.create_string_buffer(256) + self.assertEqual(self.lib.sircl_core_topology_parse(str(path).encode(), out, error, len(error)), -1) + self.assertIn(expected, error.value) + if __name__ == "__main__": unittest.main() From 4e510a69b077b0ecb12eb9533b9addfec374250a Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 01:38:57 -0500 Subject: [PATCH 03/12] Reconcile resource removal through the shared ownership policy Use one resource delta pipeline for apply, restoration and removal, preserving stale-resource and adoption rules. Honor explicit hostname policy in generated scripts and retain HostState positional argument compatibility. Validation: all 144 fabric tests pass, including generated service dispatch, restoration policy and unrelated-filter preservation. --- fabric-tool/fabric_tool/boot.py | 6 +- fabric-tool/fabric_tool/diff.py | 79 +++++++------------ fabric-tool/fabric_tool/state.py | 2 +- fabric-tool/tests/test_operation_contracts.py | 65 +++++++++++++++ 4 files changed, 97 insertions(+), 55 deletions(-) diff --git a/fabric-tool/fabric_tool/boot.py b/fabric-tool/fabric_tool/boot.py index 6fffea8..baeadba 100644 --- a/fabric-tool/fabric_tool/boot.py +++ b/fabric-tool/fabric_tool/boot.py @@ -3,7 +3,7 @@ ``install-boot`` writes the unit ``fabric-table.service``, copies the topology file and the facts document to ``/etc/fabric-table/``, enables the unit and installs the table now; ``remove-boot`` disables and removes both. The unit -runs ``apply --boot``, whose restore semantics add every missing object and +runs ``apply --boot --execute``, whose restore semantics add every missing object and remove nothing, so a boot either reinstalls the whole table (``/run`` is cleared, interfaces and their routes and filters come up empty, markers are gone) or changes nothing while the table stands. @@ -16,7 +16,7 @@ import subprocess from pathlib import Path -from . import commands +from . import commands, model UNIT_NAME = "fabric-table.service" INPUT_DIR = "/etc/fabric-table" @@ -33,7 +33,7 @@ class RestoreInvocation: tool: str = DEFAULT_TOOL marker: str = commands.DEFAULT_MARKER - max_relays: int = 3 + max_relays: int = model.DEFAULT_MAX_RELAYS host: str | None = None skip_hostname_check: bool = False diff --git a/fabric-tool/fabric_tool/diff.py b/fabric-tool/fabric_tool/diff.py index 7db8cd3..b47edf6 100644 --- a/fabric-tool/fabric_tool/diff.py +++ b/fabric-tool/fabric_tool/diff.py @@ -110,14 +110,15 @@ class _Script: qdisc_del: list[str] = dataclasses.field(default_factory=list) record: list[str] = dataclasses.field(default_factory=list) - def lines(self, hostname: str) -> list[str]: + def lines(self, hostname: str, *, check_hostname: bool = True) -> list[str]: body = (self.qdisc_add + self.filter_del + self.filter_add + self.neigh_set + self.route_set + self.marker_stop + self.marker_start + self.route_del + self.neigh_del + self.qdisc_del + self.record) if not body: return [] settle = [commands.SETTLE] if self.marker_start else [] - return [commands.HEADER, commands.guard(hostname), *body, *settle] + guard = [commands.guard(hostname)] if check_hostname else [] + return [commands.HEADER, *guard, *body, *settle] def _route_equal(entry: RouteEntry, destination: str, netdev: str, source: str) -> bool: @@ -245,23 +246,25 @@ class ReconcilePolicy: mode: str remove_stale: bool require_adoption: bool + persist_record: bool = True APPLY = ReconcilePolicy("up", True, True) RESTORE = ReconcilePolicy("boot", False, False) +REMOVE = ReconcilePolicy("down", True, True, False) def compare_up(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name: str, marker: commands.MarkerConfig, adopt: bool, check_hostname: bool = True) -> HostDiff: """Reconcile desired resources and remove stale owned resources.""" return _reconcile(state, host, plan, layout_name=layout_name, marker=marker, - adopt=adopt, check_hostname=check_hostname, policy=APPLY) + adopt=adopt, check_hostname=check_hostname, policy=APPLY, group=plan.group.label) -def _reconcile(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name: str, - marker: commands.MarkerConfig, adopt: bool, check_hostname: bool, policy: ReconcilePolicy) -> HostDiff: +def _reconcile(state: HostState, host: HostPlan, plan: GroupPlan | None, *, layout_name: str, + marker: commands.MarkerConfig, adopt: bool, check_hostname: bool, policy: ReconcilePolicy, group: str) -> HostDiff: """What ``apply`` changes on one host to install its group's plan.""" - diff = HostDiff(host.position, host.name, plan.group.label, policy.mode) + diff = HostDiff(host.position, host.name, group, policy.mode) if _common_blockers(diff, state, check_hostname=check_hostname): return diff script = _Script() @@ -293,7 +296,7 @@ def _reconcile(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name before = "; ".join(entry.text() for entry in entries) diff.changes.append(Change("filter", "replace" if entries else "add", f"{netdev} pref {pref}", f"{before} -> {wanted}" if entries else wanted)) - for pref, entries in sorted(present.items()) if policy.remove_stale else (): + for pref, entries in sorted(present.items()) if policy.remove_stale else (): script.filter_del.extend(_filter_removal(entries, state.bindings)) removed_filters[netdev] += len(entries) diff.changes.append(Change("filter", "remove", f"{netdev} pref {pref}", @@ -361,7 +364,7 @@ def _reconcile(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name _marker_changes(diff, script, state, host, marker) # Qdiscs the record lists as added by the tool and that no filter needs any more. - record = state.record if state.record and state.record.get("group") == plan.group.label else None + record = state.record if state.record and state.record.get("group") == group else None recorded = set(record.get("qdiscs", [])) if record else set() kept = set(added_qdiscs) | recorded for netdev in sorted(recorded) if policy.remove_stale else (): @@ -370,64 +373,38 @@ def _reconcile(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name script.qdisc_del.append(commands.qdisc_del(netdev, bindings=state.bindings)) kept.discard(netdev) diff.changes.append(Change("qdisc", "remove", netdev, "ingress qdisc added by the tool")) - wanted_record = _record(host, plan, layout_name, marker, sorted(kept)) + wanted_record = None + if policy.persist_record: + assert plan is not None + wanted_record = _record(host, plan, layout_name, marker, sorted(kept)) if state.record != wanted_record: - script.record.extend(commands.record_write(wanted_record)) - before = (f"group {state.record.get('group')}, plan {state.record.get('plan')}" if state.record - else "none") - diff.changes.append(Change("record", "write", commands.RECORD_PATH, - f"{before} -> group {plan.group.label}, layout {layout_name}, plan {plan.digest}")) + if wanted_record is None: + script.record.append(commands.record_remove()) + diff.changes.append(Change("record", "remove", commands.RECORD_PATH, f"group {group}")) + else: + script.record.extend(commands.record_write(wanted_record)) + before = f"group {state.record.get('group')}" if state.record else "none" + diff.changes.append(Change("record", "write", commands.RECORD_PATH, + f"{before} -> group {group}, layout {layout_name}, plan {plan.digest}")) for entry in state.foreign_tag_filters(): diff.notes.append(f"a filter outside the reserved preferences matches relay tag 0x{entry.protocol:04x}: " f"{entry.text()}") if policy.require_adoption: _adopt_blocker(diff, adopt) - diff.commands = script.lines(host.name) if diff.pending else [] + diff.commands = script.lines(host.name, check_hostname=check_hostname) if diff.pending else [] return diff def compare_down(state: HostState, *, group: str, marker: commands.MarkerConfig, adopt: bool, check_hostname: bool = True) -> HostDiff: """What ``remove`` deletes from one host: every object the tool owns there.""" - diff = HostDiff(state.position, state.name, group, "down") - if _common_blockers(diff, state, check_hostname=check_hostname): - return diff - script = _Script() - removed_filters = {netdev: 0 for netdev in state.bindings.netdevs} - for netdev in state.bindings.netdevs: - present: dict[int, list[FilterEntry]] = {} - for entry in state.reserved_filters(netdev): - present.setdefault(entry.pref, []).append(entry) - for pref, entries in sorted(present.items()): - script.filter_del.extend(_filter_removal(entries, state.bindings)) - removed_filters[netdev] += len(entries) - diff.changes.append(Change("filter", "remove", f"{netdev} pref {pref}", - "; ".join(entry.text() for entry in entries))) - for entry in state.relay_routes(): - script.route_del.append(_route_removal(entry, state.bindings)) - diff.changes.append(Change("route", "remove", f"{entry.destination}/32", entry.text(), not entry.owned)) - for entry in state.relay_neighbours(): - script.neigh_del.append(commands.neigh_del(entry.destination, entry.dev, bindings=state.bindings)) - diff.changes.append(Change("neighbour", "remove", f"{entry.destination} dev {entry.dev}", entry.text(), - not entry.owned)) - _marker_changes(diff, script, state, None, marker) - recorded = set(state.record.get("qdiscs", [])) if state.record else set() - for netdev in sorted(recorded): - remaining = len(state.filters.get(netdev, [])) - removed_filters.get(netdev, 0) - if remaining <= 0 and state.ingress_qdisc.get(netdev) == "ingress": - script.qdisc_del.append(commands.qdisc_del(netdev, bindings=state.bindings)) - diff.changes.append(Change("qdisc", "remove", netdev, "ingress qdisc added by the tool")) - if state.record is not None: - script.record.append(commands.record_remove()) - diff.changes.append(Change("record", "remove", commands.RECORD_PATH, - f"group {state.record.get('group')}, plan {state.record.get('plan')}")) - _adopt_blocker(diff, adopt) - diff.commands = script.lines(state.name) if diff.pending else [] - return diff + desired = HostPlan(state.position, state.name, group, (), (), state.bindings) + return _reconcile(state, desired, None, layout_name="", marker=marker, adopt=adopt, + check_hostname=check_hostname, policy=REMOVE, group=group) def compare_boot(state: HostState, host: HostPlan, plan: GroupPlan, *, layout_name: str, marker: commands.MarkerConfig, adopt: bool, check_hostname: bool = True) -> HostDiff: """Restore desired objects while retaining stale and foreign resources.""" return _reconcile(state, host, plan, layout_name=layout_name, marker=marker, - adopt=adopt, check_hostname=check_hostname, policy=RESTORE) + adopt=adopt, check_hostname=check_hostname, policy=RESTORE, group=plan.group.label) diff --git a/fabric-tool/fabric_tool/state.py b/fabric-tool/fabric_tool/state.py index 020eec4..91fbd9d 100644 --- a/fabric-tool/fabric_tool/state.py +++ b/fabric-tool/fabric_tool/state.py @@ -422,7 +422,6 @@ class HostState: name: str ssh: str reachable: bool - bindings: model.FabricBindings = model.DEFAULT_BINDINGS error: str = "" hostname: str = "" versions: str = "" @@ -442,6 +441,7 @@ class HostState: sparkring_record: dict | None = None raw: dict[str, str] = dataclasses.field(default_factory=dict) parse_problems: list[str] = dataclasses.field(default_factory=list) + bindings: model.FabricBindings = model.DEFAULT_BINDINGS # -- facts -- diff --git a/fabric-tool/tests/test_operation_contracts.py b/fabric-tool/tests/test_operation_contracts.py index 79ea40b..799f04a 100644 --- a/fabric-tool/tests/test_operation_contracts.py +++ b/fabric-tool/tests/test_operation_contracts.py @@ -7,6 +7,7 @@ from fabric_tool import boot, cli, commands, diff, facts, model, ops, plan, state, topology from test_facts import _document, RING4 +from test_marker_security import environment def custom_document(): @@ -85,3 +86,67 @@ def test_systemd_argument_escaping(): assert boot.systemd_arg('a%$"\\b') == '"a%%$$\\"\\\\b"' with pytest.raises(ValueError, match='control characters'): boot.systemd_arg('line\nbreak') + + +def test_restore_honors_explicit_hostname_policy(): + topo = topology.parse(RING4) + built = plan.build_plan(topo.group, facts.bind(_document(), topo)) + host = built.hosts[0] + observed = state.HostState(host.position, host.name, '', True, hostname='different-host') + arguments = dict(layout_name=topo.group.name, marker=commands.MarkerConfig(), adopt=False) + guarded = diff.compare_boot(observed, host, built, **arguments) + assert any('different-host' in blocker for blocker in guarded.blockers) + permitted = diff.compare_boot(observed, host, built, check_hostname=False, **arguments) + assert not any('different-host' in blocker for blocker in permitted.blockers) + assert '$(hostname)' not in (permitted.script or '') + + +@pytest.mark.parametrize('mode,removes_stale', [('up', True), ('boot', False), ('down', True)]) +def test_resource_policy_preserves_restoration_and_removal_contracts(mode, removes_stale): + topo = topology.parse(RING4) + built = plan.build_plan(topo.group, facts.bind(_document(), topo)) + host = built.hosts[0] + observed = state.HostState(host.position, host.name, '', True, hostname=host.name) + observed.routes.append(state.RouteEntry('198.51.100.19', 32, host.bindings.netdevs[0], + '192.0.2.1', 'link', 82, '82', 0, None, 'unicast')) + marker = commands.MarkerConfig() + if mode == 'down': + result = diff.compare_down(observed, group=topo.group.label, marker=marker, adopt=False) + else: + compare = diff.compare_up if mode == 'up' else diff.compare_boot + result = compare(observed, host, built, layout_name=topo.group.name, marker=marker, adopt=False) + removed = any(change.kind == 'route' and change.action == 'remove' and + change.key == '198.51.100.19/32' for change in result.changes) + assert removed == removes_stale + + +def test_remove_preserves_owned_qdisc_with_unrelated_filters(): + marker = commands.MarkerConfig() + observed = state.HostState(0, 'node-0', '', True, hostname='node-0') + device = observed.bindings.netdevs[0] + observed.record = {'group': 'path:0-1', 'qdiscs': [device]} + observed.ingress_qdisc[device] = 'ingress' + observed.filters[device] = [state.FilterEntry(device, 99, 0, 'flower', 0x0800, 1, + True, True, None, None, None, None)] + result = diff.compare_down(observed, group='path:0-1', marker=marker, adopt=False) + assert not any(change.kind == 'qdisc' and change.action == 'remove' for change in result.changes) + + +def test_service_invocation_dispatches_restoration(environment, tmp_path, monkeypatch): + _, _, _, arguments = environment + topology_path = arguments[arguments.index('--topology') + 1] + facts_path = tmp_path / 'boot-facts.json' + facts_path.write_text(json.dumps(_document())) + monkeypatch.setattr(boot, 'TOPOLOGY_INPUT', topology_path) + monkeypatch.setattr(boot, 'FACTS_INPUT', str(facts_path)) + monkeypatch.setattr(cli, '_route_check', lambda *args, **kwargs: 0) + service = boot.unit_text(invocation=boot.RestoreInvocation(host='node-0')) + argv = shlex.split(next(line[len('ExecStart='):] for line in service.splitlines() + if line.startswith('ExecStart='))) + class RestorationDispatched(Exception): + pass + def executor(target, script, timeout): + assert 'sudo -n tc filter add' in script + raise RestorationDispatched() + with pytest.raises(RestorationDispatched): + cli.main(argv[1:], executor=executor) From cf2301c086bd38207b595738d263ea5f8c237387 Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 01:38:57 -0500 Subject: [PATCH 04/12] Verify archive privacy and state qualification by source identity Scan extracted source without Git metadata, enforce confined regular files, and provide a complete distributed-source manifest updater. Record hardware evidence by revision and conditions; remove stale teardown guidance and references to absent components. Validation: seven release checks pass, both source scans report zero findings, extracted source builds and staged fabric-tool planning succeed. --- .github/workflows/ci.yml | 1 + README.md | 5 ++-- SOURCE.json | 6 ++--- docs/configuration.md | 12 +++++---- docs/fabric.md | 10 +++---- docs/measurements.md | 17 +++++------- docs/qualification.md | 28 ++++++++++++++++++++ docs/testing.md | 23 +++++++++++----- docs/transport-core.md | 35 ++++++++++++++++++++---- fabric-tool/DESIGN.md | 25 +++++++++++++++--- fabric-tool/HARDWARE-TEST-PLAN.md | 12 ++++----- fabric-tool/README.md | 12 +++++---- fabric-tool/fabric_tool/__init__.py | 10 +++---- net-sircl/net_sircl_admission.h | 1 - net-sircl/net_sircl_config.h | 1 - scripts/check_release_safety.py | 33 ++++++++++++++++++++--- scripts/update_source_manifest.py | 23 ++++++++++++++++ tests/test_release_safety.py | 41 +++++++++++++++++++++++++++++ transport-core/src/shm_memory.c | 1 - 19 files changed, 233 insertions(+), 63 deletions(-) create mode 100644 docs/qualification.md create mode 100644 scripts/update_source_manifest.py create mode 100644 tests/test_release_safety.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fb84b3..124429a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,7 @@ jobs: run: | mkdir "$RUNNER_TEMP/net-sircl-source" tar -xzf dist/net-sircl-0.1.2.tar.gz -C "$RUNNER_TEMP/net-sircl-source" + python3 scripts/check_release_safety.py --tree "$RUNNER_TEMP/net-sircl-source" make -C "$RUNNER_TEMP/net-sircl-source" -j2 all emu make -C "$RUNNER_TEMP/net-sircl-source" check - name: Check installed fabric entry point diff --git a/README.md b/README.md index 79ff37e..a80e92c 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,9 @@ it with no code changes, and NCCL keeps its own collective algorithms and CUDA-graph support. Version **0.1.2**, wire version **6** (every host in a job must use the same -wire version). Research-only; hardware-qualified on DGX Sparks under the -conditions in the [release notes](RELEASE_NOTES-0.1.2.md). +wire version). Status: **research-only**. The [qualification table](docs/qualification.md) +identifies the exact source revisions and conditions of recorded DGX Spark +results; modified source builds require separate hardware qualification. ## What it does diff --git a/SOURCE.json b/SOURCE.json index c51069c..ff244f9 100644 --- a/SOURCE.json +++ b/SOURCE.json @@ -140,9 +140,9 @@ "net-sircl/nccl/types.h": "204015ef7865117da6d643307d81df8f16736ccde3762e5110de516b34983890", "net-sircl/net_sircl.c": "8c1fb7ea5d6930946a9689a6810a1b282e3d5fe25a4da56776e846a3be37fca6", "net-sircl/net_sircl.h": "edf9ea26f9c3efd22a514233004b9a0771da16dc55a627ae5ed5e834cd3fe746", - "net-sircl/net_sircl_admission.h": "ecb9ea2dcbd7eb43d4162ee0992899787c35767477d9c98c2139822645464173", + "net-sircl/net_sircl_admission.h": "6e92a7e07863fc7667f1db549ac89761a34a4a372388497915fb6c362fea1409", "net-sircl/net_sircl_compat.h": "0053800750c2f061a1254d1db95e65e4317de000c1b52873c0fe2cec9afafdf9", - "net-sircl/net_sircl_config.h": "9aad3e63d9030dc03d70e132fc9fddaf5609966fa5a154c59e341ef21325c28f", + "net-sircl/net_sircl_config.h": "6d6a3e6eeb697ec652177bea148e3ba9ce80e1ecc11e17820768c19b72c1ed85", "net-sircl/net_sircl_connection.h": "4e323cb1900aea927febf0f20f68dbb2e2eef05f0d99107febc6cf78ad5ebd96", "net-sircl/net_sircl_plan.c": "6fc1f03374562864b5b5898a54f4b2cf471e6d11003af83839e0f5a1f777e856", "net-sircl/net_sircl_plan.h": "dcb857dce8247ff61756e216e90cfd40c6ce3a2b24f5e990b39ec561d2169526", @@ -173,7 +173,7 @@ "transport-core/include/sircl_fabric.h": "5960d6fe55fba8c8f32a00bf747aecfd3a4b018db8248ce5134f75bd95843ebb", "transport-core/src/core.c": "3d32d0d6d58a2874573a3ba1ea1efddb5a96cbfc45b2bfd89e451fbd952549ef", "transport-core/src/fabric.c": "edc6a98d8a8e1524ea502fade00b07467b57f299911ea8642b74a479497465b9", - "transport-core/src/shm_memory.c": "cacba720864ea531af0df6a25fe018c3a7bad682d632a6b6ae9ed4f43612ccf8", + "transport-core/src/shm_memory.c": "4fcd9767b2e999d363b78100e360a84d9054edf4b65d3177db96cd4e9e263d4c", "transport-core/src/shm_memory.h": "a7d4857229d5b0f8522f8d545de5c89bbc8c75bfebb0022db9e9ba9fb4a04189", "transport-core/src/shm_verbs.c": "88d7237b5059e751f2ef38c02a805b29505de5dd3afcfdbca496866f5cbdcb80", "transport-core/src/sysfs.c": "747062778a2cab1744d43e602c724b1887ad6ba66428d62ee892b351f7f5b7c2", diff --git a/docs/configuration.md b/docs/configuration.md index c198459..2e9646f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -131,9 +131,11 @@ Use [the hardware check](../examples/torch_teardown.py) under an outer 150-secon job timeout. It checks eight eager all-reduce sizes and 20 graph replays, releases the graph, then enforces a separate 15-second teardown bound. -The 0.1.1 hardware T1 script retained its graph. The same ordering reproduces on -the workstation with both transports; resetting the graph lets both exit. NCCL +Graph references must be released before communicator destruction. NCCL 2.32.3's [commDestroySync](https://github.com/NVIDIA/nccl/blob/v2.32.3-1/src/init.cc#L3122) -waits for graph references before stopping proxy threads and closing the network. -This fixes the test/application lifetime; it does not establish that all hardware -teardown failures have been resolved. The corrected T1 still needs the ring8c run. +waits for those references before stopping proxy threads and closing the network. +The recorded four-host path check passed nine exact checks per rank and reported +0.54–0.68 seconds for destruction, with `PASS` and exit 0 on all ranks. +The [qualification table](qualification.md) identifies the source revision and +conditions for that result. Other graph lifetimes and modified plugin builds +require their own validation; this result is not a guarantee for every teardown. diff --git a/docs/fabric.md b/docs/fabric.md index f47b813..759be86 100644 --- a/docs/fabric.md +++ b/docs/fabric.md @@ -143,11 +143,11 @@ relays and the tool copy; use `remove` for live relays. ## Validation boundary -Status: research-only. An earlier revision installed and verified ring and -path tables on a ring of four DGX Sparks, passed plugin test arms on the path -table, removed its table and restored SparkRing's table. Two defects found -during that exercise were fixed afterwards on CPU; this fixed version has not -yet been rerun on hardware. See the [release notes](release-0.1.0.md). +Status: research-only. Relay planning, command generation, ownership checks +and restoration policy have CPU regression checks. Physical forwarding and +restoration after a reboot require the hardware procedure. The +[qualification table](qualification.md) identifies the source and conditions +of recorded hardware evidence. Standalone tests cover planning, facts, generated Bash scripts, marker security, boot previews and mocked boot operations. They do not simulate an entire network or establish reboot restoration. See [testing and CI](testing.md), diff --git a/docs/measurements.md b/docs/measurements.md index 60a8d27..2388d75 100644 --- a/docs/measurements.md +++ b/docs/measurements.md @@ -1,15 +1,12 @@ # Historical 0.1.0 measurements -These records describe the 0.1.0 transport. See the -[0.1.1 release notes](../RELEASE_NOTES-0.1.1.md) for wire-6 candidate measurements -and the pending final-pass record. Historical byte-equality claims below apply -to 0.1.0, not to the 0.1.1 tree. - -These are research-only communication measurements on DGX Spark GB10, not -serving qualification or throughput guarantees. The measured plugin builds -used transport C sources and NVIDIA headers byte-identical to this release -([SOURCE.json](../SOURCE.json)), with a different plugin version string. -The 0.1.0 library itself has not run on Sparks. Raw logs are not published +These records describe the 0.1.0 transport. The source bytes associated with +these measurements are identified by the historical 0.1.0 hash inventory in +[SOURCE.json](../SOURCE.json). They do not qualify modified plugin builds. +The [qualification table](qualification.md) links the 0.1.1 and 0.1.2 evidence. + +Status: research-only. These are communication measurements on DGX Spark GB10, +not serving qualification or throughput guarantees. Raw logs are not published because they contain site-specific host information. ## Conditions diff --git a/docs/qualification.md b/docs/qualification.md new file mode 100644 index 0000000..7469dfa --- /dev/null +++ b/docs/qualification.md @@ -0,0 +1,28 @@ +# Qualification evidence + +Status: **research-only**. Hardware results apply to the recorded source revision, +topology and workload. They do not qualify a binary built from different source +bytes, even when its component version strings match. + +| Component and source identity | Conditions | Measurement and result | Qualification limit | +|---|---|---|---| +| Plugin 0.1.2, source revision `bd61460fdb03d52fe2f1e6ce685f4437b98c50b9` | Four DGX Sparks in a path; NCCL 2.32.3; PyTorch eager and CUDA graphs; graph references released before destruction | Nine exact checks per rank; destruction 0.54–0.68 seconds; `PASS` and exit 0 on all four ranks | Qualified for that recorded check; not every graph lifetime or serving workload | +| Plugin 0.1.2, same source revision | Eight-Spark ring; automatic collective channel policy | Eight active operation channels; CUDA-graph all-reduce sweep completed in 36.7 seconds | Qualified for the recorded workload and cabling; not a throughput guarantee | +| Framework integrations using plugin 0.1.1 | Versions and topologies listed in the root README framework matrix; one GPU and rank per host | Correct results, unchanged error counters and independent rank exit in single runs | Research-only; integration results do not qualify modified plugin builds | +| Fabric configuration tool | CPU planning, synthetic host observations and generated command checks | Software contracts for ownership, command forms, input validation and restoration policy | Implemented; physical forwarding and actual reboot restoration require `fabric-tool/HARDWARE-TEST-PLAN.md` | +| Shared-memory verbs emulator | Processes of one Linux host; no physical NIC or relay | Exact data movement, bounded admission, worker retirement and mapping-lifetime checks | Implemented test infrastructure; physical loss recovery and NIC performance unsupported | +| Distributed source manifest `SOURCE.json`, field `source_sha256` | Every distributed C/C++ source and header, including the marker and tests | Hash equality and inventory completeness checked by release tests | Implemented provenance check; source equality alone is not hardware qualification | + +The plugin measurement records are in +[release 0.1.2](../RELEASE_NOTES-0.1.2.md), +[release 0.1.1](../RELEASE_NOTES-0.1.1.md) and +[historical 0.1.0 measurements](measurements.md). These are explicitly historical +records. Operational requirements belong in [configuration](configuration.md), +[fabric setup](fabric.md) and [testing](testing.md). + +For a hardware qualification, record the source commit, complete distributed +source manifest, compiled-library SHA-256, topology, GPU/NIC/driver/firmware/OS +versions, NCCL/framework versions, environment, clocks, workload, independent +rank exits, correctness checks, error-counter deltas and individual timing +measurements. Keep site-specific identifiers in private logs; publish sanitized +conditions and bounded conclusions. diff --git a/docs/testing.md b/docs/testing.md index 805b6e2..508bf5d 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -14,8 +14,9 @@ make check-release real-NIC plugin and the packet marker. `make emu` builds the shared-memory test plugin. `make check` runs: -- transport-core: two C test executables for concurrent window arithmetic, abort/progress - callbacks and emulated verbs, plus four Python discovery/topology tests. +- transport-core: three C test executables for concurrent window arithmetic, abort/progress + callbacks, emulated verbs and barrier-controlled executor/mapping lifetimes, + plus five Python discovery/topology tests. - net-sircl: Python tests, including multiprocess transfer, window, lane, teardown, peer-loss and deadline tests, fixed topology expectations and the real-NIC library's v7–v12 export check, ABI layout calls, route/ACK @@ -28,7 +29,8 @@ test plugin. `make check` runs: checkout or full-network simulator is used. These do not exercise real apply/verify/remove across hosts or restoration after an actual reboot. - Release contracts: shipped C/C++/header hashes, example routes, embedded core - identity, and archive reproducibility/completeness. The archive test creates + identity, and archive reproducibility/completeness, extracted-source privacy scanning and + complete distributed C/C++/header inventory. The archive test creates an untracked file under docs and checks that the archive still contains exactly `git ls-files`. This test skips in an extracted archive without Git metadata; the other three release tests run there. @@ -93,6 +95,8 @@ host or establish performance. See the [hardware procedure](../fabric-tool/HARDW ```sh make package python3 scripts/check_release_safety.py . +# For an extracted source archive without Git metadata: +python3 scripts/check_release_safety.py --tree EXTRACTED_DIRECTORY ``` The archive is `dist/net-sircl-0.1.2.tar.gz`, built from `git ls-files` in @@ -107,8 +111,9 @@ IPv4 addresses outside documentation/loopback ranges, user-home paths and credential-like strings. It reports locations and rule names without matched values. `--site-values FILE` adds literal host names or addresses, one per line; keep the file untracked (`scripts/config/site-values.txt` is ignored and -excluded). The scanner checks Git-tracked text; archive privacy is checked by -scanning its extracted text with the same rules. +excluded). The scanner checks Git-tracked text by default. `--tree` enumerates confined +regular files without Git metadata and refuses symbolic links. CI scans the +extracted archive before building it, using the same rules. ## Source identity @@ -116,7 +121,7 @@ The startup line `net-sircl transport-core 0.1.1 ABI 1 source ` contains a digest of transport-core's C sources, headers, Python tools and VERSION. It is not a compiled-library checksum. Removing Python adaptation tools and changing packaging or the component version changes this digest. -[SOURCE.json](../SOURCE.json) separates shipped checksums, candidate provenance +[SOURCE.json](../SOURCE.json) separates distributed source checksums, upstream provenance and immutable historical 0.1.0 measured hashes. They do not qualify this binary. See [retained compatibility code](transport-core.md#retained-compatibility-code). @@ -133,3 +138,9 @@ Use the site's GPU reservation for these commands. reproducer. CPU fault injection covers silent peers, lost completion delivery, sticky errors and bounded close. Fabric tests cover missing forwarding rules, lost `in_hw`, unreachable relays and verify blockers without contacting a host. + +The distributed source inventory is regenerated with +`python3 scripts/update_source_manifest.py`. Its test checks both hashes and +completeness, including `fabric-tool/mesh_marker.c`, private implementation +modules and C test harnesses. Updating hashes does not establish hardware +qualification; see [qualification evidence](qualification.md). diff --git a/docs/transport-core.md b/docs/transport-core.md index df5a958..c66011a 100644 --- a/docs/transport-core.md +++ b/docs/transport-core.md @@ -23,9 +23,9 @@ which must agree between hosts. ## Retained compatibility code -SOURCE.json records the shipped source hashes and the candidate hashes -separately from historical 0.1.0 measured bytes. The version macro and its -test use 0.1.1; the ABI remains 1. Some comments refer to the originating project. +`SOURCE.json` records the distributed source inventory separately from upstream +provenance and the historical 0.1.0 measurement hashes. The version macro and its +test use 0.1.1; the ABI remains 1. The component version and ABI do not identify hardware-qualified source bytes. The following code is research-only and is not part of the plugin's transport: - `transport-core/src/fabric.c` and `include/sircl_fabric.h`: collective planner @@ -34,7 +34,32 @@ The following code is research-only and is not part of the plugin's transport: dynamic verbs loader. The latter includes the former, and the core build compiles the loader. The plugin links libibverbs directly. - `transport-core/include/sircl_core/legacy_proxy_names.h`: includes proxy - renames alongside emulator renames. Frozen emulator sources and tests include - it, so the unused renames cannot be separated for this release. + renames alongside emulator renames. The emulator and tests use its verbs symbol mapping; the proxy aliases preserve + compatibility for consumers of that header. The Python proxy adapter and its external-consumer tests are not distributed. + +## Private planning and emulation contracts + +Implemented: `net-sircl/net_sircl_plan.c` constructs a deterministic validated +topology/admission plan. The plugin binds its device discovery to that result; +the CPU allocator oracle links the same planning implementation without the +plugin. The core topology parser rejects duplicate host names and multiply +connected physical ports for every caller. + +`net-sircl/net_sircl_admission.h` owns credit reservation, completion accounting, +shared-member progress, pending-request order and membership retirement. Protocol +posting reserves forward and ACK resources together. A failed unaccepted write +returns its reservation; a partial control pair retains debt and poisons progress. +Direct-peer scheduling remains distinct from relay FIFO admission. + +`transport-core/src/shm_memory.c` owns allocated segments and cached remote +mappings. Mapping leases prevent eviction while executing work uses a mapping; +inactive remote mappings are evicted when the bounded table needs a slot. +The emulator serializes worker membership transitions under one lifecycle lock. +Executing work holds QP ownership through its memory access and completion; +QP destruction waits for that work before returning. The worker never takes the +lifecycle lock, so joining it cannot wait for a lock held by the joining thread. + +The emulator remains research-only test infrastructure. Its retirement and +mapping checks establish local software contracts, not NIC or relay behavior. diff --git a/fabric-tool/DESIGN.md b/fabric-tool/DESIGN.md index 3cff52d..eb8c2ec 100644 --- a/fabric-tool/DESIGN.md +++ b/fabric-tool/DESIGN.md @@ -37,9 +37,9 @@ is a oneshot operation rather than marker supervision. See the installed guide `share/doc/net-sircl/docs/fabric.md` for the relay mechanism and command sequence. `HARDWARE-TEST-PLAN.md` describes hardware -qualification. An earlier revision ran the ring/path table exercise on four -DGX Sparks; the script fixes in this version have only been tested on CPU. -The tool remains research-only. Standalone tests cover planning, facts, command forms, +qualification. Status: research-only. Recorded hardware evidence and its +source identities are listed in `../docs/qualification.md`. +Standalone tests cover planning, facts, command forms, boot previews and mocked boot operations; full-network simulation and comparison tests that require another project are not distributed. @@ -70,3 +70,22 @@ the detached root shell creates the log and redirects marker stdout and stderr there. The SSH caller can finish without waiting for the long-lived marker. Standalone Bash regression tests check digest/ownership parsing and require the caller's captured output to close before a simulated marker exits. + +## Configuration and reconciliation ownership + +Implemented: each operation resolves an immutable `FabricBindings` value before +collecting host observations. Facts, host observations and host plans retain that +value; parsing another topology does not change existing plans or reports. +Device identifiers are validated before script generation and quoted as shell +arguments. Topology parsing has no process-global side effects. + +Apply and boot restoration use one resource reconciler. Its policy controls +stale-object removal and adoption requirements. Restoration retains stale +objects; apply reconciles them. Qdisc ownership records contain only interfaces +where the tool added a qdisc, plus previously recorded ownership. Removal leaves +a pre-existing unowned qdisc intact and preserves qdiscs with unrelated filters. + +`RestoreInvocation` retains execution intent, facts, topology, marker location, +relay limit and optional host selection. The systemd unit serializes its argument +vector using systemd escaping. Offline installation uses the same reconciler +against an empty observation, rather than a separate command sequence. diff --git a/fabric-tool/HARDWARE-TEST-PLAN.md b/fabric-tool/HARDWARE-TEST-PLAN.md index 2170d3c..445ee9b 100644 --- a/fabric-tool/HARDWARE-TEST-PLAN.md +++ b/fabric-tool/HARDWARE-TEST-PLAN.md @@ -1,12 +1,10 @@ # Hardware validation of the standalone fabric tool -Status: the ring/path table exercise ran on one ring of four DGX Sparks -with an earlier revision: both tables were installed and verified, plugin test -arms passed on the path table, the tool's table was removed, and SparkRing's -table was restored. Two script defects were fixed afterwards on CPU; the fixed -version has not yet been rerun on hardware. See `docs/release-0.1.0.md` in the -repository for details. Boot restoration and the full two-ring procedure below -remain unqualified. CPU tests do not qualify real forwarding or boot restoration. +Status: research-only. This procedure qualifies physical forwarding, resource +ownership and actual boot restoration of the exact source and binary under test. +The recorded table exercise is scoped in `../docs/release-0.1.0.md`; source +identities and measurement limits are listed in `../docs/qualification.md`. +CPU tests establish software contracts, not real forwarding or boot restoration. Use placeholders `node-0` through `node-3` for one ring and `node-4` through `node-7` for the other. Substitute actual host names and SSH targets privately. diff --git a/fabric-tool/README.md b/fabric-tool/README.md index 3f6e732..bb6d7a7 100644 --- a/fabric-tool/README.md +++ b/fabric-tool/README.md @@ -4,13 +4,15 @@ fabric-tool configures relays between directly cabled DGX Sparks: NIC forwarding rules on intermediate hosts, sender IP routes and neighbour entries, and a per-NIC marker process that tags outgoing RDMA packets with the number of relays to cross. It reads net-sircl's topology file. -Version **0.1.1**, Apache-2.0; derived from the SparkRing project, see +Version **0.1.2**, Apache-2.0; derived from the SparkRing project, see [LICENSE](LICENSE) and [NOTICE](NOTICE). -Status: research-only. An earlier revision installed and verified ring and -path tables on four DGX Sparks; plugin test arms passed on the path table. -The two script fixes included here are CPU-tested and have not yet been rerun -on hardware. See the repository's `docs/release-0.1.0.md` for the run's scope. +Status: research-only. The tool implements relay planning, ownership checks, +hardware-offload verification and explicit boot restoration. CPU checks qualify +these software contracts; real forwarding and reboot restoration require the +[hardware procedure](HARDWARE-TEST-PLAN.md). The repository's +[qualification table](../docs/qualification.md) identifies recorded hardware +evidence separately from the source checks. Standalone tests cover planning, facts, command forms, marker security checks, boot previews and mocked boot operations. They do not prove real NIC forwarding or reboot restoration. diff --git a/fabric-tool/fabric_tool/__init__.py b/fabric-tool/fabric_tool/__init__.py index bef8f0c..2a9424c 100644 --- a/fabric-tool/fabric_tool/__init__.py +++ b/fabric-tool/fabric_tool/__init__.py @@ -1,7 +1,7 @@ -"""Relay installer for directly cabled DGX Sparks. +"""Relay configuration for directly cabled DGX Sparks. -Derived from the SparkRing relay installer; see NOTICE. Reads a topology, -plans forwarding rules and sender routes, inspects hosts and applies changes. -Uses only Python's standard library. Research-only; the latest script fixes -have not been rerun on hardware. See HARDWARE-TEST-PLAN.md for validation scope. +Reads topology and facts, derives forwarding rules and sender routes, inspects +hosts, and reconciles explicitly owned objects. Uses Python's standard library. +Status: research-only. HARDWARE-TEST-PLAN.md defines physical qualification. +See NOTICE for SparkRing attribution. """ diff --git a/net-sircl/net_sircl_admission.h b/net-sircl/net_sircl_admission.h index 23c28e7..2feb145 100644 --- a/net-sircl/net_sircl_admission.h +++ b/net-sircl/net_sircl_admission.h @@ -205,4 +205,3 @@ static ncclResult_t poll_cq(struct comm *c) { } return ncclSuccess; } - diff --git a/net-sircl/net_sircl_config.h b/net-sircl/net_sircl_config.h index ed7b245..b0a41c0 100644 --- a/net-sircl/net_sircl_config.h +++ b/net-sircl/net_sircl_config.h @@ -200,4 +200,3 @@ int net_sircl_topology_routes(const char *path, int position, char *out, size_t } return 0; } - diff --git a/scripts/check_release_safety.py b/scripts/check_release_safety.py index 4e0009f..9c83e91 100644 --- a/scripts/check_release_safety.py +++ b/scripts/check_release_safety.py @@ -1,7 +1,8 @@ -"""Scan tracked text for host names, private IPv4 addresses, home paths and credentials without printing matches.""" +"""Scan tracked or extracted source text for private data without printing matched values.""" import argparse import ipaddress import json +import os from pathlib import Path import re import subprocess @@ -34,9 +35,34 @@ def findings(text, site=()): yield number, "site-value" +def source_paths(root, tree=False): + """Enumerate confined regular files; extracted trees require an explicit mode.""" + root = root.resolve() + if tree: + names = [] + for directory, children, files in os.walk(root, followlinks=False): + children[:] = sorted(name for name in children if name != ".git") + for name in children + files: + path = Path(directory) / name + if path.is_symlink(): + raise ValueError("source tree contains a symbolic link") + names.extend((Path(directory) / name).relative_to(root).as_posix() for name in files) + else: + checkout = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], cwd=root).decode().strip() + if Path(checkout).resolve() != root: + raise ValueError("source root must be the repository root") + names = subprocess.check_output(["git", "ls-files", "-z"], cwd=root).decode().split("\0") + for name in sorted(filter(None, names)): + path = root / name + if path.is_symlink() or not path.is_file() or not path.resolve().is_relative_to(root): + raise ValueError("source entry is not a confined regular file") + yield name + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("root", type=Path) + parser.add_argument("--tree", action="store_true", help="scan every regular file in an extracted source tree") parser.add_argument("--site-values", type=Path, help="add one literal host name or address per line from FILE") args = parser.parse_args() site = [] @@ -44,9 +70,8 @@ def main(): site = [line.split("#", 1)[0].strip() for line in args.site_values.read_text().splitlines()] site = [value for value in site if value] try: - paths = subprocess.check_output(["git", "ls-files", "-z"], cwd=args.root).decode().split("\0") count = 0 - for name in filter(None, paths): + for name in source_paths(args.root, args.tree): if name == "scripts/check_release_safety.py": continue data = (args.root / name).read_bytes() @@ -58,7 +83,7 @@ def main(): print(f"Release-safety findings: {count}; matched content withheld; site values: {len(site)}") return int(count > 0) except (OSError, ValueError, subprocess.SubprocessError): - print("Release-safety scan could not inspect all tracked files") + print("Release-safety scan could not inspect all source files") return 2 diff --git a/scripts/update_source_manifest.py b/scripts/update_source_manifest.py new file mode 100644 index 0000000..4463e45 --- /dev/null +++ b/scripts/update_source_manifest.py @@ -0,0 +1,23 @@ +"""Record the complete distributed C, C++, and header inventory and its SHA-256 hashes.""" +import hashlib +import json +from pathlib import Path +import subprocess + +ROOT = Path(__file__).resolve().parents[1] +SUFFIXES = {".c", ".h", ".cc", ".cpp", ".cxx", ".hpp"} + + +def main(): + names = subprocess.check_output( + ["git", "ls-files", "--cached", "--others", "--exclude-standard", "-z"], cwd=ROOT).decode().split("\0") + sources = sorted(name for name in names if name and not name.startswith(".codegraph/") + and Path(name).suffix in SUFFIXES and (ROOT / name).is_file()) + path = ROOT / "SOURCE.json" + document = json.loads(path.read_text()) + document["source_sha256"] = {name: hashlib.sha256((ROOT / name).read_bytes()).hexdigest() for name in sources} + path.write_text(json.dumps(document, indent=2) + "\n", encoding="utf-8") + + +if __name__ == "__main__": + main() diff --git a/tests/test_release_safety.py b/tests/test_release_safety.py new file mode 100644 index 0000000..fb894ad --- /dev/null +++ b/tests/test_release_safety.py @@ -0,0 +1,41 @@ +"""Source scanning contracts for archives without repository metadata.""" +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +SCANNER = Path(__file__).resolve().parents[1] / "scripts/check_release_safety.py" + + +class ExtractedSourceTests(unittest.TestCase): + def scan(self, path): + return subprocess.run([sys.executable, str(SCANNER), "--tree", str(path)], + capture_output=True, text=True, timeout=10) + + def test_private_content_is_reported_without_disclosing_values(self): + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) + private = "spark-" + "abcd" + (path / "notes.txt").write_text(private) + result = self.scan(path) + self.assertEqual(result.returncode, 1) + self.assertIn('"rule": "site-host"', result.stdout) + self.assertNotIn(private, result.stdout) + + def test_documentation_address_is_accepted_without_git(self): + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) + (path / "guide.txt").write_text("Example address: 192.0.2.1") + self.assertEqual(self.scan(path).returncode, 0) + + def test_symlinks_are_refused(self): + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) + (path / "guide.txt").write_text("example") + (path / "link").symlink_to(path / "guide.txt") + self.assertEqual(self.scan(path).returncode, 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/transport-core/src/shm_memory.c b/transport-core/src/shm_memory.c index f4b7ca2..f119c7b 100644 --- a/transport-core/src/shm_memory.c +++ b/transport-core/src/shm_memory.c @@ -180,4 +180,3 @@ void sircl_emu_mapping_release(sv_segment *mapping) { pthread_cond_broadcast(&segment_retired); pthread_mutex_unlock(&segments_lock); } - From ddc39fa07cd57010769a77094d0a6aad1efb9fbb Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 09:45:03 -0500 Subject: [PATCH 05/12] Size emulation registries for NCCL initialization pools Support eight local ranks with bounded connection, completion, registration and mapping tables sized for NCCL's startup channel pool. Use shared-memory registry layout 2; ext-net ABI and hardware wire version 6 remain unchanged. Keep mapping-eviction tests on a small explicit cache. Validation: existing CPU plugin tests and lifetime barriers pass, including 1536 simultaneous registrations and 300 CQs; bounded diagnostic GPU channel cases pass with the same capacity envelope. --- SOURCE.json | 10 ++++++---- docs/transport-core.md | 10 ++++++++++ tests/test_release.py | 3 ++- transport-core/Makefile | 2 +- transport-core/src/emulation_limits.h | 15 ++++++++++++++ transport-core/src/shm_memory.h | 2 +- transport-core/src/shm_verbs.c | 7 ++----- transport-core/tests/test_emulator_lifetime.c | 20 ++++++++++++++++++- 8 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 transport-core/src/emulation_limits.h diff --git a/SOURCE.json b/SOURCE.json index ff244f9..391ee9c 100644 --- a/SOURCE.json +++ b/SOURCE.json @@ -172,16 +172,17 @@ "transport-core/include/sircl_core/verbs_dl.c": "917eb77893adad8a62c053146ca8954d567b8e037a987a20a8e8393ac1f5f4eb", "transport-core/include/sircl_fabric.h": "5960d6fe55fba8c8f32a00bf747aecfd3a4b018db8248ce5134f75bd95843ebb", "transport-core/src/core.c": "3d32d0d6d58a2874573a3ba1ea1efddb5a96cbfc45b2bfd89e451fbd952549ef", + "transport-core/src/emulation_limits.h": "e7bc515560b9c1b0610279dd3ed6c0be9d3a3f248246e245299cc78db6017693", "transport-core/src/fabric.c": "edc6a98d8a8e1524ea502fade00b07467b57f299911ea8642b74a479497465b9", "transport-core/src/shm_memory.c": "4fcd9767b2e999d363b78100e360a84d9054edf4b65d3177db96cd4e9e263d4c", - "transport-core/src/shm_memory.h": "a7d4857229d5b0f8522f8d545de5c89bbc8c75bfebb0022db9e9ba9fb4a04189", - "transport-core/src/shm_verbs.c": "88d7237b5059e751f2ef38c02a805b29505de5dd3afcfdbca496866f5cbdcb80", + "transport-core/src/shm_memory.h": "defe5e56c0162f2c2ce3d7484693b2771bf0afb953f8a9994ba8ebe5e4f1e01b", + "transport-core/src/shm_verbs.c": "2bc7a33b4e492c1ab0ee25de3527695420ce7ddde4bd4b9b5128874093a1686b", "transport-core/src/sysfs.c": "747062778a2cab1744d43e602c724b1887ad6ba66428d62ee892b351f7f5b7c2", "transport-core/src/topology.c": "a3f7c625832f95816d8cac09d625aada86b4fe29f30923acbc9c126af73a9d0a", "transport-core/src/verbs_dl.c": "ea38fd0ef71bc215f8d97c4f836179aa9190dc87a34125a4a24a96e23bbc4d84", "transport-core/tests/fake_verbs/infiniband/verbs.h": "8c2173547a2169bb455d103b7842463168e75d4350f4434d92ab5dabc353c64c", "transport-core/tests/test_core.c": "af1228e52b14a1da826573e8eb604ca27ffaf603d3aa7f464b00a4b729f0c2c0", - "transport-core/tests/test_emulator_lifetime.c": "93d92a046853f8bc60077053768e5cac005bab51961f2d1305050330cd4a02e4", + "transport-core/tests/test_emulator_lifetime.c": "9a6b273b84cee7da73ec12eb03759098e11103bb461af02b5af6dd03311c0506", "transport-core/tests/test_verbs.c": "ec84a8971e48c2fd098dc06d630733af2a5f21c6cd6e9eaa89dca67a9871c220" }, "upstream_source_sha256": { @@ -243,5 +244,6 @@ "source_path": "src/include/plugin/tuner/tuner_v4.h", "sha256": "1164e13f7096c21c3c02fda1ddcb13d52a9d74e89a42cbf287ac74710861c9cd", "function_enum": "src/include/nccl_common.h ncclFunc_t (in nccl/tuner.h)" - } + }, + "emulator_shared_memory_version": 2 } diff --git a/docs/transport-core.md b/docs/transport-core.md index c66011a..ae548dd 100644 --- a/docs/transport-core.md +++ b/docs/transport-core.md @@ -63,3 +63,13 @@ lifecycle lock, so joining it cannot wait for a lock held by the joining thread. The emulator remains research-only test infrastructure. Its retirement and mapping checks establish local software contracts, not NIC or relay behavior. + +Its registry envelope supports eight local ranks with up to 1,024 local +connections per rank: 8,192 shared QPs, 32,768 shared registrations, 1,024 local +CQs and 4,096 local segment mappings. NCCL can allocate a 64-channel connection +pool even when its tuner selects eight channels for operations. The emulator's +registry must accommodate that initialization pool. CPU tests retain a smaller +mapping-cache bound to exercise eviction independently of the production bound. +The shared-memory registry layout is version 2; emulator providers with different +registry layouts must not attach to the same fabric segment. The hardware wire +protocol remains version 6. diff --git a/tests/test_release.py b/tests/test_release.py index ae3a6ce..d7f3bfc 100644 --- a/tests/test_release.py +++ b/tests/test_release.py @@ -69,7 +69,8 @@ def test_release_identity_is_built_in(self): self.assertEqual(ctypes.c_char_p(ctypes.addressof( ctypes.c_char.in_dll(library, "net_sircl_release"))).value.decode(), version) identity = subprocess.check_output([sys.executable, str(ROOT / "transport-core/tools/identity.py")]).strip() - self.assertIn(identity, (ROOT / "net-sircl/libnccl-net-sircl-emu.so").read_bytes()) + self.assertTrue(identity in (ROOT / "net-sircl/libnccl-net-sircl-emu.so").read_bytes(), + "compiled emulator lacks the expected transport source identity; rebuild it from this source tree") def test_all_example_routes_parse(self): subprocess.run(["make", "-C", str(ROOT / "net-sircl"), "emu"], check=True) diff --git a/transport-core/Makefile b/transport-core/Makefile index 747e9a3..a22c662 100644 --- a/transport-core/Makefile +++ b/transport-core/Makefile @@ -19,7 +19,7 @@ $(BUILD)/test_core: tests/test_core.c $(BUILD)/libsircl-core.a $(BUILD)/test_verbs: tests/test_verbs.c src/shm_verbs.c src/shm_memory.c | $(BUILD) $(CC) $(CPPFLAGS) -Itests/fake_verbs $(CFLAGS) $(filter %.c,$^) -o $@ $(BUILD)/test_emulator_lifetime: tests/test_emulator_lifetime.c src/shm_verbs.c src/shm_memory.c | $(BUILD) - $(CC) $(CPPFLAGS) -Itests/fake_verbs $(CFLAGS) -DSIRCL_EMU_TEST_HOOKS $(filter %.c,$^) -o $@ + $(CC) $(CPPFLAGS) -Itests/fake_verbs $(CFLAGS) -DSIRCL_EMU_TEST_HOOKS -DSV_SEGMENTS=64 $(filter %.c,$^) -o $@ check: all $(BUILD)/test_core $(BUILD)/test_verbs $(BUILD)/test_emulator_lifetime $(BUILD)/test_core $(BUILD)/test_verbs diff --git a/transport-core/src/emulation_limits.h b/transport-core/src/emulation_limits.h new file mode 100644 index 0000000..1c3e35c --- /dev/null +++ b/transport-core/src/emulation_limits.h @@ -0,0 +1,15 @@ +/* Finite registry envelope for eight local ranks with NCCL connection pools. */ +#ifndef SIRCL_EMULATION_LIMITS_H +#define SIRCL_EMULATION_LIMITS_H +#define SIRCL_EMU_MAX_RANKS 8 +#define SIRCL_EMU_LOCAL_CONNECTIONS 1024 +#define SV_LOCAL_QPS SIRCL_EMU_LOCAL_CONNECTIONS +#define SV_LOCAL_CQS SIRCL_EMU_LOCAL_CONNECTIONS +#define SV_MAX_QPS (SIRCL_EMU_MAX_RANKS * SIRCL_EMU_LOCAL_CONNECTIONS) +/* Control, send, receive and staging registrations can coexist per connection. */ +#define SV_MAX_MRS (4 * SV_MAX_QPS) +/* CPU lifetime tests override the cache bound to exercise eviction cheaply. */ +#ifndef SV_SEGMENTS +#define SV_SEGMENTS (4 * SIRCL_EMU_LOCAL_CONNECTIONS) +#endif +#endif diff --git a/transport-core/src/shm_memory.h b/transport-core/src/shm_memory.h index 6d59863..50c669c 100644 --- a/transport-core/src/shm_memory.h +++ b/transport-core/src/shm_memory.h @@ -3,8 +3,8 @@ #define SIRCL_EMU_MEMORY_H #include #include +#include "emulation_limits.h" #define SV_NAME 64 -#define SV_SEGMENTS 512 typedef struct { char name[SV_NAME]; uint8_t *base; diff --git a/transport-core/src/shm_verbs.c b/transport-core/src/shm_verbs.c index 7e15033..7269707 100644 --- a/transport-core/src/shm_verbs.c +++ b/transport-core/src/shm_verbs.c @@ -23,16 +23,13 @@ #include #include +#include "emulation_limits.h" #define SV_MAGIC 0x31465653u /* "SVF1" in byte order */ -#define SV_VERSION 1u +#define SV_VERSION 2u #define SV_MAX_DEVICES 256 -#define SV_MAX_MRS 1024 -#define SV_MAX_QPS 2048 #define SV_NAME 64 #define SV_INLINE 16 -#define SV_LOCAL_QPS 1024 -#define SV_LOCAL_CQS 256 /* -- shared registry --------------------------------------------------------------------------- */ diff --git a/transport-core/tests/test_emulator_lifetime.c b/transport-core/tests/test_emulator_lifetime.c index 9a6eb85..5755c21 100644 --- a/transport-core/tests/test_emulator_lifetime.c +++ b/transport-core/tests/test_emulator_lifetime.c @@ -195,12 +195,30 @@ static void worker_lifetime(void) { cleanup(&e); } +static void registration_envelope(void) { + struct endpoint e = endpoint(4); + char error[256]; + void *memory = sccl_emu_segment_alloc(4096, error, sizeof error); assert(memory); + struct ibv_mr *regions[1536]; + for (unsigned i = 0; i < 1536; ++i) { + regions[i] = sircl_core_reg_mr(e.pd, memory, 4096, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); + assert(regions[i]); + } + for (unsigned i = 0; i < 1536; ++i) assert(!sircl_core_dereg_mr(regions[i])); + struct ibv_cq *queues[300]; + for (unsigned i = 0; i < 300; ++i) { queues[i] = sircl_core_create_cq(e.ctx, 1); assert(queues[i]); } + for (unsigned i = 0; i < 300; ++i) assert(!sircl_core_destroy_cq(queues[i])); + sccl_emu_segment_free(memory); + cleanup(&e); +} + int main(void) { char fabric[80]; snprintf(fabric, sizeof fabric, "/sircl-lifetime-%d", (int)getpid()); assert(!setenv("SIRCL_EMU_FABRIC", fabric, 1)); mapping_lifetimes(); worker_lifetime(); + registration_envelope(); assert(!shm_unlink(fabric)); - puts("emulator: 530 remote lifetimes, serialized membership and work retirement exact"); + puts("emulator: 530 remote lifetimes, serialized retirement, 1536 registrations and 300 CQs exact"); return 0; } From 42458788742a79ecb3a061785e67c532c86f96bd Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 10:15:17 -0500 Subject: [PATCH 06/12] Qualify Spark transport workloads and document recovery prerequisites Record exact source and binary identities for physical collective, PyTorch, emulator, ownership and local boot checks. Publish sanitized measurements and keep the product research-only outside those conditions. Document independently persisted interface addresses and explicit group reconciliation after carrier resets. Local boot restoration succeeds while running neighbors require repair; automatic group recovery is unsupported. Record the shared-GPU LL128 failure with both sircl and Socket controls. Install the evidence artifact with the documentation. Runtime interfaces and wire compatibility are unchanged. Validation: 72 physical sweeps with 1,152 size rows, zero reported correctness errors and zero monitored error/drop deltas; physical graph/teardown before and after group repair; seven GPU channel cases; real local reboot and unrelated-filter preservation. Source/archive CPU suites pass for the pinned transport implementation. Documentation privacy and whitespace checks pass. --- Makefile | 2 + docs/compatibility.md | 18 +- docs/dgx-spark-validation.md | 140 + docs/evidence/dgx-spark-transport.json | 4453 ++++++++++++++++++++++++ docs/fabric.md | 17 +- docs/qualification.md | 46 +- fabric-tool/HARDWARE-TEST-PLAN.md | 8 + 7 files changed, 4657 insertions(+), 27 deletions(-) create mode 100644 docs/dgx-spark-validation.md create mode 100644 docs/evidence/dgx-spark-transport.json diff --git a/Makefile b/Makefile index 5c1e186..fd70129 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,8 @@ install: install -m 0644 SOURCE.json $(DESTDIR)$(PREFIX)/share/doc/net-sircl/SOURCE.json install -d $(DESTDIR)$(PREFIX)/share/doc/net-sircl/docs $(DESTDIR)$(PREFIX)/share/net-sircl/examples install -m 0644 docs/*.md $(DESTDIR)$(PREFIX)/share/doc/net-sircl/docs/ + install -d $(DESTDIR)$(PREFIX)/share/doc/net-sircl/docs/evidence + install -m 0644 docs/evidence/*.json $(DESTDIR)$(PREFIX)/share/doc/net-sircl/docs/evidence/ install -m 0644 examples/* $(DESTDIR)$(PREFIX)/share/net-sircl/examples/ install -d $(DESTDIR)$(PREFIX)/share/doc/net-sircl/examples install -m 0644 examples/* $(DESTDIR)$(PREFIX)/share/doc/net-sircl/examples/ diff --git a/docs/compatibility.md b/docs/compatibility.md index d5e20e0..63183ae 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -35,10 +35,20 @@ or 2.32.3 with the 0.1.1 library. PyTorch wheels and container images carry their own NCCL. A framework version, image name or exported plugin symbol does not establish the loaded runtime. -The current tests use PyTorch 2.11.0+cu128, its bundled NCCL 2.28.9, and separately -selected unpatched 2.31.2/2.32.3 libraries. They do not qualify all PyTorch wheels -or community vLLM images. For an image carrying NCCL 2.31.2, the matching runtime -is tested here, but its complete framework workload remains unqualified. +The runtime matrix above describes the recorded plugin 0.1.2 checks; it does +not qualify every binary carrying that version. The +[DGX Spark validation record](dgx-spark-validation.md) identifies the tested +source, compiled libraries, PyTorch versions and loaded NCCL library. Complete +framework workloads and community vLLM images remain unqualified. + +Status: **unsupported** for four ranks sharing one GB10 GPU with PyTorch +2.11.0+cu130, NCCL 2.32.3 and forced LL128. Exact checks fail with both the +shared-memory verbs plugin and NCCL Socket under those conditions. LL and +Simple pass the corresponding protocol probes; selecting Simple also passes +the seven-case channel matrix. These observations do not establish a failure +of the physical RDMA transport. The cached NGC PyTorch 26.09 image with +PyTorch 2.14.0a0 and loaded NCCL 2.32.3 passes the channel matrix without a +protocol override. Do not generalize either result to untested combinations. `scripts/check_e2e.py --expected-version 23102` queries `ncclGetVersion` after importing PyTorch and fails if the loaded version differs. It then verifies the diff --git a/docs/dgx-spark-validation.md b/docs/dgx-spark-validation.md new file mode 100644 index 0000000..9ee8506 --- /dev/null +++ b/docs/dgx-spark-validation.md @@ -0,0 +1,140 @@ +# DGX Spark transport and fabric validation + +Product status: **research-only**. The checks below qualify specific behavior; +automatic group recovery and arbitrary framework workloads remain unsupported. +Measurements were collected on 2026-10-23. The structured +[measurement artifact](evidence/dgx-spark-transport.json) contains per-sweep +results, timings, platform versions, GPU checks and negative controls. + +## Artifact identity and conditions + +The transport implementation is source revision +`ddc39fa07cd57010769a77094d0a6aad1efb9fbb`. Its aarch64 production plugin has +SHA-256 `52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef` +on all eight hosts. Its embedded transport source identity is +`1d159d428f60a5b2c43dd55a7a27aef4050bedf82263c4eb0ec5a6762acb1e75`. +The packet-marker binary has SHA-256 +`06b0ccf0af10b312a92d966d787b37d6fb4be681e13d6a2beb7389b24dfe39f7`. +Fabric Python sources are identical between that revision and the separately +tested resource-ownership revision +`cf2301c086bd38207b595738d263ea5f8c237387`. + +Matched controls use baseline source +`bd61460fdb03d52fe2f1e6ce685f4437b98c50b9`, production-library SHA-256 +`650844c24ed0727c09eb3f1049080232a179b8cdd887c9a18a23c2ddea2f1bcf`. +The resource-ownership revision's production-library SHA-256 is +`9701b41f6464173d5266de6da0055f56f3dc6f82688c6f00a946807658d1387d`. +Version strings remain plugin 0.1.2, core 0.1.1, core ABI 1 and wire 6. +The emulator's private shared-memory layout is version 2; it must not share a +fabric with a version-1 emulator. + +Eight DGX Sparks provide one GB10 GPU per host and directly cabled ConnectX-7 +functions. The fleet contains Ubuntu 24.04.4/24.04.5, NVIDIA kernels +6.17.0-1029/7.0.0-1019 and GPU drivers 580.173.02/580.178.04. NIC firmware is +28.45.4028; rdma-core/libibverbs is 50.0-2ubuntu0.2. Builds use GCC 13.3.0; +the benchmark build uses CUDA 13.0.88. GPU clocks were not fixed. The artifact's +idle/active clock samples do not establish clocks during every timed operation. + +The selected unpatched NCCL runtime is 2.32.3, library SHA-256 +`c77f5ced2c4b538aad2b0ab88a9838e9eac9a68e22017863ffb0cff9c4f58745`, +from the aarch64 `nvidia-nccl-cu13` wheel, SHA-256 +`a5bee92b2f4af218c109f8d221c3c9adcc752b94ae0ffcb0ed5abf9341a7724c`. +It is staged separately; installed framework libraries are not replaced. +NVIDIA nccl-tests is v2.21.1, source +`afd59abab774a6a4b492eb344bd0c845a0b7bb4d`, with MPI and one GPU/rank per host. + +## Physical collective results + +Every sweep selects sircl explicitly, the pinned production plugin, Ring, +at most eight channels and bfloat16. Sizes double from 8 KiB through 256 MiB: +16 size rows, two warm-ups and five timed iterations, in-place and out-of-place +correctness checks. Graph sweeps use 20 replays. All-reduce, all-gather, +reduce-scatter and broadcast each have eager and graph sweeps. + +| Cabling and participants | Source comparison | Sweeps | Result | +|---|---|---:|---| +| Directly cabled pair | Baseline and resource-ownership revision | 16 | Passed | +| Eight-host ring, all hosts participating | Baseline and resource-ownership revision | 16 | Passed | +| Directly cabled pair | Transport revision with expanded emulator registries | 8 | Passed | +| Four-host path, including relayed end-to-end connection | Baseline and transport revision with expanded registries | 16 | Passed | +| Eight-host ring, all hosts participating | Transport revision with expanded registries | 8 | Passed | +| Opposite ring endpoints; two paths, three relays per path | Transport revision with expanded registries | 8 | Passed | + +All 72 sweeps exit zero, identify sircl and report zero out-of-bounds values. +The 1,152 size rows have no reported correctness failures. Every suite records +before/after observations from all four RDMA functions on all eight hosts: +out-of-sequence, packet sequence, local ACK timeout and implied NAK counters, +plus available ethtool discard/drop/out-of-buffer counters. All monitored +deltas are zero and no required counter is missing. Comparisons span traffic +windows; a reboot's reset counters are not treated as continuous. These are +single matched sweeps, not a statistical performance qualification. + +The physical PyTorch check uses cached `nvcr.io/nvidia/pytorch:26.09-py3`, +image ID `sha256:a2d1be1817a6ecf66c56d60e4ab76c1ff745b407c31b4a7a76c1021f8a013d53`, +PyTorch 2.14.0a0+b2c75dd062.nv26.09 and separately loaded NCCL 2.32.3. +Four hosts each report eight exact eager all-reduces through 256 MiB, an exact +64 KiB graph replayed 20 times, PASS and exit zero. Destruction takes +0.35–0.36 seconds before reboot and 0.32–0.33 seconds after group repair. +Graph references are released before destruction. + +## Fabric lifecycle and recovery boundary + +Real facts, marker installation, apply, explicit verification and a second +idempotent apply pass on the ring and four-host path. Removing a path host's +table preserves its pre-existing clsact queue and an unrelated ARP filter +outside the relay preferences. Reapply and verification pass; the test filter +is removed afterward. + +The generated boot service retains execution intent, selected host, custom +marker and relay limit 2. Removing one host's table and restarting the service +restores it. An actual middle-host reboot with independently persisted IPv4 +addresses restores and verifies that host's filters, routes, neighbors and +markers. Administration access returns after 123.22 seconds. + +Address configuration is a prerequisite. With its normal address-providing +service paused and no replacement, the restarted host has no fabric IPv4 +addresses; restoration refuses all changes. Complete facts do not configure +those addresses. The successful local boot check uses a temporary prerequisite +service to restore saved addresses before the unmodified fabric unit runs. + +Automatic group recovery is **unsupported**. The reboot also resets neighboring +carriers. Two running neighbors lose six routes and six neighbor entries in +total; group verification fails although the rebooted host verifies. Explicit +apply across all four hosts repairs the group; verification and the repeated +physical PyTorch test then pass. That repair does not qualify autonomous +recovery. See [fabric operation](fabric.md) for the operator sequence. + +## GPU emulation and runtime boundary + +The expanded registries pass all seven channel-policy cases with the cached +PyTorch image and NCCL 2.32.3: four-rank path and eight-rank cycle use eight +active channels; direct-pair and stock-tuner controls use 64; explicit overrides +use four and 16; tuner disablement uses 64. Every rank reports seven exact +checks and exit zero. The matrix completes in 67.90 seconds. + +On host PyTorch 2.11.0+cu130 with the same NCCL library, direct/windowed checks +and four-rank teardown pass. Retaining a CUDA graph causes sircl and Socket +negative controls to exceed the 15-second destruction bound, as intended. +The default channel matrix fails its four-channel case. Protocol probes isolate +an unsupported combination: forced LL128 with four ranks on one GB10 produces +incorrect values with both sircl emulation and Socket. LL and Simple probes +pass, and Simple passes all seven channel cases. These observations do not +establish a physical RDMA defect or a root cause inside NCCL/PyTorch. + +NCCL 2.31.2 with the cached image fails the first two-rank emulation collective +for baseline and resource-ownership revisions. These failures do not demonstrate +a regression between those revisions or qualify that shared-GPU combination. + +## Software checks and exclusions + +The transport revision passes isolated Debian 13 x86-64 source/archive builds, +26 plugin tests, 144 fabric tests, five planning tests, three native core +executables, seven checkout release tests, extracted-source checks, privacy +scans and staged installation. The native lifetime regression exercises 530 +remote mappings, 1,536 simultaneous registrations and 300 completion queues; +a reduced cache bound forces eviction. All eight aarch64 builds produce the +same production-library hash. + +No vLLM/SGLang server, training job, physical packet-loss recovery, rank-loss +recovery, exhaustive concurrency envelope or automatic group recovery is +qualified. Site host names, addresses, keys and raw service logs remain private. diff --git a/docs/evidence/dgx-spark-transport.json b/docs/evidence/dgx-spark-transport.json new file mode 100644 index 0000000..2dae204 --- /dev/null +++ b/docs/evidence/dgx-spark-transport.json @@ -0,0 +1,4453 @@ +{ + "schema": "net-sircl-hardware-validation/v1", + "measured_date": "2026-10-23", + "source_revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "baseline_revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "production_plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef", + "baseline_plugin_sha256": "650844c24ed0727c09eb3f1049080232a179b8cdd887c9a18a23c2ddea2f1bcf", + "nccl": { + "version": "2.32.3", + "library_sha256": "c77f5ced2c4b538aad2b0ab88a9838e9eac9a68e22017863ffb0cff9c4f58745", + "wheel_sha256": "a5bee92b2f4af218c109f8d221c3c9adcc752b94ae0ffcb0ed5abf9341a7724c" + }, + "nccl_tests": { + "tag": "v2.21.1", + "revision": "afd59abab774a6a4b492eb344bd0c845a0b7bb4d" + }, + "workload": { + "datatype": "bfloat16", + "sizes_bytes": [ + 8192, + 268435456 + ], + "size_multiplier": 2, + "warmups": 2, + "iterations": 5, + "graph_replays": 20, + "max_channels": 8, + "algorithm": "Ring", + "collectives": [ + "all_reduce", + "all_gather", + "reduce_scatter", + "broadcast" + ] + }, + "physical_suites": { + "direct_pair_baseline_comparison": { + "layout": "direct_pair_baseline_comparison", + "cases": 16, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 3.4, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "6338.98", + "21.17", + "21.17", + "0", + "6251.98", + "21.47", + "21.47", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "12225.7", + "21.96", + "21.96", + "0", + "12185.7", + "22.03", + "22.03", + "0" + ] + ], + "collective": "all_reduce", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 8.32, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "6292.04", + "21.33", + "21.33", + "0", + "6292.34", + "21.33", + "21.33", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "12064.5", + "22.25", + "22.25", + "0", + "12089.7", + "22.20", + "22.20", + "0" + ] + ], + "collective": "all_reduce", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 3.41, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "3573.40", + "37.56", + "18.78", + "0", + "3394.43", + "39.54", + "19.77", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "6752.79", + "39.75", + "19.88", + "0", + "6496.98", + "41.32", + "20.66", + "0" + ] + ], + "collective": "all_gather", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 5.9, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "3600.85", + "37.27", + "18.64", + "0", + "3402.58", + "39.45", + "19.72", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "6739.48", + "39.83", + "19.92", + "0", + "6401.72", + "41.93", + "20.97", + "0" + ] + ], + "collective": "all_gather", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 3.29, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "3461.24", + "38.78", + "19.39", + "0", + "3511.66", + "38.22", + "19.11", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "6594.61", + "40.71", + "20.35", + "0", + "6525.85", + "41.13", + "20.57", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 6.3, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "3514.13", + "38.19", + "19.10", + "0", + "3495.54", + "38.40", + "19.20", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "6593.81", + "40.71", + "20.36", + "0", + "6603.61", + "40.65", + "20.32", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 3.81, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5479.33", + "24.50", + "24.50", + "0", + "5641.04", + "23.79", + "23.79", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "10989.2", + "24.43", + "24.43", + "0", + "11188.2", + "23.99", + "23.99", + "0" + ] + ], + "collective": "broadcast", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 8.3, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5586.41", + "24.03", + "24.03", + "0", + "5594.02", + "23.99", + "23.99", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11067.5", + "24.25", + "24.25", + "0", + "11080.3", + "24.23", + "24.23", + "0" + ] + ], + "collective": "broadcast", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 3.3, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "6303.00", + "21.29", + "21.29", + "0", + "6244.97", + "21.49", + "21.49", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "12058.7", + "22.26", + "22.26", + "0", + "12015.4", + "22.34", + "22.34", + "0" + ] + ], + "collective": "all_reduce", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 8.3, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "6303.53", + "21.29", + "21.29", + "0", + "6328.42", + "21.21", + "21.21", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "12082.2", + "22.22", + "22.22", + "0", + "12108.8", + "22.17", + "22.17", + "0" + ] + ], + "collective": "all_reduce", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 3.27, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "3560.33", + "37.70", + "18.85", + "0", + "3385.06", + "39.65", + "19.83", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "6777.69", + "39.61", + "19.80", + "0", + "6587.84", + "40.75", + "20.37", + "0" + ] + ], + "collective": "all_gather", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 6.35, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "3590.55", + "37.38", + "18.69", + "0", + "3416.74", + "39.28", + "19.64", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "6709.48", + "40.01", + "20.00", + "0", + "6399.36", + "41.95", + "20.97", + "0" + ] + ], + "collective": "all_gather", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 3.52, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "3523.22", + "38.10", + "19.05", + "0", + "3466.84", + "38.71", + "19.36", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "6726.37", + "39.91", + "19.95", + "0", + "6480.46", + "41.42", + "20.71", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 6.35, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "3525.02", + "38.08", + "19.04", + "0", + "3516.99", + "38.16", + "19.08", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "6595.43", + "40.70", + "20.35", + "0", + "6583.85", + "40.77", + "20.39", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 3.81, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5505.61", + "24.38", + "24.38", + "0", + "5712.86", + "23.49", + "23.49", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11028.2", + "24.34", + "24.34", + "0", + "11285.3", + "23.79", + "23.79", + "0" + ] + ], + "collective": "broadcast", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 8.32, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5604.62", + "23.95", + "23.95", + "0", + "5579.90", + "24.05", + "24.05", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11086.2", + "24.21", + "24.21", + "0", + "11020.5", + "24.36", + "24.36", + "0" + ] + ], + "collective": "broadcast", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + } + ] + }, + "full_ring_baseline_comparison": { + "layout": "full_ring_baseline_comparison", + "cases": 16, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 5.89, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "10998.2", + "12.20", + "21.36", + "0", + "11298.8", + "11.88", + "20.79", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "21411.4", + "12.54", + "21.94", + "0", + "21099.7", + "12.72", + "22.26", + "0" + ] + ], + "collective": "all_reduce", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 14.63, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "10491.1", + "12.79", + "22.39", + "0", + "10540.3", + "12.73", + "22.28", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "20529.7", + "13.08", + "22.88", + "0", + "20463.5", + "13.12", + "22.96", + "0" + ] + ], + "collective": "all_reduce", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 5.09, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "none", + "-1", + "6677.06", + "20.10", + "17.59", + "0", + "6682.11", + "20.09", + "17.58", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "none", + "-1", + "11826.1", + "22.70", + "19.86", + "0", + "11539.9", + "23.26", + "20.35", + "0" + ] + ], + "collective": "all_gather", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 10.68, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "none", + "-1", + "5612.56", + "23.91", + "20.92", + "0", + "5583.46", + "24.04", + "21.03", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "none", + "-1", + "10808.0", + "24.84", + "21.73", + "0", + "10758.2", + "24.95", + "21.83", + "0" + ] + ], + "collective": "all_gather", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 5.25, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "sum", + "-1", + "6071.95", + "22.10", + "19.34", + "0", + "6240.22", + "21.51", + "18.82", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "sum", + "-1", + "10921.3", + "24.58", + "21.51", + "0", + "11341.2", + "23.67", + "20.71", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 10.13, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "sum", + "-1", + "5445.67", + "24.65", + "21.57", + "0", + "5455.72", + "24.60", + "21.53", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "sum", + "-1", + "10498.4", + "25.57", + "22.37", + "0", + "10457.5", + "25.67", + "22.46", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 5.15, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "6577.14", + "20.41", + "20.41", + "0", + "6795.76", + "19.75", + "19.75", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "12371.7", + "21.70", + "21.70", + "0", + "12480.2", + "21.51", + "21.51", + "0" + ] + ], + "collective": "broadcast", + "mode": "eager", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 10.68, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5876.48", + "22.84", + "22.84", + "0", + "5784.79", + "23.20", + "23.20", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11326.9", + "23.70", + "23.70", + "0", + "11302.7", + "23.75", + "23.75", + "0" + ] + ], + "collective": "broadcast", + "mode": "graph", + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9" + }, + { + "exit": 0, + "seconds": 5.76, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "11210.7", + "11.97", + "20.95", + "0", + "11439.6", + "11.73", + "20.53", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "21331.5", + "12.58", + "22.02", + "0", + "20932.3", + "12.82", + "22.44", + "0" + ] + ], + "collective": "all_reduce", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 14.7, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "10480.3", + "12.81", + "22.41", + "0", + "10522.7", + "12.76", + "22.32", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "20509.7", + "13.09", + "22.90", + "0", + "20562.2", + "13.05", + "22.85", + "0" + ] + ], + "collective": "all_reduce", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 5.1, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "none", + "-1", + "6370.65", + "21.07", + "18.43", + "0", + "6181.06", + "21.71", + "19.00", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "none", + "-1", + "11785.6", + "22.78", + "19.93", + "0", + "11729.6", + "22.89", + "20.02", + "0" + ] + ], + "collective": "all_gather", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 11.09, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "none", + "-1", + "5606.42", + "23.94", + "20.95", + "0", + "5565.17", + "24.12", + "21.10", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "none", + "-1", + "10802.2", + "24.85", + "21.74", + "0", + "10724.0", + "25.03", + "21.90", + "0" + ] + ], + "collective": "all_gather", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 5.3, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "sum", + "-1", + "6415.92", + "20.92", + "18.30", + "0", + "6699.02", + "20.04", + "17.53", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "sum", + "-1", + "11659.0", + "23.02", + "20.15", + "0", + "10681.1", + "25.13", + "21.99", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 10.69, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "sum", + "-1", + "5432.12", + "24.71", + "21.62", + "0", + "5423.25", + "24.75", + "21.66", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "sum", + "-1", + "10413.1", + "25.78", + "22.56", + "0", + "10422.0", + "25.76", + "22.54", + "0" + ] + ], + "collective": "reduce_scatter", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 5.19, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "6702.57", + "20.02", + "20.02", + "0", + "6545.00", + "20.51", + "20.51", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "12214.6", + "21.98", + "21.98", + "0", + "12955.4", + "20.72", + "20.72", + "0" + ] + ], + "collective": "broadcast", + "mode": "eager", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + }, + { + "exit": 0, + "seconds": 10.18, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5882.73", + "22.82", + "22.82", + "0", + "5947.02", + "22.57", + "22.57", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11469.1", + "23.41", + "23.41", + "0", + "11605.4", + "23.13", + "23.13", + "0" + ] + ], + "collective": "broadcast", + "mode": "graph", + "revision": "cf2301c086bd38207b595738d263ea5f8c237387" + } + ] + }, + "direct_pair_capacity_revision": { + "layout": "direct_pair_capacity_revision", + "cases": 8, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 3.39, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "6261.55", + "21.44", + "21.44", + "0", + "6247.50", + "21.48", + "21.48", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "12046.9", + "22.28", + "22.28", + "0", + "11941.9", + "22.48", + "22.48", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 8.34, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "6303.58", + "21.29", + "21.29", + "0", + "6307.07", + "21.28", + "21.28", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "12127.2", + "22.13", + "22.13", + "0", + "12079.7", + "22.22", + "22.22", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.34, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "3550.08", + "37.81", + "18.90", + "0", + "3391.68", + "39.57", + "19.79", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "6607.43", + "40.63", + "20.31", + "0", + "6406.89", + "41.90", + "20.95", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 6.32, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "3600.18", + "37.28", + "18.64", + "0", + "3405.99", + "39.41", + "19.70", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "6701.81", + "40.05", + "20.03", + "0", + "6417.95", + "41.83", + "20.91", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.34, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "3443.83", + "38.97", + "19.49", + "0", + "3488.17", + "38.48", + "19.24", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "6548.69", + "40.99", + "20.50", + "0", + "6514.04", + "41.21", + "20.60", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 6.38, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "3522.42", + "38.10", + "19.05", + "0", + "3504.66", + "38.30", + "19.15", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "6577.96", + "40.81", + "20.40", + "0", + "6565.16", + "40.89", + "20.44", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.85, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5525.85", + "24.29", + "24.29", + "0", + "5764.96", + "23.28", + "23.28", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11001.4", + "24.40", + "24.40", + "0", + "11158.9", + "24.06", + "24.06", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 8.39, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5580.30", + "24.05", + "24.05", + "0", + "5582.99", + "24.04", + "24.04", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11083.9", + "24.22", + "24.22", + "0", + "11076.1", + "24.24", + "24.24", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "graph" + } + ] + }, + "four_host_path_baseline_comparison": { + "layout": "four_host_path_baseline_comparison", + "cases": 16, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 4.46, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "14185.7", + "9.46", + "14.19", + "0", + "14274.6", + "9.40", + "14.10", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "28901.3", + "9.29", + "13.93", + "0", + "29031.5", + "9.25", + "13.87", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "all_reduce", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 15.95, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "14072.5", + "9.54", + "14.31", + "0", + "14083.3", + "9.53", + "14.30", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "28950.6", + "9.27", + "13.91", + "0", + "29057.8", + "9.24", + "13.86", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "all_reduce", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.95, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "7375.16", + "18.20", + "13.65", + "0", + "7371.83", + "18.21", + "13.66", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14544.5", + "18.46", + "13.84", + "0", + "14544.2", + "18.46", + "13.84", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "all_gather", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.04, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "7391.52", + "18.16", + "13.62", + "0", + "7322.33", + "18.33", + "13.75", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14515.0", + "18.49", + "13.87", + "0", + "14378.0", + "18.67", + "14.00", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "all_gather", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.06, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6775.01", + "19.81", + "14.86", + "0", + "6804.27", + "19.73", + "14.79", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "14077.1", + "19.07", + "14.30", + "0", + "13981.6", + "19.20", + "14.40", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "reduce_scatter", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.03, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6671.08", + "20.12", + "15.09", + "0", + "6693.82", + "20.05", + "15.04", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "13855.2", + "19.37", + "14.53", + "0", + "13844.7", + "19.39", + "14.54", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "reduce_scatter", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.45, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5595.88", + "23.99", + "23.99", + "0", + "5596.76", + "23.98", + "23.98", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11117.8", + "24.14", + "24.14", + "0", + "11106.9", + "24.17", + "24.17", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "broadcast", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 8.97, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5800.86", + "23.14", + "23.14", + "0", + "5780.32", + "23.22", + "23.22", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11340.8", + "23.67", + "23.67", + "0", + "11315.4", + "23.72", + "23.72", + "0" + ] + ], + "revision": "bd61460fdb03d52fe2f1e6ce685f4437b98c50b9", + "collective": "broadcast", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.72, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "13989.9", + "9.59", + "14.39", + "0", + "14021.9", + "9.57", + "14.36", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "28865.6", + "9.30", + "13.95", + "0", + "29069.4", + "9.23", + "13.85", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 15.89, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "14184.4", + "9.46", + "14.19", + "0", + "14235.8", + "9.43", + "14.14", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "29128.9", + "9.22", + "13.82", + "0", + "29142.1", + "9.21", + "13.82", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.78, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "7222.41", + "18.58", + "13.94", + "0", + "7128.60", + "18.83", + "14.12", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14435.8", + "18.60", + "13.95", + "0", + "14414.3", + "18.62", + "13.97", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 9.75, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "7293.14", + "18.40", + "13.80", + "0", + "7122.02", + "18.85", + "14.13", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14417.4", + "18.62", + "13.96", + "0", + "14297.0", + "18.78", + "14.08", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.78, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6770.91", + "19.82", + "14.87", + "0", + "6843.72", + "19.61", + "14.71", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "14004.0", + "19.17", + "14.38", + "0", + "14074.3", + "19.07", + "14.30", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 9.81, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6775.67", + "19.81", + "14.86", + "0", + "6814.34", + "19.70", + "14.77", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "13996.2", + "19.18", + "14.38", + "0", + "14017.3", + "19.15", + "14.36", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 3.68, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5580.00", + "24.05", + "24.05", + "0", + "5688.33", + "23.60", + "23.60", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11197.9", + "23.97", + "23.97", + "0", + "11115.0", + "24.15", + "24.15", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 8.42, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5800.72", + "23.14", + "23.14", + "0", + "5800.54", + "23.14", + "23.14", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11297.5", + "23.76", + "23.76", + "0", + "11308.9", + "23.74", + "23.74", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "graph" + } + ] + }, + "full_ring_capacity_revision": { + "layout": "full_ring_capacity_revision", + "cases": 8, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 5.84, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "11213.7", + "11.97", + "20.95", + "0", + "11043.8", + "12.15", + "21.27", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "20828.5", + "12.89", + "22.55", + "0", + "20935.7", + "12.82", + "22.44", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 14.62, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "10460.5", + "12.83", + "22.45", + "0", + "10460.7", + "12.83", + "22.45", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "20399.2", + "13.16", + "23.03", + "0", + "20365.8", + "13.18", + "23.07", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 5.09, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "none", + "-1", + "6509.79", + "20.62", + "18.04", + "0", + "6523.98", + "20.57", + "18.00", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "none", + "-1", + "11426.0", + "23.49", + "20.56", + "0", + "11169.8", + "24.03", + "21.03", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.13, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "none", + "-1", + "5578.41", + "24.06", + "21.05", + "0", + "5507.84", + "24.37", + "21.32", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "none", + "-1", + "10712.3", + "25.06", + "21.93", + "0", + "10606.1", + "25.31", + "22.15", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 5.24, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "sum", + "-1", + "5982.00", + "22.44", + "19.63", + "0", + "6060.68", + "22.15", + "19.38", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "sum", + "-1", + "11121.8", + "24.14", + "21.12", + "0", + "11162.4", + "24.05", + "21.04", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.09, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "8388608", + "bfloat16", + "sum", + "-1", + "5396.60", + "24.87", + "21.76", + "0", + "5367.50", + "25.01", + "21.88", + "0" + ], + [ + "268435456", + "16777216", + "bfloat16", + "sum", + "-1", + "10422.0", + "25.76", + "22.54", + "0", + "10410.6", + "25.78", + "22.56", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 5.3, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "6537.55", + "20.53", + "20.53", + "0", + "7007.27", + "19.15", + "19.15", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "12228.7", + "21.95", + "21.95", + "0", + "12432.6", + "21.59", + "21.59", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.18, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5816.49", + "23.08", + "23.08", + "0", + "5814.56", + "23.08", + "23.08", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11317.2", + "23.72", + "23.72", + "0", + "11286.1", + "23.78", + "23.78", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "graph" + } + ] + }, + "opposite_ring_endpoints_capacity_revision": { + "layout": "opposite_ring_endpoints_capacity_revision", + "cases": 8, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 5.11, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "11921.7", + "11.26", + "11.26", + "0", + "15590.8", + "8.61", + "8.61", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "26454.1", + "10.15", + "10.15", + "0", + "29185.7", + "9.20", + "9.20", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 14.6, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "11696.8", + "11.47", + "11.47", + "0", + "11694.5", + "11.48", + "11.48", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "23086.3", + "11.63", + "11.63", + "0", + "23173.6", + "11.58", + "11.58", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_reduce", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.6, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "8087.83", + "16.60", + "8.30", + "0", + "8670.57", + "15.48", + "7.74", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "12869.5", + "20.86", + "10.43", + "0", + "12088.6", + "22.21", + "11.10", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.1, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "none", + "-1", + "6045.24", + "22.20", + "11.10", + "0", + "6015.16", + "22.31", + "11.16", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "none", + "-1", + "11848.2", + "22.66", + "11.33", + "0", + "11702.1", + "22.94", + "11.47", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "all_gather", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.56, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "6242.56", + "21.50", + "10.75", + "0", + "5948.06", + "22.56", + "11.28", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "14121.2", + "19.01", + "9.50", + "0", + "12053.4", + "22.27", + "11.14", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 9.49, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "33554432", + "bfloat16", + "sum", + "-1", + "6085.20", + "22.06", + "11.03", + "0", + "5981.89", + "22.44", + "11.22", + "0" + ], + [ + "268435456", + "67108864", + "bfloat16", + "sum", + "-1", + "11718.3", + "22.91", + "11.45", + "0", + "11721.3", + "22.90", + "11.45", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "reduce_scatter", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 18.74, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "49414.6", + "2.72", + "2.72", + "0", + "48897.9", + "2.74", + "2.74", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "59473.9", + "4.51", + "4.51", + "0", + "58552.0", + "4.58", + "4.58", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 27.07, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "11661.4", + "11.51", + "11.51", + "0", + "11777.2", + "11.40", + "11.40", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "21338.8", + "12.58", + "12.58", + "0", + "21353.7", + "12.57", + "12.57", + "0" + ] + ], + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "collective": "broadcast", + "mode": "graph" + } + ] + } + }, + "gpu_host_suite": [ + { + "case": "e2e", + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "exit": 0, + "seconds": 10.06 + }, + { + "case": "teardown", + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "exit": 0, + "seconds": 55.71 + }, + { + "case": "channels", + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "exit": 1, + "seconds": 43.43 + } + ], + "gpu_protocol_probe": [ + { + "net": "sircl", + "protocol": "Simple", + "exit": 0, + "seconds": 5.42, + "summary": { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.27 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.27 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.27 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.27 s", + "plugin": true, + "wrong": false + } + ] + } + }, + { + "net": "sircl", + "protocol": "LL", + "exit": 0, + "seconds": 28.46, + "summary": { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + } + ] + } + }, + { + "net": "sircl", + "protocol": "LL128", + "exit": 1, + "seconds": 6.95, + "summary": { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 1, + "pass": false, + "exact_lines": 5, + "teardown": "0.33 s", + "plugin": true, + "wrong": true + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.33 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.33 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.33 s", + "plugin": true, + "wrong": false + } + ] + } + }, + { + "net": "socket", + "protocol": "LL128", + "exit": 1, + "seconds": 6.48, + "summary": { + "net": "socket", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 1, + "pass": false, + "exact_lines": 4, + "teardown": "0.23 s", + "plugin": false, + "wrong": true + }, + { + "rank": 1, + "exit": 1, + "pass": false, + "exact_lines": 4, + "teardown": "0.23 s", + "plugin": false, + "wrong": true + }, + { + "rank": 2, + "exit": 1, + "pass": false, + "exact_lines": 4, + "teardown": "0.23 s", + "plugin": false, + "wrong": true + }, + { + "rank": 3, + "exit": 1, + "pass": false, + "exact_lines": 4, + "teardown": "0.23 s", + "plugin": false, + "wrong": true + } + ] + } + } + ], + "gpu_simple_channels": [ + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.49 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.45 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.45 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.49 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null + ], + "case": "path4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.66 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.59 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.67 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.67 s", + "plugin": true, + "wrong": false + }, + { + "rank": 4, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.61 s", + "plugin": true, + "wrong": false + }, + { + "rank": 5, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.67 s", + "plugin": true, + "wrong": false + }, + { + "rank": 6, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.68 s", + "plugin": true, + "wrong": false + }, + { + "rank": 7, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.66 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null, + null, + null, + null, + null + ], + "case": "cycle8" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.30 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.32 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.26 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair-stock-tuner" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.33 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 4, + null, + null, + null + ], + "case": "override4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.08 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.10 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.09 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.11 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 16, + null, + null, + null + ], + "case": "override16" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.46 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.46 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.46 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.46 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null, + null, + null + ], + "case": "disabled" + } + ], + "gpu_container_channels": { + "revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "exit": 0, + "seconds": 67.9, + "image": "nvcr.io/nvidia/pytorch:26.09-py3", + "image_id": "sha256:a2d1be1817a6ecf66c56d60e4ab76c1ff745b407c31b4a7a76c1021f8a013d53", + "cases": [ + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.26 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.29 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.31 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.27 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null + ], + "case": "path4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.60 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.68 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.66 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.68 s", + "plugin": true, + "wrong": false + }, + { + "rank": 4, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.67 s", + "plugin": true, + "wrong": false + }, + { + "rank": 5, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.73 s", + "plugin": true, + "wrong": false + }, + { + "rank": 6, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.64 s", + "plugin": true, + "wrong": false + }, + { + "rank": 7, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.73 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null, + null, + null, + null, + null + ], + "case": "cycle8" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.38 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.29 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.29 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair-stock-tuner" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 4, + null, + null, + null + ], + "case": "override4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 16, + null, + null, + null + ], + "case": "override16" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.44 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.44 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.42 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.44 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null, + null, + null + ], + "case": "disabled" + } + ] + }, + "physical_pytorch": { + "before-reboot": [ + { + "rank": 0, + "exit": 0, + "seconds": 4.29, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.36 + }, + { + "rank": 1, + "exit": 0, + "seconds": 4.32, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.36 + }, + { + "rank": 2, + "exit": 0, + "seconds": 4.39, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.36 + }, + { + "rank": 3, + "exit": 0, + "seconds": 4.34, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.35 + } + ], + "after-reboot": [ + { + "rank": 0, + "exit": 0, + "seconds": 6.2, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.32 + }, + { + "rank": 1, + "exit": 0, + "seconds": 6.47, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.32 + }, + { + "rank": 2, + "exit": 0, + "seconds": 6.28, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.33 + }, + { + "rank": 3, + "exit": 0, + "seconds": 6.22, + "exact": 9, + "pass_line": true, + "wrong": false, + "plugin": true, + "teardown_seconds": 0.32 + } + ] + }, + "boot": { + "boot_identity_changed": true, + "return_seconds": 123.22, + "independently_persisted_addresses": true, + "local_restoration": "qualified", + "automatic_group_recovery": "unsupported", + "group_verification_exit_by_position": { + "0": 1, + "1": 0, + "2": 1, + "3": 0 + }, + "repair": "Explicit group apply and verify before traffic", + "missing_neighbor_objects": { + "routes": 6, + "neighbors": 6 + }, + "missing_address_control": "Boot restoration refused when all four fabric IPv4 addresses were absent" + }, + "unrelated_filter": { + "passed": true, + "queue_kind": "clsact", + "unrelated_filter_retained": true + }, + "platform": { + "0": { + "os": "Ubuntu 24.04.4 LTS", + "kernel": "6.17.0-1029-nvidia", + "gpu": "NVIDIA GB10, 580.173.02, P8, 208 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + }, + "1": { + "os": "Ubuntu 24.04.4 LTS", + "kernel": "6.17.0-1029-nvidia", + "gpu": "NVIDIA GB10, 580.173.02, P8, 208 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + }, + "2": { + "os": "Ubuntu 24.04.4 LTS", + "kernel": "6.17.0-1029-nvidia", + "gpu": "NVIDIA GB10, 580.173.02, P8, 208 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + }, + "3": { + "os": "Ubuntu 24.04.4 LTS", + "kernel": "6.17.0-1029-nvidia", + "gpu": "NVIDIA GB10, 580.173.02, P8, 208 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + }, + "4": { + "os": "Ubuntu 24.04.4 LTS", + "kernel": "6.17.0-1029-nvidia", + "gpu": "NVIDIA GB10, 580.173.02, P0, 2405 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + }, + "5": { + "os": "Ubuntu 24.04.5 LTS", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10, 580.178.04, P0, 2411 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + }, + "6": { + "os": "Ubuntu 24.04.5 LTS", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10, 580.178.04, P8, 208 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + }, + "7": { + "os": "Ubuntu 24.04.4 LTS", + "kernel": "6.17.0-1029-nvidia", + "gpu": "NVIDIA GB10, 580.173.02, P0, 2398 MHz, [N/A], [N/A]", + "firmware": "28.45.4028 (NVD0000000087)", + "rdma": "libibverbs1:arm64\t50.0-2ubuntu0.2\nrdma-core\t50.0-2ubuntu0.2", + "compiler": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0", + "plugin_sha256": "52fa08d212cdabba6cdd2be629092a5d95ec8235430a46f0022d42d69d1ed3ef" + } + }, + "limits": [ + "Single matched sweeps; clocks were not fixed; no throughput regression threshold established", + "Forced LL128 with four ranks sharing one GB10, PyTorch 2.11.0+cu130 and NCCL 2.32.3 fails both sircl and Socket", + "Boot service restores its own host only; group recovery after adjacent carrier reset requires explicit reconciliation", + "No vLLM, SGLang, training-job, process-loss or physical packet-loss recovery qualification" + ], + "transport_source_identity": "1d159d428f60a5b2c43dd55a7a27aef4050bedf82263c4eb0ec5a6762acb1e75", + "marker_sha256": "06b0ccf0af10b312a92d966d787b37d6fb4be681e13d6a2beb7389b24dfe39f7" +} diff --git a/docs/fabric.md b/docs/fabric.md index 759be86..822a381 100644 --- a/docs/fabric.md +++ b/docs/fabric.md @@ -31,8 +31,8 @@ The tool does not assign addresses or bring links up. Each of the four RDMA functions needs IPv4. Each cable's ends must share a subnet on the primary functions (`rocep1...`) and another on the secondary functions (`roceP2...`). All hosts must use the same function-to-network-interface mapping. By default -a lane may cross three relays (`--max-relays`); the plugin hardware measurements -cover at most two. Three relays have not been measured for this release. +a lane may cross three relays (`--max-relays`). Source-specific measurements +and limits are recorded in [qualification evidence](qualification.md). ## Plan, apply and verify @@ -133,7 +133,18 @@ This writes topology and facts under `/etc/fabric-table/`, copies the tool to `/opt/net-sircl` install), enables `fabric-table.service` and applies the relays. At boot the oneshot unit runs `apply --boot`, restoring missing objects and markers without removing anything. It does not continuously supervise markers. -Addresses must be ready at `network-online.target`. +Addresses must be ready at `network-online.target`. If a separate service +configures them later, order `fabric-table.service` after that service and +require it through a systemd drop-in. Copying addresses into the facts file +does not configure the interfaces. Missing addresses block restoration. + +Status: **unsupported** for automatic recovery of the entire group after a +link reset. A reboot can remove routes and permanent neighbour entries on +the still-running adjacent hosts. Their boot units do not run again. After +the links and addresses are ready, apply the group table across all hosts +with `--execute`, then require group verification before resuming traffic. +The [DGX Spark validation record](dgx-spark-validation.md) separates successful +local boot restoration from this group recovery requirement. After reboot run `fabric verify --facts facts.json` from the workstation and `systemctl status fabric-table.service` on the restarted host. To disable diff --git a/docs/qualification.md b/docs/qualification.md index 7469dfa..3a72b38 100644 --- a/docs/qualification.md +++ b/docs/qualification.md @@ -1,28 +1,34 @@ # Qualification evidence -Status: **research-only**. Hardware results apply to the recorded source revision, -topology and workload. They do not qualify a binary built from different source -bytes, even when its component version strings match. +Product status: **research-only**. A qualified check applies to its source, +compiled artifact, runtime, topology and workload. Component version strings +alone do not identify the tested implementation. -| Component and source identity | Conditions | Measurement and result | Qualification limit | -|---|---|---|---| -| Plugin 0.1.2, source revision `bd61460fdb03d52fe2f1e6ce685f4437b98c50b9` | Four DGX Sparks in a path; NCCL 2.32.3; PyTorch eager and CUDA graphs; graph references released before destruction | Nine exact checks per rank; destruction 0.54–0.68 seconds; `PASS` and exit 0 on all four ranks | Qualified for that recorded check; not every graph lifetime or serving workload | -| Plugin 0.1.2, same source revision | Eight-Spark ring; automatic collective channel policy | Eight active operation channels; CUDA-graph all-reduce sweep completed in 36.7 seconds | Qualified for the recorded workload and cabling; not a throughput guarantee | -| Framework integrations using plugin 0.1.1 | Versions and topologies listed in the root README framework matrix; one GPU and rank per host | Correct results, unchanged error counters and independent rank exit in single runs | Research-only; integration results do not qualify modified plugin builds | -| Fabric configuration tool | CPU planning, synthetic host observations and generated command checks | Software contracts for ownership, command forms, input validation and restoration policy | Implemented; physical forwarding and actual reboot restoration require `fabric-tool/HARDWARE-TEST-PLAN.md` | -| Shared-memory verbs emulator | Processes of one Linux host; no physical NIC or relay | Exact data movement, bounded admission, worker retirement and mapping-lifetime checks | Implemented test infrastructure; physical loss recovery and NIC performance unsupported | -| Distributed source manifest `SOURCE.json`, field `source_sha256` | Every distributed C/C++ source and header, including the marker and tests | Hash equality and inventory completeness checked by release tests | Implemented provenance check; source equality alone is not hardware qualification | +The [DGX Spark validation record](dgx-spark-validation.md) and its +[measurement artifact](evidence/dgx-spark-transport.json) identify source +revision `ddc39fa07cd57010769a77094d0a6aad1efb9fbb`, compiled-library hashes, +matched controls, results and limitations. -The plugin measurement records are in +| Component | Conditions and measurement | Status and conclusion | +|---|---|---| +| Physical RDMA plugin | Recorded revision; NCCL 2.32.3; direct pair, four-host path, eight-host ring and opposite ring endpoints; four collectives, eager and graphs, 8 KiB–256 MiB | **Qualified** for 32 sweeps of that revision. Across implementation and baseline controls, 72 sweeps contain 1,152 size rows with zero correctness errors and no monitored error/drop-counter growth. No throughput guarantee | +| Physical PyTorch graph lifetime | Four hosts, one GPU/rank per host; NGC PyTorch 26.09 with NCCL 2.32.3; eight eager checks and 20 graph replays; graph references released before destruction | **Qualified** before reboot and after group reconciliation; nine exact-result lines per rank, destruction 0.32–0.36 seconds | +| Standalone fabric tool | Real four-host path and eight-host ring; apply, verify, idempotency, removal and unrelated-filter preservation | **Qualified** for those operations; pre-existing clsact and unrelated filter retained | +| Local boot restoration | One middle path host rebooted; complete facts and independently persisted interface addresses; custom marker and relay limit | **Qualified** for restoration on that host; service applied and verified its local table | +| Group recovery after carrier reset | Rebooted host restores locally; two running neighbors lose six routes and six neighbor entries | **Unsupported** for automatic group recovery. Explicit group apply and verification restore traffic; the boot-only service does not reconcile running neighbors | +| Shared-memory verbs emulator | Eight local ranks and NCCL initialization pools; cached PyTorch 26.09 image, loaded NCCL 2.32.3 | **Qualified** for the seven-case channel matrix. CPU tests cover admission, worker retirement, mapping leases and registry bounds. Physical loss recovery and NIC performance unsupported | +| Shared-GPU LL128 combination | Four ranks on one GB10; PyTorch 2.11.0+cu130; NCCL 2.32.3; forced LL128 | **Unsupported**: exact checks fail with both sircl emulation and NCCL Socket. LL and Simple probes pass; Simple passes the channel matrix | +| Distributed source manifest `SOURCE.json`, field `source_sha256` | Every distributed C/C++ source and header, including marker and tests; inventory completeness and hash equality | **Implemented** provenance check; equality alone does not establish hardware qualification | + +Historical plugin and framework measurements are retained in [release 0.1.2](../RELEASE_NOTES-0.1.2.md), [release 0.1.1](../RELEASE_NOTES-0.1.1.md) and -[historical 0.1.0 measurements](measurements.md). These are explicitly historical -records. Operational requirements belong in [configuration](configuration.md), +[0.1.0 measurements](measurements.md). They do not qualify different source +bytes. Operational requirements belong in [configuration](configuration.md), [fabric setup](fabric.md) and [testing](testing.md). -For a hardware qualification, record the source commit, complete distributed -source manifest, compiled-library SHA-256, topology, GPU/NIC/driver/firmware/OS -versions, NCCL/framework versions, environment, clocks, workload, independent -rank exits, correctness checks, error-counter deltas and individual timing -measurements. Keep site-specific identifiers in private logs; publish sanitized -conditions and bounded conclusions. +A qualification record must identify source commit and manifest, compiled +library SHA-256, topology, GPU/NIC/driver/firmware/OS, runtime and framework, +environment, clock policy, workload, independent rank exits, correctness, +counter deltas and individual timing measurements. Keep site identifiers in +private logs; publish sanitized conditions and bounded conclusions. diff --git a/fabric-tool/HARDWARE-TEST-PLAN.md b/fabric-tool/HARDWARE-TEST-PLAN.md index 445ee9b..cff9e13 100644 --- a/fabric-tool/HARDWARE-TEST-PLAN.md +++ b/fabric-tool/HARDWARE-TEST-PLAN.md @@ -75,9 +75,17 @@ CPU tests predict no throughput value. Compare only matched runs. ## Boot persistence (about 15 minutes on one ring) Install the boot unit locally on all four hosts with identical complete facts. +Keep interface addressing persistent through an independent network service; +the fabric tool does not assign addresses. If that service runs after +`network-online.target`, require and order it before `fabric-table.service`. Reboot one host; wait for addresses and the unit to become ready. Require `verify` to pass for every host and repeat a relayed traffic probe. Record the systemd journal and counters. Keep any other installer's restore disabled. +Record local restoration separately from group verification. A carrier reset +can remove adjacent hosts' routes and neighbours; boot-only units do not +repair those running hosts. If group verification fails, preserve that result, +reapply across the group under operator control, verify and repeat traffic. +Successful traffic after that repair does not qualify automatic group recovery. ## Remove and restore (about 10 minutes per ring) From b6c7f0a00d8e044b1211004dbbba2f29c3c28fd0 Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 10:50:22 -0500 Subject: [PATCH 07/12] Reconcile missing fabric state after carrier resets Install a periodic local reconciliation timer that reloads the retained fabric service. Startup and reload share the validated add-only invocation, including marker, relay limit and host selection. Healthy markers remain in the retained service cgroup rather than being killed by repeated restarts. Each host repairs its own routes and neighbors after an adjacent link resets. Start periodic checks after successful immediate installation. Removing boot persistence stops reconciliation before deleting its units and inputs while preserving live relay state. Boot-only installations remain removable. Transport ABI and wire behavior are unchanged; persistent interface addresses remain a network-configuration prerequisite. Validation: 145 fabric tests; fake-root lifecycle checks; real systemd timer and reload integration in an isolated unprivileged Debian container, including missing-state repair, retained marker PID and marker survival after removal. --- docs/fabric.md | 33 ++++++++++++++---------- fabric-tool/HARDWARE-TEST-PLAN.md | 9 ++++--- fabric-tool/README.md | 4 +-- fabric-tool/fabric_tool/boot.py | 42 +++++++++++++++++++++++++------ fabric-tool/fabric_tool/cli.py | 14 ++++++++--- fabric-tool/tests/test_boot.py | 30 +++++++++++++++++++--- 6 files changed, 98 insertions(+), 34 deletions(-) diff --git a/docs/fabric.md b/docs/fabric.md index 822a381..a6f20e5 100644 --- a/docs/fabric.md +++ b/docs/fabric.md @@ -116,7 +116,7 @@ Using the shell function above, run `fabric status`, then `fabric remove` to preview and `fabric remove --execute` to remove. Inspect ownership before using `--adopt`; routes outside the relay plan are not adopted. -## Boot restoration +## Boot and link-reset restoration Install the repository on every Spark. Copy the same topology and a `facts.json` covering every host to each Spark. Run locally on **each Spark**: @@ -131,26 +131,33 @@ sudo /opt/net-sircl/bin/fabric-tool install-boot \ This writes topology and facts under `/etc/fabric-table/`, copies the tool to `/usr/local/lib/fabric-tool` and `/usr/local/bin/fabric-tool` (separate from the `/opt/net-sircl` install), enables `fabric-table.service` and applies the relays. -At boot the oneshot unit runs `apply --boot`, restoring missing objects and -markers without removing anything. It does not continuously supervise markers. +It also installs and starts `fabric-table-reconcile.timer`. Every 15 seconds +after the preceding check finishes, the timer starts +`fabric-table-reconcile.service`, which requests a reload of the retained +fabric service, or starts it if inactive. Startup and reload both run +`apply --boot --execute`, adding missing objects and markers without removing +healthy state. Reload preserves existing marker processes. Failed checks are +retried; inspect both services' journals when restoration is blocked. Addresses must be ready at `network-online.target`. If a separate service configures them later, order `fabric-table.service` after that service and require it through a systemd drop-in. Copying addresses into the facts file does not configure the interfaces. Missing addresses block restoration. -Status: **unsupported** for automatic recovery of the entire group after a -link reset. A reboot can remove routes and permanent neighbour entries on -the still-running adjacent hosts. Their boot units do not run again. After -the links and addresses are ready, apply the group table across all hosts -with `--execute`, then require group verification before resuming traffic. -The [DGX Spark validation record](dgx-spark-validation.md) separates successful -local boot restoration from this group recovery requirement. +Status: **implemented** for periodic recovery of missing local relay state. +A reboot can remove routes and permanent neighbour entries on running +adjacent hosts. Each host's timer reconciles its own table after links and +addresses become ready. Recovery is asynchronous; require group verification +before resuming a failed workload. It does not resume NCCL communicators or +guarantee recovery while cabling, addresses or ownership conflict with facts. +Source-specific hardware evidence is in the [qualification table](qualification.md). After reboot run `fabric verify --facts facts.json` from the workstation and -`systemctl status fabric-table.service` on the restarted host. To disable +inspect the fabric service and reconciliation timer on every host. To disable restoration run `sudo /usr/local/bin/fabric-tool remove-boot` locally, then -repeat with `--execute`. This removes the unit and inputs but leaves live -relays and the tool copy; use `remove` for live relays. +repeat with `--execute`. This stops reconciliation and removes the units and +inputs while leaving live relays, marker processes and the tool copy. +Run `remove-boot --execute` before `remove` when retiring a table, otherwise +the timer restores objects that removal deletes. ## Validation boundary diff --git a/fabric-tool/HARDWARE-TEST-PLAN.md b/fabric-tool/HARDWARE-TEST-PLAN.md index cff9e13..3ea788a 100644 --- a/fabric-tool/HARDWARE-TEST-PLAN.md +++ b/fabric-tool/HARDWARE-TEST-PLAN.md @@ -82,10 +82,11 @@ Reboot one host; wait for addresses and the unit to become ready. Require `verify` to pass for every host and repeat a relayed traffic probe. Record the systemd journal and counters. Keep any other installer's restore disabled. Record local restoration separately from group verification. A carrier reset -can remove adjacent hosts' routes and neighbours; boot-only units do not -repair those running hosts. If group verification fails, preserve that result, -reapply across the group under operator control, verify and repeat traffic. -Successful traffic after that repair does not qualify automatic group recovery. +can remove adjacent hosts' routes and neighbours. Require the periodic local +checks to restore those entries without an operator apply. Record convergence +time and verify that healthy marker PIDs remain unchanged across checks. +If group verification fails, preserve that result before operator repair; +successful traffic after repair does not qualify automatic group recovery. ## Remove and restore (about 10 minutes per ring) diff --git a/fabric-tool/README.md b/fabric-tool/README.md index bb6d7a7..8b57bcd 100644 --- a/fabric-tool/README.md +++ b/fabric-tool/README.md @@ -50,8 +50,8 @@ The installed copy of that guide is under `share/doc/net-sircl/`. | `status` | Show owned and unowned objects | | `install-marker` | Preview/build `mesh_marker.c` on hosts, install root-owned at `/usr/local/libexec/fabric-tool/fabric-tool-marker` and record its SHA-256 | | `remove` | Preview/remove owned relay objects | -| `install-boot` | Locally install `fabric-table.service`, tool copy and inputs, enable restoration and apply now | -| `remove-boot` | Locally disable/remove the unit and inputs; leave live table and tool copy | +| `install-boot` | Install the retained fabric service, periodic reconciliation service/timer, tool and inputs; apply now and start checks | +| `remove-boot` | Stop reconciliation and remove units/inputs; leave live table, markers and tool copy | `apply`, `verify`, `remove`, `status` and `install-marker` act locally by default. With `--ssh`, supply one target for **every** topology host. Host names must match diff --git a/fabric-tool/fabric_tool/boot.py b/fabric-tool/fabric_tool/boot.py index baeadba..d1ef2cb 100644 --- a/fabric-tool/fabric_tool/boot.py +++ b/fabric-tool/fabric_tool/boot.py @@ -1,12 +1,12 @@ -"""Boot persistence: the systemd unit that restores the relay table at boot. +"""Local relay restoration at boot and after link or marker loss. ``install-boot`` writes the unit ``fabric-table.service``, copies the topology file and the facts document to ``/etc/fabric-table/``, enables the unit and installs the table now; ``remove-boot`` disables and removes both. The unit -runs ``apply --boot --execute``, whose restore semantics add every missing object and -remove nothing, so a boot either reinstalls the whole table (``/run`` is -cleared, interfaces and their routes and filters come up empty, markers are -gone) or changes nothing while the table stands. +runs ``apply --boot --execute`` at startup and reload. A timer requests reload +every 15 seconds after the preceding check finishes. Restore semantics add +missing objects and remove nothing. Reload retains the service's marker +processes; restarting the service on each check would kill healthy markers. """ from __future__ import annotations @@ -19,6 +19,8 @@ from . import commands, model UNIT_NAME = "fabric-table.service" +RECOVERY_SERVICE = "fabric-table-reconcile.service" +RECOVERY_TIMER = "fabric-table-reconcile.timer" INPUT_DIR = "/etc/fabric-table" TOPOLOGY_INPUT = f"{INPUT_DIR}/topology" FACTS_INPUT = f"{INPUT_DIR}/facts.json" @@ -67,7 +69,9 @@ def unit_text(tool: str = DEFAULT_TOOL, *, invocation: RestoreInvocation | None "[Service]", "Type=oneshot", "ExecStart=" + " ".join(systemd_arg(arg) for arg in invocation.argv()), + "ExecReload=" + " ".join(systemd_arg(arg) for arg in invocation.argv()), "RemainAfterExit=yes", + "TimeoutStartSec=300", "", "[Install]", "WantedBy=multi-user.target", @@ -75,6 +79,21 @@ def unit_text(tool: str = DEFAULT_TOOL, *, invocation: RestoreInvocation | None ]) +def recovery_service_text() -> str: + """Run checks in the retained service's cgroup so markers survive each check.""" + return ("[Unit]\nDescription=Reconcile missing local fabric relay state\n\n" + "[Service]\nType=oneshot\n" + f"ExecStart=/usr/bin/systemctl reload-or-restart {UNIT_NAME}\n" + "TimeoutStartSec=330\n") + + +def recovery_timer_text() -> str: + """Retry incomplete restoration without overlapping local reconciliation jobs.""" + return ("[Unit]\nDescription=Check local fabric relay state periodically\n\n" + "[Timer]\nOnActiveSec=15s\nOnUnitInactiveSec=15s\nAccuracySec=1s\n" + f"Unit={RECOVERY_SERVICE}\n\n[Install]\nWantedBy=timers.target\n") + + def wrapper_text() -> str: """The ``fabric-tool`` entry point the unit runs: the package copied to ``LIB_DIR``.""" return ("#!/usr/bin/env python3\n" @@ -95,7 +114,7 @@ class BootPlan: @property def commands(self) -> tuple[str, ...]: - return ("systemctl daemon-reload", f"systemctl enable {UNIT_NAME}") + return ("systemctl daemon-reload", f"systemctl enable {UNIT_NAME} {RECOVERY_TIMER}") def plan(topology_path: str, facts_path: str, tool: str = DEFAULT_TOOL, *, @@ -106,7 +125,9 @@ def plan(topology_path: str, facts_path: str, tool: str = DEFAULT_TOOL, *, facts = facts_text if facts_text is not None else Path(facts_path).read_text(encoding="utf-8") return BootPlan(topology_path, facts_path, UNIT_NAME, ((TOPOLOGY_INPUT, topology), (FACTS_INPUT, facts), (f"/etc/systemd/system/{UNIT_NAME}", - unit_text(tool, invocation=invocation)))) + unit_text(tool, invocation=invocation)), + (f"/etc/systemd/system/{RECOVERY_SERVICE}", recovery_service_text()), + (f"/etc/systemd/system/{RECOVERY_TIMER}", recovery_timer_text()))) def install(spec: BootPlan, *, root: str = "/", execute: bool) -> list[str]: @@ -129,8 +150,13 @@ def remove(*, root: str = "/", execute: bool) -> list[str]: """Remove the unit and the copied inputs; with ``root`` (tests) under that directory.""" removed = [] if root == "/" and execute: + if Path(f"/etc/systemd/system/{RECOVERY_TIMER}").exists(): + subprocess.run(["systemctl", "disable", "--now", RECOVERY_TIMER], check=True) + if Path(f"/etc/systemd/system/{RECOVERY_SERVICE}").exists(): + subprocess.run(["systemctl", "stop", RECOVERY_SERVICE], check=True) subprocess.run(["systemctl", "disable", UNIT_NAME], check=True) - for destination in (f"/etc/systemd/system/{UNIT_NAME}", TOPOLOGY_INPUT, FACTS_INPUT): + for destination in (f"/etc/systemd/system/{UNIT_NAME}", f"/etc/systemd/system/{RECOVERY_SERVICE}", + f"/etc/systemd/system/{RECOVERY_TIMER}", TOPOLOGY_INPUT, FACTS_INPUT): path = Path(root) / destination.lstrip("/") if path.exists(): path.unlink() diff --git a/fabric-tool/fabric_tool/cli.py b/fabric-tool/fabric_tool/cli.py index ba06deb..85c84cb 100644 --- a/fabric-tool/fabric_tool/cli.py +++ b/fabric-tool/fabric_tool/cli.py @@ -315,6 +315,9 @@ def _command_install_boot(args: argparse.Namespace, topology: topology_mod.Topol facts_text=json.dumps(facts_mod.load(args.facts), indent=1) + "\n") print(f"unit {boot.UNIT_NAME}:") print(spec.files[2][1], end="") + for destination, content in spec.files[3:]: + print(f"unit {destination}:") + print(content, end="") for destination, _ in spec.files[:2]: print(f"input: {destination}") if not args.execute: @@ -342,12 +345,17 @@ def _command_install_boot(args: argparse.Namespace, topology: topology_mod.Topol wrapper.chmod(0o755) print(f"wrote {wrapper}") boot.install(spec, root=args.root, execute=True) - print(f"enabled {boot.UNIT_NAME}") - return _apply_flow(args, topology, "boot", executor) + print(f"enabled {boot.UNIT_NAME} and {boot.RECOVERY_TIMER}") + code = _apply_flow(args, topology, "boot", executor) + if code == 0 and args.root == "/": + subprocess.run(["systemctl", "start", boot.RECOVERY_TIMER], check=True) + return code def _command_remove_boot(args: argparse.Namespace) -> int: - removed = [f"/etc/systemd/system/{boot.UNIT_NAME}", boot.TOPOLOGY_INPUT, boot.FACTS_INPUT] + removed = [f"/etc/systemd/system/{name}" for name in + (boot.UNIT_NAME, boot.RECOVERY_SERVICE, boot.RECOVERY_TIMER)] + removed += [boot.TOPOLOGY_INPUT, boot.FACTS_INPUT] print("remove-boot deletes: " + ", ".join(removed) + "; the relay table itself stays until `remove`") if not args.execute: print("dry run: --execute removes them") diff --git a/fabric-tool/tests/test_boot.py b/fabric-tool/tests/test_boot.py index 6491879..b1a39e3 100644 --- a/fabric-tool/tests/test_boot.py +++ b/fabric-tool/tests/test_boot.py @@ -18,6 +18,26 @@ def test_unit_text(): assert "WantedBy=multi-user.target" in text +def test_recovery_reloads_the_retained_service_without_restarting_markers(tmp_path): + invocation = boot.RestoreInvocation(marker="/opt/relay/bin/marker", max_relays=2, host="node-1") + text = boot.unit_text(invocation=invocation) + reload_argv = shlex.split(next(line.removeprefix("ExecReload=") for line in text.splitlines() + if line.startswith("ExecReload="))) + assert reload_argv == list(invocation.argv()) + assert "RemainAfterExit=yes" in text + spec = boot.plan("topology", "facts", invocation=invocation, topology_text="hosts a b\n", facts_text="{}") + files = dict(spec.files) + recovery = files[f"/etc/systemd/system/{boot.RECOVERY_SERVICE}"] + timer = files[f"/etc/systemd/system/{boot.RECOVERY_TIMER}"] + assert f"ExecStart=/usr/bin/systemctl reload-or-restart {boot.UNIT_NAME}" in recovery + assert "RemainAfterExit" not in recovery + assert "OnUnitInactiveSec=15s" in timer + assert f"Unit={boot.RECOVERY_SERVICE}" in timer + boot.install(spec, root=str(tmp_path), execute=False) + boot.remove(root=str(tmp_path), execute=False) + assert not any((tmp_path / "etc/systemd/system").glob("fabric-table*")) + + def test_wrapper_runs_the_copied_package(): wrapper = boot.wrapper_text() assert wrapper.startswith("#!/usr/bin/env python3") @@ -32,15 +52,16 @@ def test_install_and_remove_under_a_fake_root(tmp_path): facts.write_text('{"schema": "fabric-tool-facts/v1", "hosts": []}', encoding="utf-8") spec = boot.plan(str(topology), str(facts)) assert [destination for destination, _ in spec.files] == [ - boot.TOPOLOGY_INPUT, boot.FACTS_INPUT, f"/etc/systemd/system/{boot.UNIT_NAME}"] + boot.TOPOLOGY_INPUT, boot.FACTS_INPUT, f"/etc/systemd/system/{boot.UNIT_NAME}", + f"/etc/systemd/system/{boot.RECOVERY_SERVICE}", f"/etc/systemd/system/{boot.RECOVERY_TIMER}"] written = boot.install(spec, root=str(tmp_path), execute=False) - assert len(written) == 3 + assert len(written) == 5 unit = tmp_path / "etc/systemd/system" / boot.UNIT_NAME assert unit.read_text().startswith("[Unit]") assert (tmp_path / "etc/fabric-table/topology").read_text() == "hosts a b\ncabling ring\n" removed = boot.remove(root=str(tmp_path), execute=False) assert not unit.exists() and not (tmp_path / "etc/fabric-table").exists() - assert len(removed) == 3 + assert len(removed) == 5 def test_remove_boot_cli_preview_and_execute(tmp_path): @@ -87,4 +108,5 @@ def systemctl(argv, **kwargs): monkeypatch.setattr(boot.subprocess, "run", systemctl) with pytest.raises(subprocess.CalledProcessError): boot.install(spec, execute=True) - assert calls == [["systemctl", "daemon-reload"], ["systemctl", "enable", boot.UNIT_NAME]] + assert calls == [["systemctl", "daemon-reload"], + ["systemctl", "enable", boot.UNIT_NAME, boot.RECOVERY_TIMER]] From 748142fb36850fb097454e4b4c01cf1b3070461e Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 10:51:30 -0500 Subject: [PATCH 08/12] Prevent unsafe LL128 selection in CPU-staged emulation Select LL and Simple for emulation subprocesses and reject protocol requests that enable LL128 unless diagnostic intent is explicit. Per-collective requests retain a safe global default. Record the selected protocols in the result. CPU memory copies do not guarantee LL128's ordered 128-byte data/flag visibility. Forced-LL128 corruption reproduces with two PyTorch versions and an independent native NCCL program; PyTorch is not a necessary cause. Excluding LL128 is a mitigation, not a claim that its memory-ordering requirement is implemented. The production RDMA plugin, tuner cost tables, wire and parent environment are unchanged. Diagnostic LL128 runs remain available with --allow-ll128. Validation: CPU selection checks cover defaults, explicit supported values, per-collective policies, exclusions and diagnostic opt-in. Existing fabric contracts and real systemd reload/cgroup integration pass independently. --- docs/compatibility.md | 22 +++++++++++------ docs/testing.md | 8 ++++++ net-sircl/tests/emulation/nccl_e2e.py | 35 +++++++++++++++++++++++++-- tests/test_emulation_protocols.py | 28 +++++++++++++++++++++ 4 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 tests/test_emulation_protocols.py diff --git a/docs/compatibility.md b/docs/compatibility.md index 63183ae..a70e3d0 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -41,14 +41,20 @@ not qualify every binary carrying that version. The source, compiled libraries, PyTorch versions and loaded NCCL library. Complete framework workloads and community vLLM images remain unqualified. -Status: **unsupported** for four ranks sharing one GB10 GPU with PyTorch -2.11.0+cu130, NCCL 2.32.3 and forced LL128. Exact checks fail with both the -shared-memory verbs plugin and NCCL Socket under those conditions. LL and -Simple pass the corresponding protocol probes; selecting Simple also passes -the seven-case channel matrix. These observations do not establish a failure -of the physical RDMA transport. The cached NGC PyTorch 26.09 image with -PyTorch 2.14.0a0 and loaded NCCL 2.32.3 passes the channel matrix without a -protocol override. Do not generalize either result to untested combinations. +Status: **implemented** for safe protocol selection in CPU-staged emulation: +the launcher defaults to LL and Simple and rejects an LL128-enabling request +unless `--allow-ll128` explicitly permits a diagnostic run. The production +RDMA plugin's protocol costs are unchanged. + +Raw LL128 on the CPU-staged path is **unsupported**. Four ranks sharing one +GB10 with NCCL 2.32.3 fail forced-LL128 exact checks under PyTorch 2.11.0+cu130 +and NGC PyTorch 26.09's 2.14.0a0, including Socket controls. An independent +native NCCL probe also fails through sircl emulation. This rules out PyTorch +as a necessary cause. NVIDIA's [protocol explanation](https://github.com/NVIDIA/nccl/issues/281) +requires ordered 128-byte data/flag visibility and cautions against forcing +LL128 when the buffer or interconnect lacks it. The emulator's CPU `memmove` +does not provide that guarantee. Safe selection is a mitigation, not an +implementation of LL128 or proof of an upstream runtime defect. `scripts/check_e2e.py --expected-version 23102` queries `ncclGetVersion` after importing PyTorch and fails if the loaded version differs. It then verifies the diff --git a/docs/testing.md b/docs/testing.md index 508bf5d..2990e80 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -58,6 +58,14 @@ at six sizes from 8 KiB to 64 MiB, plus 20 CUDA-graph replays at 64 KiB. Graphs are released before process-group destruction. Each rank must select sircl, report seven exact-result lines and exit successfully. +The launcher restricts CPU-staged emulation to LL and Simple. LL128 relies on +128-byte data/flag visibility that ordinary CPU copies do not guarantee; it +is not qualified by a passing run. A request that enables LL128 is rejected +before ranks start. `--allow-ll128` is an explicit diagnostic opt-in for the +launcher, including its Socket control; it may produce incorrect results. +This policy affects emulation subprocesses only. The production RDMA plugin's +tuner and the process-wide environment are unchanged. + Logs and JSON summaries go under `test-results/`, which Git ignores and `make package` excludes. Logs contain this machine's host name; check them before sharing. The emulator moves bytes in shared memory and models no NIC, diff --git a/net-sircl/tests/emulation/nccl_e2e.py b/net-sircl/tests/emulation/nccl_e2e.py index 0c62894..96205df 100644 --- a/net-sircl/tests/emulation/nccl_e2e.py +++ b/net-sircl/tests/emulation/nccl_e2e.py @@ -35,6 +35,28 @@ SIZES = [8 << 10, 64 << 10, 512 << 10, 4 << 20, 32 << 20, 64 << 20] +def select_protocols(value, *, allow_ll128): + """Restrict CPU-staged transfers to LL/Simple unless LL128 is diagnostic intent.""" + if allow_ll128: + return value or "LL,LL128,Simple" + value = value or "LL,Simple" + clauses = value.split(";") + if ":" in clauses[0]: + clauses.insert(0, "LL,Simple") + protocols = {"LL", "LL128", "SIMPLE"} + for clause in clauses: + selection = clause.rsplit(":", 1)[-1] + excluded = selection.startswith("^") + selected = set(selection.lstrip("^").upper().split(",")) + if not selected <= protocols: + raise ValueError("invalid NCCL_PROTO selection for emulation") + enabled = protocols - selected if excluded else selected + if "LL128" in enabled: + raise ValueError("LL128 is unsafe for CPU-staged emulation; use LL,Simple or " + "--allow-ll128 for a diagnostic run that may produce incorrect data") + return ";".join(clauses) + + def rank_main(args): import torch import torch.distributed as dist @@ -105,7 +127,10 @@ def launch(args): base = dict(os.environ, WORLD_SIZE=str(args.world_size), MASTER_ADDR="127.0.0.1", MASTER_PORT=str(29500 + os.getpid() % 500), NCCL_MULTI_RANK_GPU_ENABLE="1", NCCL_P2P_DISABLE="1", NCCL_SHM_DISABLE="1", NCCL_NVLS_ENABLE="0", NCCL_DEBUG="INFO", - NCCL_DEBUG_SUBSYS="INIT,NET,TUNING", NCCL_SOCKET_IFNAME="lo") + NCCL_DEBUG_SUBSYS="INIT,NET,TUNING", NCCL_SOCKET_IFNAME="lo", + NCCL_PROTO=select_protocols(os.environ.get("NCCL_PROTO"), allow_ll128=args.allow_ll128)) + if args.allow_ll128: + print("diagnostic LL128 opt-in: CPU-staged transfers may produce incorrect data", file=sys.stderr) if args.net == "sircl": base.update(NCCL_NET="sircl", NCCL_NET_PLUGIN=args.plugin, NET_SIRCL_OOB_ADDR="127.0.0.1", SIRCL_EMU_FABRIC=f"/sircl-emu-glm-e2e-{os.getpid()}", NET_SIRCL_STANDIN_DEVICES="4") @@ -152,7 +177,7 @@ def launch(args): if os.path.exists(shm): os.unlink(shm) rendezvous.cleanup() - summary = {"net": args.net, "teardown": args.teardown, "windowed": args.windowed, + summary = {"net": args.net, "teardown": args.teardown, "windowed": args.windowed, "protocols": base["NCCL_PROTO"], "backend": "native" if args.native else "pytorch", "ranks": results} print(json.dumps(summary)) return 0 if all(r["pass"] and r["exit"] == 0 and not r["wrong"] and @@ -165,6 +190,8 @@ def main(): parser.add_argument("--rank", action="store_true") parser.add_argument("--teardown", choices=("release-graph", "keep-graph"), default="release-graph") parser.add_argument("--net", choices=("sircl", "socket"), default="sircl") + parser.add_argument("--allow-ll128", action="store_true", + help="allow LL128 in CPU-staged emulation for diagnosis; correctness is not guaranteed") parser.add_argument("--windowed", action="store_true") parser.add_argument("--world-size", type=int, default=2) parser.add_argument("--layout", choices=("path", "ring"), default="path") @@ -187,6 +214,10 @@ def main(): parser.error("the native backend releases its graph before communicator teardown") if args.rank: return rank_main(args) + try: + select_protocols(os.environ.get("NCCL_PROTO"), allow_ll128=args.allow_ll128) + except ValueError as error: + parser.error(str(error)) return launch(args) diff --git a/tests/test_emulation_protocols.py b/tests/test_emulation_protocols.py new file mode 100644 index 0000000..10f86e7 --- /dev/null +++ b/tests/test_emulation_protocols.py @@ -0,0 +1,28 @@ +"""CPU-staged emulation must not select LL128 without diagnostic opt-in.""" +import importlib.util +from pathlib import Path +import unittest + +path = Path(__file__).resolve().parents[1] / 'net-sircl/tests/emulation/nccl_e2e.py' +spec = importlib.util.spec_from_file_location('nccl_emulation', path) +emulation = importlib.util.module_from_spec(spec) +spec.loader.exec_module(emulation) + + +class EmulationProtocols(unittest.TestCase): + def test_supported_protocol_selection(self): + cases = [(None, 'LL,Simple'), ('', 'LL,Simple'), ('LL', 'LL'), ('Simple', 'Simple'), + ('^LL128', '^LL128'), ('LL,Simple', 'LL,Simple'), + ('allreduce:Simple;broadcast:LL', 'LL,Simple;allreduce:Simple;broadcast:LL'), + ('^LL128;allreduce:Simple', '^LL128;allreduce:Simple')] + for value, expected in cases: + with self.subTest(value=value): + self.assertEqual(emulation.select_protocols(value, allow_ll128=False), expected) + + def test_ll128_requires_explicit_diagnostic_opt_in(self): + for value in ['LL128', 'LL,LL128,Simple', '^Simple', 'allreduce:LL128', '^LL128;broadcast:LL128']: + with self.subTest(value=value), self.assertRaisesRegex(ValueError, 'LL128'): + emulation.select_protocols(value, allow_ll128=False) + + def test_diagnostic_opt_in_preserves_protocol_request(self): + self.assertEqual(emulation.select_protocols('LL128', allow_ll128=True), 'LL128') From 5c76ef48878e9cef802b1aae1d5b9abb673ba37d Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:05:31 -0500 Subject: [PATCH 09/12] Wait for restoration before replacing or removing boot inputs Stopping the periodic systemctl client does not cancel its manager-side reload job. Stop scheduling and wait for the fabric service's active and queued jobs to finish before removing inputs or replacing installed code. Keep marker processes alive. A bounded wait retains inputs on timeout. Validation: a real systemd regression with a delayed reload fails without the wait and passes with it; removal waits 3.35 seconds and preserves the marker. Fabric tests cover a queued reload and input lifetime; 146 pass. This changes installer coordination only, with no transport ABI or wire change. --- fabric-tool/fabric_tool/boot.py | 29 ++++++++++++++++++++++++++--- fabric-tool/fabric_tool/cli.py | 2 ++ fabric-tool/tests/test_boot.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/fabric-tool/fabric_tool/boot.py b/fabric-tool/fabric_tool/boot.py index d1ef2cb..ce1597a 100644 --- a/fabric-tool/fabric_tool/boot.py +++ b/fabric-tool/fabric_tool/boot.py @@ -14,6 +14,7 @@ import dataclasses import shutil import subprocess +import time from pathlib import Path from . import commands, model @@ -146,14 +147,36 @@ def install(spec: BootPlan, *, root: str = "/", execute: bool) -> list[str]: return written +def _wait_for_restoration() -> None: + """A stopped systemctl client can leave its manager-side reload job running.""" + deadline = time.monotonic() + 330 + while True: + result = subprocess.run(["systemctl", "show", UNIT_NAME, "--property=ActiveState", "--property=Job"], + check=True, capture_output=True, text=True, timeout=10) + state = dict(line.split("=", 1) for line in result.stdout.splitlines() if "=" in line) + if state.get("ActiveState") not in ("activating", "reloading") and state.get("Job") in ("", "0"): + return + if time.monotonic() >= deadline: + raise TimeoutError("fabric restoration is still running; boot inputs were retained") + time.sleep(0.1) + + +def stop_reconciliation() -> None: + """Stop scheduling and wait for restoration before changing its code or inputs.""" + if Path(f"/etc/systemd/system/{RECOVERY_TIMER}").exists(): + subprocess.run(["systemctl", "stop", RECOVERY_TIMER], check=True) + if Path(f"/etc/systemd/system/{RECOVERY_SERVICE}").exists(): + subprocess.run(["systemctl", "stop", RECOVERY_SERVICE], check=True) + _wait_for_restoration() + + def remove(*, root: str = "/", execute: bool) -> list[str]: """Remove the unit and the copied inputs; with ``root`` (tests) under that directory.""" removed = [] if root == "/" and execute: + stop_reconciliation() if Path(f"/etc/systemd/system/{RECOVERY_TIMER}").exists(): - subprocess.run(["systemctl", "disable", "--now", RECOVERY_TIMER], check=True) - if Path(f"/etc/systemd/system/{RECOVERY_SERVICE}").exists(): - subprocess.run(["systemctl", "stop", RECOVERY_SERVICE], check=True) + subprocess.run(["systemctl", "disable", RECOVERY_TIMER], check=True) subprocess.run(["systemctl", "disable", UNIT_NAME], check=True) for destination in (f"/etc/systemd/system/{UNIT_NAME}", f"/etc/systemd/system/{RECOVERY_SERVICE}", f"/etc/systemd/system/{RECOVERY_TIMER}", TOPOLOGY_INPUT, FACTS_INPUT): diff --git a/fabric-tool/fabric_tool/cli.py b/fabric-tool/fabric_tool/cli.py index 85c84cb..822f917 100644 --- a/fabric-tool/fabric_tool/cli.py +++ b/fabric-tool/fabric_tool/cli.py @@ -335,6 +335,8 @@ def _command_install_boot(args: argparse.Namespace, topology: topology_mod.Topol _print_outcome(outcome, args, scripts=False) return 3 if args.root == "/": + if Path(f"/etc/systemd/system/{boot.RECOVERY_TIMER}").exists(): + boot.stop_reconciliation() source = Path(__file__).resolve().parents[1] target = Path(boot.LIB_DIR) if target.resolve() != source.resolve(): diff --git a/fabric-tool/tests/test_boot.py b/fabric-tool/tests/test_boot.py index b1a39e3..504b4dd 100644 --- a/fabric-tool/tests/test_boot.py +++ b/fabric-tool/tests/test_boot.py @@ -110,3 +110,31 @@ def systemctl(argv, **kwargs): boot.install(spec, execute=True) assert calls == [["systemctl", "daemon-reload"], ["systemctl", "enable", boot.UNIT_NAME, boot.RECOVERY_TIMER]] + + +def test_removal_keeps_inputs_until_the_manager_job_is_idle(tmp_path, monkeypatch): + from pathlib import Path + import subprocess + + spec = boot.plan('topology', 'facts', topology_text='hosts a b\n', facts_text='{}') + boot.install(spec, root=str(tmp_path), execute=False) + files = [tmp_path / name.lstrip('/') for name, _ in spec.files] + states = iter(['ActiveState=active\nJob=42\n', 'ActiveState=reloading\nJob=42\n', + 'ActiveState=active\nJob=\n']) + observations = [] + + def systemctl(argv, **kwargs): + output = '' + if argv[1] == 'show': + assert all(path.exists() for path in files) + output = next(states) + observations.append(output) + return subprocess.CompletedProcess(argv, 0, stdout=output) + + monkeypatch.setattr(boot, 'Path', lambda value: tmp_path / str(value).lstrip('/') + if str(value).startswith('/') else Path(value)) + monkeypatch.setattr(boot.subprocess, 'run', systemctl) + monkeypatch.setattr(boot.time, 'sleep', lambda _: None) + boot.remove(execute=True) + assert len(observations) == 3 + assert not any(path.exists() for path in files) From 3e14c8a437d9409664e63881e1dacc6ef42407a4 Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:08:15 -0500 Subject: [PATCH 10/12] Record autonomous relay recovery and safe emulation evidence Qualify periodic local restoration on a four-host Spark path. A middle-host reboot converges without operator repair, injected route/neighbor loss is repaired, healthy marker PIDs persist and pre/post traffic passes. Record exact source, binary and NCCL identities with sanitized measurements. Qualify the LL/Simple selection mitigation with both tested PyTorch versions. Retain the unsupported status of raw LL128 and the native/PyTorch controls; do not imply that CPU copies implement its visibility requirement. Record pending-job retirement and the restored serving state. Transport interfaces and hardware wire behavior are unchanged. Validation: 16 physical sweeps with 256 size rows, zero reported correctness errors and zero monitored error/drop growth; 14 GPU channel cases; unsafe request rejection; real systemd timer/reload and retirement checks; 146 fabric tests; source/archive CPU and installed-documentation checks; privacy and whitespace scans. --- docs/dgx-spark-validation.md | 15 +- docs/evidence/recovery.json | 1764 ++++++++++++++++++++++++++++++++++ docs/qualification.md | 11 +- docs/recovery-validation.md | 102 ++ 4 files changed, 1882 insertions(+), 10 deletions(-) create mode 100644 docs/evidence/recovery.json create mode 100644 docs/recovery-validation.md diff --git a/docs/dgx-spark-validation.md b/docs/dgx-spark-validation.md index 9ee8506..f5b66bd 100644 --- a/docs/dgx-spark-validation.md +++ b/docs/dgx-spark-validation.md @@ -1,7 +1,8 @@ # DGX Spark transport and fabric validation -Product status: **research-only**. The checks below qualify specific behavior; -automatic group recovery and arbitrary framework workloads remain unsupported. +Product status: **research-only**. This record qualifies the specific source +artifacts identified below. Periodic restoration and safe emulation protocol +selection have a separate [validation record](recovery-validation.md). Measurements were collected on 2026-10-23. The structured [measurement artifact](evidence/dgx-spark-transport.json) contains per-sweep results, timings, platform versions, GPU checks and negative controls. @@ -97,7 +98,8 @@ addresses; restoration refuses all changes. Complete facts do not configure those addresses. The successful local boot check uses a temporary prerequisite service to restore saved addresses before the unmodified fabric unit runs. -Automatic group recovery is **unsupported**. The reboot also resets neighboring +The boot-only service in the recorded source does not recover the entire group. +The reboot also resets neighboring carriers. Two running neighbors lose six routes and six neighbor entries in total; group verification fails although the rebooted host verifies. Explicit apply across all four hosts repairs the group; verification and the repeated @@ -135,6 +137,7 @@ remote mappings, 1,536 simultaneous registrations and 300 completion queues; a reduced cache bound forces eviction. All eight aarch64 builds produce the same production-library hash. -No vLLM/SGLang server, training job, physical packet-loss recovery, rank-loss -recovery, exhaustive concurrency envelope or automatic group recovery is -qualified. Site host names, addresses, keys and raw service logs remain private. +These measurements do not qualify vLLM/SGLang serving, training jobs, physical +packet-loss recovery, rank-loss recovery or an exhaustive concurrency envelope. +Periodic group restoration is scoped separately in the recovery validation. +Site host names, addresses, keys and raw service logs remain private. diff --git a/docs/evidence/recovery.json b/docs/evidence/recovery.json new file mode 100644 index 0000000..2eb7486 --- /dev/null +++ b/docs/evidence/recovery.json @@ -0,0 +1,1764 @@ +{ + "schema": "net-sircl-recovery-validation/v1", + "measured_date": "2026-10-23", + "source_revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "production_plugin_sha256": "a2f33a58b2a1f3ab6e8d1b328de4c57b087785236651075ad3e59e6545c9ee14", + "nccl_version": "2.32.3", + "nccl_library_sha256": "c77f5ced2c4b538aad2b0ab88a9838e9eac9a68e22017863ffb0cff9c4f58745", + "conditions": { + "hosts": 4, + "gpu": "NVIDIA GB10", + "cabling": "path", + "timer_inactive_interval_seconds": 15, + "independent_address_service": true, + "collectives": [ + "all_reduce", + "all_gather", + "reduce_scatter", + "broadcast" + ], + "modes": [ + "eager", + "graph" + ], + "sizes_bytes": [ + 8192, + 268435456 + ], + "size_multiplier": 2, + "warmups": 2, + "iterations": 5, + "graph_replays": 20, + "clock_policy": "not fixed; throughput qualification excluded" + }, + "reboot": { + "source": "748142fb36850fb097454e4b4c01cf1b3070461e", + "boot_identity_changed": true, + "administration_return_seconds": 125.77, + "group_convergence_seconds": 126.76, + "verification_exits": [ + 0 + ], + "operator_repair": false, + "unaffected_marker_pids_preserved": true, + "serving_health_http": 200 + }, + "injected_loss": { + "route_and_neighbor_removed": true, + "operator_repair": false, + "convergence_seconds": 12.88, + "verification_exits": [ + 1, + 1, + 1, + 1, + 0 + ] + }, + "physical": { + "before-reboot": { + "layout": "four_host_path", + "cases": 8, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 5.45, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "14007.5", + "9.58", + "14.37", + "0", + "13968.2", + "9.61", + "14.41", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "28024.2", + "9.58", + "14.37", + "0", + "28138.4", + "9.54", + "14.31", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_reduce", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 17.36, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "13972.2", + "9.61", + "14.41", + "0", + "13991.6", + "9.59", + "14.39", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "28571.9", + "9.40", + "14.09", + "0", + "28589.8", + "9.39", + "14.08", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_reduce", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.98, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "7286.39", + "18.42", + "13.82", + "0", + "7318.91", + "18.34", + "13.75", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14345.0", + "18.71", + "14.03", + "0", + "14354.7", + "18.70", + "14.03", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_gather", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 11.28, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "7299.90", + "18.39", + "13.79", + "0", + "7196.97", + "18.65", + "13.99", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14701.9", + "18.26", + "13.69", + "0", + "14502.9", + "18.51", + "13.88", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_gather", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.9, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6888.75", + "19.48", + "14.61", + "0", + "7072.31", + "18.98", + "14.23", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "13736.0", + "19.54", + "14.66", + "0", + "13637.1", + "19.68", + "14.76", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "reduce_scatter", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 11.35, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6716.08", + "19.98", + "14.99", + "0", + "6727.83", + "19.95", + "14.96", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "13760.0", + "19.51", + "14.63", + "0", + "13777.4", + "19.48", + "14.61", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "reduce_scatter", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.85, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "6140.87", + "21.86", + "21.86", + "0", + "6207.79", + "21.62", + "21.62", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11729.5", + "22.89", + "22.89", + "0", + "11760.9", + "22.82", + "22.82", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "broadcast", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 9.8, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5795.93", + "23.16", + "23.16", + "0", + "5792.46", + "23.17", + "23.17", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11276.2", + "23.81", + "23.81", + "0", + "11268.2", + "23.82", + "23.82", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "broadcast", + "mode": "graph" + } + ] + }, + "after-reboot": { + "layout": "four_host_path", + "cases": 8, + "passed": true, + "counter_deltas": {}, + "missing_counters": { + "0": [], + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [] + }, + "measurements": [ + { + "exit": 0, + "seconds": 5.44, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "13699.3", + "9.80", + "14.70", + "0", + "13894.8", + "9.66", + "14.49", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "28013.0", + "9.58", + "14.37", + "0", + "28721.3", + "9.35", + "14.02", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_reduce", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 16.81, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "sum", + "-1", + "13718.7", + "9.78", + "14.68", + "0", + "13647.5", + "9.83", + "14.75", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "sum", + "-1", + "28130.0", + "9.54", + "14.31", + "0", + "28137.1", + "9.54", + "14.31", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_reduce", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.83, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "7115.66", + "18.86", + "14.15", + "0", + "7061.59", + "19.01", + "14.26", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14295.0", + "18.78", + "14.08", + "0", + "13942.5", + "19.25", + "14.44", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_gather", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.79, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "none", + "-1", + "6958.90", + "19.29", + "14.47", + "0", + "6826.41", + "19.66", + "14.75", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "none", + "-1", + "14066.5", + "19.08", + "14.31", + "0", + "14018.5", + "19.15", + "14.36", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "all_gather", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.37, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6825.08", + "19.67", + "14.75", + "0", + "6577.78", + "20.40", + "15.30", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "13873.1", + "19.35", + "14.51", + "0", + "13638.2", + "19.68", + "14.76", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "reduce_scatter", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 11.37, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "16777216", + "bfloat16", + "sum", + "-1", + "6615.22", + "20.29", + "15.22", + "0", + "6621.40", + "20.27", + "15.20", + "0" + ], + [ + "268435456", + "33554432", + "bfloat16", + "sum", + "-1", + "13693.6", + "19.60", + "14.70", + "0", + "13664.0", + "19.65", + "14.73", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "reduce_scatter", + "mode": "graph" + }, + { + "exit": 0, + "seconds": 4.33, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5998.98", + "22.37", + "22.37", + "0", + "6002.32", + "22.36", + "22.36", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11458.5", + "23.43", + "23.43", + "0", + "11494.4", + "23.35", + "23.35", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "broadcast", + "mode": "eager" + }, + { + "exit": 0, + "seconds": 10.02, + "rows": 16, + "out_of_bounds": [ + 0 + ], + "using_sircl": true, + "largest_rows": [ + [ + "134217728", + "67108864", + "bfloat16", + "none", + "0", + "5769.11", + "23.26", + "23.26", + "0", + "5767.88", + "23.27", + "23.27", + "0" + ], + [ + "268435456", + "134217728", + "bfloat16", + "none", + "0", + "11256.8", + "23.85", + "23.85", + "0", + "11243.6", + "23.87", + "23.87", + "0" + ] + ], + "revision": "748142fb36850fb097454e4b4c01cf1b3070461e", + "collective": "broadcast", + "mode": "graph" + } + ] + } + }, + "host_framework": { + "source": "748142fb36850fb097454e4b4c01cf1b3070461e", + "framework": "PyTorch 2.11.0+cu130", + "nccl": "2.32.3", + "exit": 0, + "seconds": 65.26, + "cases": [ + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.47 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.48 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.48 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.48 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null + ], + "case": "path4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.52 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.63 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.63 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.59 s", + "plugin": true, + "wrong": false + }, + { + "rank": 4, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.55 s", + "plugin": true, + "wrong": false + }, + { + "rank": 5, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.58 s", + "plugin": true, + "wrong": false + }, + { + "rank": 6, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.62 s", + "plugin": true, + "wrong": false + }, + { + "rank": 7, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.62 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null, + null, + null, + null, + null + ], + "case": "cycle8" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.29 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.31 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.28 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.33 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair-stock-tuner" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 4, + null, + null, + null + ], + "case": "override4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.10 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.12 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 16, + null, + null, + null + ], + "case": "override16" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.34 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.24 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.34 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null, + null, + null + ], + "case": "disabled" + } + ] + }, + "container_framework": { + "framework": "PyTorch 2.14.0a0+b2c75dd062.nv26.09", + "image": "nvcr.io/nvidia/pytorch:26.09-py3", + "image_id": "sha256:a2d1be1817a6ecf66c56d60e4ab76c1ff745b407c31b4a7a76c1021f8a013d53", + "runs": [ + { + "case": "channels", + "exit": 0, + "seconds": 67.83 + }, + { + "case": "reject-ll128", + "exit": 2, + "seconds": 0.37 + } + ], + "cases": [ + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.27 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.31 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.31 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.31 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null + ], + "case": "path4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.60 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.59 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.61 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.61 s", + "plugin": true, + "wrong": false + }, + { + "rank": 4, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.60 s", + "plugin": true, + "wrong": false + }, + { + "rank": 5, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.60 s", + "plugin": true, + "wrong": false + }, + { + "rank": 6, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.54 s", + "plugin": true, + "wrong": false + }, + { + "rank": 7, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.55 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 8, + null, + null, + null, + null, + null, + null, + null + ], + "case": "cycle8" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.31 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.31 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.26 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null + ], + "case": "pair-stock-tuner" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 4, + null, + null, + null + ], + "case": "override4" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.17 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.17 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.17 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.17 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 16, + null, + null, + null + ], + "case": "override16" + }, + { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "protocols": "LL,Simple", + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.35 s", + "plugin": true, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.39 s", + "plugin": true, + "wrong": false + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.34 s", + "plugin": true, + "wrong": false + } + ], + "max_active_channels": [ + 64, + null, + null, + null + ], + "case": "disabled" + } + ] + }, + "raw_ll128_native": [ + { + "net": "sircl", + "protocol": "LL128", + "exits": [ + 1, + 1, + 1, + 1 + ], + "seconds": 3.45 + }, + { + "net": "Socket", + "protocol": "LL128", + "exits": [ + 0, + 0, + 0, + 0 + ], + "seconds": 4.0 + }, + { + "net": "sircl", + "protocol": "Simple", + "exits": [ + 0, + 0, + 0, + 0 + ], + "seconds": 3.24 + } + ], + "raw_ll128_pytorch": [ + { + "net": "sircl", + "extra": {}, + "exit": 1, + "seconds": 7.78, + "summary": { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 1, + "pass": false, + "exact_lines": 4, + "teardown": "0.29 s", + "plugin": true, + "wrong": true + }, + { + "rank": 1, + "exit": 1, + "pass": false, + "exact_lines": 5, + "teardown": "0.28 s", + "plugin": true, + "wrong": true + }, + { + "rank": 2, + "exit": 1, + "pass": false, + "exact_lines": 5, + "teardown": "0.26 s", + "plugin": true, + "wrong": true + }, + { + "rank": 3, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.29 s", + "plugin": true, + "wrong": false + } + ] + } + }, + { + "net": "socket", + "extra": {}, + "exit": 1, + "seconds": 8.28, + "summary": { + "net": "socket", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 1, + "pass": false, + "exact_lines": 3, + "teardown": "0.30 s", + "plugin": false, + "wrong": true + }, + { + "rank": 1, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.30 s", + "plugin": false, + "wrong": false + }, + { + "rank": 2, + "exit": 0, + "pass": true, + "exact_lines": 7, + "teardown": "0.30 s", + "plugin": false, + "wrong": false + }, + { + "rank": 3, + "exit": 1, + "pass": false, + "exact_lines": 5, + "teardown": "0.30 s", + "plugin": false, + "wrong": true + } + ] + } + }, + { + "net": "sircl", + "extra": { + "NCCL_CGA_CLUSTER_SIZE": "1" + }, + "exit": 1, + "seconds": 7.86, + "summary": { + "net": "sircl", + "teardown": "release-graph", + "windowed": false, + "backend": "pytorch", + "ranks": [ + { + "rank": 0, + "exit": 1, + "pass": false, + "exact_lines": 4, + "teardown": "0.46 s", + "plugin": true, + "wrong": true + }, + { + "rank": 1, + "exit": 1, + "pass": false, + "exact_lines": 5, + "teardown": "0.46 s", + "plugin": true, + "wrong": true + }, + { + "rank": 2, + "exit": 1, + "pass": false, + "exact_lines": 5, + "teardown": "0.46 s", + "plugin": true, + "wrong": true + }, + { + "rank": 3, + "exit": 1, + "pass": false, + "exact_lines": 5, + "teardown": "0.46 s", + "plugin": true, + "wrong": true + } + ] + } + } + ], + "restoration": { + "original_owner_restored": true, + "fabric_verified": true, + "serving_health_http": 200, + "recovery_timer": "active" + }, + "limits": [ + "LL128 visibility is not implemented by CPU-staged emulation; safe protocol selection is a mitigation", + "Reconciliation restores local relay objects after links and independently configured addresses are ready", + "Interrupted NCCL communicators and application jobs are not resumed", + "One reboot and one state-loss injection on a four-host path; other failure patterns are not qualified" + ], + "installer_coordination_revision": "5c76ef48878e9cef802b1aae1d5b9abb673ba37d", + "systemd_retirement_check": { + "passed": true, + "wait_seconds": 3.48, + "marker_preserved": true, + "pending_job_completed_before_input_removal": true + } +} diff --git a/docs/qualification.md b/docs/qualification.md index 3a72b38..5bf0775 100644 --- a/docs/qualification.md +++ b/docs/qualification.md @@ -4,20 +4,23 @@ Product status: **research-only**. A qualified check applies to its source, compiled artifact, runtime, topology and workload. Component version strings alone do not identify the tested implementation. -The [DGX Spark validation record](dgx-spark-validation.md) and its +The [recovery and protocol validation](recovery-validation.md) records periodic +restoration and safe emulation selection. The +[DGX Spark transport validation record](dgx-spark-validation.md) and its [measurement artifact](evidence/dgx-spark-transport.json) identify source revision `ddc39fa07cd57010769a77094d0a6aad1efb9fbb`, compiled-library hashes, matched controls, results and limitations. | Component | Conditions and measurement | Status and conclusion | |---|---|---| -| Physical RDMA plugin | Recorded revision; NCCL 2.32.3; direct pair, four-host path, eight-host ring and opposite ring endpoints; four collectives, eager and graphs, 8 KiB–256 MiB | **Qualified** for 32 sweeps of that revision. Across implementation and baseline controls, 72 sweeps contain 1,152 size rows with zero correctness errors and no monitored error/drop-counter growth. No throughput guarantee | +| Physical RDMA plugin | Artifacts identified by the two validation records; NCCL 2.32.3; four collectives, eager and graphs, 8 KiB–256 MiB | **Qualified** for the recorded topologies and artifacts. Transport controls total 72 sweeps; recovery checks add 16 four-host-path sweeps. Zero reported correctness errors or monitored error/drop growth. No throughput guarantee | | Physical PyTorch graph lifetime | Four hosts, one GPU/rank per host; NGC PyTorch 26.09 with NCCL 2.32.3; eight eager checks and 20 graph replays; graph references released before destruction | **Qualified** before reboot and after group reconciliation; nine exact-result lines per rank, destruction 0.32–0.36 seconds | | Standalone fabric tool | Real four-host path and eight-host ring; apply, verify, idempotency, removal and unrelated-filter preservation | **Qualified** for those operations; pre-existing clsact and unrelated filter retained | | Local boot restoration | One middle path host rebooted; complete facts and independently persisted interface addresses; custom marker and relay limit | **Qualified** for restoration on that host; service applied and verified its local table | -| Group recovery after carrier reset | Rebooted host restores locally; two running neighbors lose six routes and six neighbor entries | **Unsupported** for automatic group recovery. Explicit group apply and verification restore traffic; the boot-only service does not reconcile running neighbors | +| Periodic group recovery after carrier reset | Four-host path; local 15-second reconciliation timers; independently persisted addresses; middle-host reboot | **Qualified** for the recorded check: group verifies after 126.76 seconds without operator repair; unaffected marker PIDs retained. An injected route/neighbor deletion converges in 12.88 seconds. Interrupted application jobs are not resumed | | Shared-memory verbs emulator | Eight local ranks and NCCL initialization pools; cached PyTorch 26.09 image, loaded NCCL 2.32.3 | **Qualified** for the seven-case channel matrix. CPU tests cover admission, worker retirement, mapping leases and registry bounds. Physical loss recovery and NIC performance unsupported | -| Shared-GPU LL128 combination | Four ranks on one GB10; PyTorch 2.11.0+cu130; NCCL 2.32.3; forced LL128 | **Unsupported**: exact checks fail with both sircl emulation and NCCL Socket. LL and Simple probes pass; Simple passes the channel matrix | +| Emulation protocol selection | CPU-staged transfers; NCCL 2.32.3; PyTorch 2.11.0+cu130 and NGC PyTorch 26.09 | **Qualified** for seven channel cases in each runtime using LL/Simple. LL128-enabling requests require diagnostic opt-in; otherwise rejected before ranks start | +| Raw LL128 through CPU-staged emulation | Independent native NCCL probe and two PyTorch versions on GB10 | **Unsupported**. CPU copies lack the protocol's required visibility guarantee. Safe selection is a mitigation; physical RDMA protocol costs are unchanged | | Distributed source manifest `SOURCE.json`, field `source_sha256` | Every distributed C/C++ source and header, including marker and tests; inventory completeness and hash equality | **Implemented** provenance check; equality alone does not establish hardware qualification | Historical plugin and framework measurements are retained in diff --git a/docs/recovery-validation.md b/docs/recovery-validation.md new file mode 100644 index 0000000..148406f --- /dev/null +++ b/docs/recovery-validation.md @@ -0,0 +1,102 @@ +# Relay recovery and emulation protocol validation + +Product status: **research-only**. Periodic relay restoration and safe protocol +selection are **qualified** for the checks below. Raw LL128 on the CPU-staged +emulation path remains **unsupported**; selecting supported protocols is a +mitigation, not an LL128 implementation. + +Measurements collected on 2026-10-23 are in the structured +[recovery evidence](evidence/recovery.json). The transport and runtime context +is also documented in [DGX Spark validation](dgx-spark-validation.md). + +## Artifact and execution conditions + +The source containing periodic restoration and protocol selection is +`748142fb36850fb097454e4b4c01cf1b3070461e`. Its aarch64 production plugin has +SHA-256 `a2f33a58b2a1f3ab6e8d1b328de4c57b087785236651075ad3e59e6545c9ee14` +on all eight hosts. Four directly cabled DGX Sparks form a path, with one GB10 +GPU/rank per host. Complete facts, a custom protected marker path and a relay +limit of two are retained by each host's service. + +NCCL is unpatched 2.32.3, library SHA-256 +`c77f5ced2c4b538aad2b0ab88a9838e9eac9a68e22017863ffb0cff9c4f58745`. +Physical collectives use nccl-tests v2.21.1, Ring, at most eight channels and +bfloat16. Sizes double from 8 KiB to 256 MiB, with two warm-ups and five timed +iterations. All-reduce, all-gather, reduce-scatter and broadcast each run in +eager mode and with 20 graph replays. Clocks are not fixed; these checks do +not establish a throughput regression threshold. + +## Periodic recovery + +Each host's retained fabric service restores missing state at startup and +reload. A timer requests reconciliation 15 seconds after the preceding check +finishes. The trigger reloads an active fabric service so healthy markers +survive; it starts an inactive service. Restore policy adds missing objects, +retains ownership checks and does not remove healthy state. + +A middle path host is rebooted while every host's reconciliation timer is +enabled. An independent prerequisite service supplies its saved fabric IPv4 +addresses while the normal address owner is reserved for the test. The host +returns to administration access after 125.77 seconds. The entire path verifies +after 126.76 seconds, with no operator apply or repair. Marker PIDs on an +unaffected endpoint remain unchanged. + +Deleting an owned route and its permanent neighbor entry on a running host +causes group verification to fail. The timer repairs both; verification passes +after 12.88 seconds without operator repair. Eight physical collective sweeps +before reboot and eight after recovery all exit zero, select sircl and report +zero correctness errors. Their 256 size rows have no failures; monitored +RDMA/error/drop counters have zero growth and no required counter is missing. + +These results qualify asynchronous relay-object restoration on that path. +Links, independently configured addresses, unchanged cabling and compatible +ownership remain prerequisites. Existing NCCL communicators and application +jobs are not resumed. Marker/kernel/NIC failure combinations beyond the +recorded checks remain unqualified. + +Installer coordination is implemented in source +`5c76ef48878e9cef802b1aae1d5b9abb673ba37d`. Replacing or removing boot inputs +stops scheduling and waits for the manager-side restoration job, because +terminating its `systemctl` client alone does not cancel that job. A real +systemd regression with a delayed reload fails without that wait. With the +wait, removal completes after 3.48 seconds, retains its inputs until the reload +finishes and preserves the marker. A bounded timeout retains the inputs. +CPU fabric checks pass 146 tests. Transport ABI and wire behavior are unchanged. + +## CPU-staged protocol selection + +LL128 carries data and a validity flag in a 128-byte line. NVIDIA's +[protocol explanation](https://github.com/NVIDIA/nccl/issues/281) requires +ordered visibility of that line; splitting or reversing its accesses can +produce incorrect values. Ordinary CPU `memmove` in the emulator does not +provide that contract. This explains why enabling LL128 is unsafe there; the +measurements do not establish an upstream runtime defect. + +Forced LL128 fails exact checks with sircl emulation under PyTorch +2.11.0+cu130 and the cached NGC PyTorch 26.09 image's +2.14.0a0+b2c75dd062.nv26.09, including PyTorch Socket controls. Reducing CUDA +cluster size to one also fails. An independent four-rank native NCCL probe +fails through sircl emulation, so PyTorch is not a necessary cause. Its Socket +arm passes once; that observation does not establish a memory-ordering +guarantee or invalidate the failing PyTorch Socket controls. + +The emulation launcher selects LL/Simple and rejects LL128-enabling requests +before ranks start unless `--allow-ll128` explicitly permits a diagnostic run. +Seven channel-policy cases pass with every rank exact and independently exited +under both PyTorch versions, with no caller protocol override: 65.26 seconds +for the host framework and 67.83 seconds for the cached image. An unsafe +request exits 2 in 0.37 seconds with an explanation and launches no ranks. +The production RDMA plugin's tuner and protocol cost tables are unchanged. + +## Restoration and software verification + +After qualification, test timers, services and address prerequisites are +removed. The saved SparkRing configuration and relay owner are restored; +fabric verification passes. The saved four-rank FLARE group is running and +its health endpoint returns HTTP 200. Its recovery timer is active. Model +weights and system NCCL installations are unchanged. + +Isolated Debian source/archive checks pass the plugin, core, fabric, protocol +selection, release, privacy and staged-installation suites. Real systemd checks +cover timer execution, missing-state repair, marker lifetime and pending-job +retirement. Site addresses, names, credentials and raw service logs are private. From d1004d2e23354e4a6ef3841512057be91359ed5e Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:09:58 -0500 Subject: [PATCH 11/12] Identify protocol-control artifacts and native probe conditions Record the exact emulator revision and compiled-library hash used by raw LL128 controls, plus the independent native probe source hash and its rank, datatype and allocation conditions. This separates diagnostic controls from the source containing the safe launcher policy. No executable code or compatibility changes. Validation: artifact hashes match the retained source and library; source privacy and whitespace checks pass. --- docs/evidence/recovery.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/evidence/recovery.json b/docs/evidence/recovery.json index 2eb7486..0cf7452 100644 --- a/docs/evidence/recovery.json +++ b/docs/evidence/recovery.json @@ -1760,5 +1760,24 @@ "wait_seconds": 3.48, "marker_preserved": true, "pending_job_completed_before_input_removal": true + }, + "raw_protocol_control_artifacts": { + "emulator_source_revision": "ddc39fa07cd57010769a77094d0a6aad1efb9fbb", + "emulator_library_sha256": "87e663b629639d2d1fefdbf0ca1e787f3d497503f5fd99fe16effb4469e9b705", + "native_probe_source_sha256": "b3d9d2008cdc8d9a2a12b7069f5347607c2da735863e5fc40fdfd824f82c49bb", + "native_probe_conditions": { + "ranks": 4, + "gpu_devices": 1, + "datatype": "uint32", + "sizes_bytes": [ + 8192, + 4194304, + 67108864 + ], + "channels": 4, + "algorithm": "Ring", + "nccl_host_memory_allocation": "NCCL_CUMEM_HOST_ENABLE=0", + "p2p_and_shm_transports": "disabled" + } } } From cf395521d061107b8e0c43bc3bd735e48b08c584 Mon Sep 17 00:00:00 2001 From: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:13:33 -0500 Subject: [PATCH 12/12] Preserve protocol rejection errors in GPU check commands Check launcher failure before decoding a rank summary, and report an empty-summary rejection directly in teardown checks. An unsupported protocol request now retains its actionable explanation instead of failing with a list-index error. Successful checks and retained-graph negative controls are unchanged. Validation: both checker entry points reproduce the error without the change; five protocol regression tests pass with it, including safe selection and diagnostic opt-in. --- scripts/check_channels.py | 2 +- scripts/check_teardown.py | 2 ++ tests/test_emulation_protocols.py | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/check_channels.py b/scripts/check_channels.py index 7a9075d..149dd79 100644 --- a/scripts/check_channels.py +++ b/scripts/check_channels.py @@ -34,8 +34,8 @@ def main(): "--launch", "--world-size", str(world), "--layout", layout, "--plugin", str(ROOT / "net-sircl/libnccl-net-sircl-emu.so"), "--out", str(out)] result = subprocess.run(command, env=env, capture_output=True, text=True, timeout=260) - summary = json.loads(result.stdout.strip().splitlines()[-1]) assert result.returncode == 0, result.stdout + result.stderr + summary = json.loads(result.stdout.strip().splitlines()[-1]) assert all(r["exact_lines"] == 7 and r["plugin"] for r in summary["ranks"]), summary counts = [] for rank in range(world): diff --git a/scripts/check_teardown.py b/scripts/check_teardown.py index 0390069..9bf59d9 100644 --- a/scripts/check_teardown.py +++ b/scripts/check_teardown.py @@ -30,6 +30,8 @@ def main(): result = subprocess.run(command, env=env, capture_output=True, text=True, timeout=200) print(result.stdout, end="", flush=True) print(result.stderr, end="", file=sys.stderr) + if not result.stdout.strip(): + raise RuntimeError(result.stderr.strip() or "emulation launcher returned no rank summary") summary = json.loads(result.stdout.strip().splitlines()[-1]) (out / "summary.json").write_text(json.dumps(summary, indent=2) + "\n") ranks = summary["ranks"] diff --git a/tests/test_emulation_protocols.py b/tests/test_emulation_protocols.py index 10f86e7..6225585 100644 --- a/tests/test_emulation_protocols.py +++ b/tests/test_emulation_protocols.py @@ -2,6 +2,8 @@ import importlib.util from pathlib import Path import unittest +from unittest import mock +import subprocess path = Path(__file__).resolve().parents[1] / 'net-sircl/tests/emulation/nccl_e2e.py' spec = importlib.util.spec_from_file_location('nccl_emulation', path) @@ -26,3 +28,23 @@ def test_ll128_requires_explicit_diagnostic_opt_in(self): def test_diagnostic_opt_in_preserves_protocol_request(self): self.assertEqual(emulation.select_protocols('LL128', allow_ll128=True), 'LL128') + + def test_channel_checker_reports_launcher_rejection(self): + path = Path(__file__).resolve().parents[1] / 'scripts/check_channels.py' + spec = importlib.util.spec_from_file_location('channel_check', path) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = subprocess.CompletedProcess([], 2, stdout='', stderr='LL128 is unsafe for CPU-staged emulation') + with mock.patch('sys.argv', ['check_channels.py']), mock.patch.object(checker.subprocess, 'run', return_value=result): + with self.assertRaisesRegex(AssertionError, 'LL128 is unsafe'): + checker.main() + + def test_teardown_checker_reports_launcher_rejection(self): + path = Path(__file__).resolve().parents[1] / 'scripts/check_teardown.py' + spec = importlib.util.spec_from_file_location('teardown_check', path) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = subprocess.CompletedProcess([], 2, stdout='', stderr='LL128 is unsafe for CPU-staged emulation') + with mock.patch('sys.argv', ['check_teardown.py']), mock.patch.object(checker.subprocess, 'run', return_value=result): + with self.assertRaisesRegex(RuntimeError, 'LL128 is unsafe'): + checker.main()