Repository navigation
fix(nvidia): only start fabric manager on hosts with an NVSwitch fabric - #2840
Conversation
…tch fabric nvidia-fabricmanager is enabled on every NVIDIA instance, but it only has work to do on hosts that manage NVSwitches. Elsewhere, single-GPU and PCIe-only instances and GB200/GB300 whose fabric is managed off-host by the rack's switch trays, it exits with NV_WARN_NOTHING_TO_DO and leaves a failed unit behind, which reads like a broken GPU interconnect. Gate the unit with an ExecCondition drop-in. The condition starts Fabric Manager when it finds NVSwitches on the PCI bus (class 0680, how the nvidia driver binds them on HGX A100/H100/H200) or a ConnectX bridge with SW_MNG in its VPD (NVLink5+, the same check nvidia-fabricmanager-start.sh uses), and skips it on known off-host-fabric GPUs and everywhere else. A skipped unit shows as inactive with a condition message instead of failed. systemd skips on any condition exit from 1 to 254, so the condition fails open: it starts Fabric Manager whenever lspci can't be read, and returns 1 only from an explicit decision. validate.sh exercises every decision path against canned lspci output so a broken condition fails the AMI build. Closes awslabs#2727
Say where each hex constant comes from: the PCI vendor and class IDs from pci.ids, class 0x0680 from the nvidia driver's own NVSwitch PCI table, and the GB200/GB300 device IDs from NVIDIA's supported-gpus lists. Explain the lspci -mm fields and the awk match idiom with example lines. In validate.sh, mark which lspci fixtures were captured from real instances and which are hand-written. Replace the NVSwitch fixture with the line captured from a p4d.24xlarge; only its subdevice ID changes, which the condition doesn't read.
Wrongly starting Fabric Manager costs one failed unit, the behavior before the condition existed. Wrongly skipping it on an NVSwitch host leaves the fabric unconfigured, which per NVIDIA's Fabric Manager user guide fails CUDA initialization on HGX A100 and costs NVLink peer-to-peer on HGX H100 and later.
mselim00
left a comment
There was a problem hiding this comment.
thanks for adding this, I just have a few small suggestions!
| fi | ||
| done | ||
| return 1 | ||
| } |
There was a problem hiding this comment.
any reason we actually need this? if we see an NVSwitch from within the VM, that seems like enough to mean we should run FM
correct me if I'm wrong, but I don't think think the "off host" switches would be visible from within the VM since they don't need to be mounted into it. in any case, I think false negatives are much worse than false positives here, which is also reflected in the earlier comment about starting if lspci somehow returns no output
There was a problem hiding this comment.
Agreed, and it also removes the upkeep for future Grace IDs. I also noticed FM ships local-fabric GB200 topologies (gb200_nvl4r1_c2g2_etf, gb200_nvl8r1_c2g4_etf), so a device-ID skip could be a false negative on those. Dropping it.
| # 0000:10:1c.0 0302 10de 20b0 -ra1 10de 134f <- no match (a GPU, class 0302) | ||
| awk -v vendor="${NVIDIA_VENDOR_ID}" -v class="${NVSWITCH_PCI_CLASS_CODE}" \ | ||
| '$2 == class && tolower($3) == vendor { found = 1 } END { exit !found }' <<< "${PCI_DEVICES}" | ||
| } |
There was a problem hiding this comment.
it might actually be simpler to just rely on the NVIDIA driver for this. on init, the nvidia kernel module registers a PCI probe that matches these same parameters 1->2 which creates a procfs entry for the device at /proc/driver/nvidia-nvswitch/devices/
I think either just checking if that directory is non-empty could be the whole check, or we could use both check and let either one be enough to start FM. but if there's any device mounted that the nvidia kmod thinks is an NVSwitch, it'd definitely be worth running fabricmanager
There was a problem hiding this comment.
Good call. I'll start FM if either /proc/driver/nvidia-nvswitch/devices/ is non-empty or lspci shows a 0680 NVIDIA device, so we don't depend on the module having loaded first. SW_MNG stays for NVL5, where the switches aren't PCI devices.
There was a problem hiding this comment.
Nice to see this resolved. This was going to be my overall comment as well.
| echo "${dropin} does not gate nvidia-fabricmanager.service on ${condition}" | ||
| exit 1 | ||
| fi | ||
|
|
There was a problem hiding this comment.
it might be worth additionally checking that the same service name (nvidia-fabricmanager.service) exists in /usr/lib/systemd/system/. this is redundant to a check that's already done elsewhere, but it's directly important for this to take effect since systemd matches across the two directories on exact names
There was a problem hiding this comment.
Makes sense. One wrinkle: at build time the unit isn't in /usr/lib/systemd/system yet (validate.sh fails if it is; setup installs it from the tree at first boot), so I'll check each tree's /usr/lib/systemd/system/nvidia-fabricmanager.service instead, right next to the drop-in check.
…skip Address review feedback: - Start Fabric Manager when the nvidia driver has registered an NVSwitch under /proc/driver/nvidia-nvswitch/devices, the same check NVIDIA's gpu-driver-container uses. The lspci class 0680 check stays alongside it so starting doesn't depend on the driver having loaded first. - Remove the GB200/GB300 device-ID skip. Off-host NVSwitches aren't visible to the guest, so those hosts already fall through to skip, and FM ships topologies for GB200 systems with a local fabric, where a device-ID skip would be a false negative. - validate.sh: check that every tree carries nvidia-fabricmanager.service, the exact name the drop-in directory applies to, and cover the procfs check in the condition cases.
Issue #, if available: Closes #2727
Description of changes:
nvidia-fabricmanageris started on every NVIDIA instance, but it only has work to do on hosts that manage an NVSwitch fabric. Everywhere else (single-GPU and PCIe-only instances, and GB200/GB300, whose fabric is managed off-host) it fails at every boot:This adds an
ExecConditiondrop-in, so on those hosts the unit is skipped instead of failed. Enablement insetup-nvidia.shis unchanged.The condition (
nvidia-fabricmanager-condition.sh) starts Fabric Manager on any evidence of a local NVSwitch fabric, and skips only when there's none:/proc/driver/nvidia-nvswitch/devices/is non-empty0680SW_MNGin its VPDThe procfs and
SW_MNGchecks are the ones NVIDIA's gpu-driver-container uses to decide whether to start Fabric Manager;SW_MNGis also hownvidia-fabricmanager-start.shpicks its NVLSM path.systemd skips the unit on any
ExecConditionexit from 1 to 254, so a broken condition would silently skip Fabric Manager on an NVSwitch host. To prevent that, the condition fails open:lspcican't be read.errexit/nounsetare off, so only an explicit decision returns 1.validate.shruns every decision path against cannedlspcioutput, so a broken condition fails the AMI build.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Testing Done
Built the AMI from this branch (
make k8s=1.34 os_distro=al2023 enable_accelerator=nvidia);validate.shpassed, including the new check. On instances from that AMI, on first boot and after a reboot:g4dn.xlarge(no fabric)failed,NV_WARN_NOTHING_TO_DOfabricmanager-condition: no NVSwitch fabric on this host, skipping; not insystemctl --failedp4d.24xlarge(6 NVSwitches)activeactive:fabricmanager-condition: found NVSwitch devices, starting, NVSwitches configured, all GPU pairsNV12After the review update (e37fb29), its files were also installed on the stock AMI and checked on first boot and after a reboot:
p4d.24xlarge:fabricmanager-condition: found NVSwitch devices registered by the nvidia driver, starting./proc/driver/nvidia-nvswitch/devices/lists the same 6 NVSwitches aslspci, and is already populated when the condition runs (it decides about 60 ms afternvidia-setupfinishes). NVSwitches configured, all GPU pairsNV12.g4dn.xlarge:no NVSwitch fabric on this host, skipping. The procfs directory exists but is empty.p6-b200.48xlarge:fabricmanager-condition: found an NVSwitch management bridge, starting, via the two CX7 bridges whose VPD carriesSMDL=SW_MNG(procfs empty, no class0680devices, as expected for NVLink5).nvidia-fabricmanager-start.shthen loggedDetected NVL5+ systemand started NVLSM; NVSwitches configured, all GPU pairsNV18. Itslspcilines match theb200/cx7fixtures invalidate.sh.Also:
lspcifixtures match output captured on both instances.validate.shruns 9 decision cases. Breaking the condition in six ways (a crash, each of the three start checks removed, each fail-open path flipped to fail-closed) makes it fail.shfmtandshellcheckare clean with themake lint-codeflags.Not tested: a node joining a cluster; B300 and GB200/GB300 hardware.