Skip to content

fix(nvidia): only start fabric manager on hosts with an NVSwitch fabric - #2840

Merged
kummatty merged 4 commits into
awslabs:mainfrom
aaithal:conditional-fabricmanager
Oct 1, 2026
Merged

kummatty merged 4 commits into
awslabs:mainfrom
aaithal:conditional-fabricmanager

Conversation

@aaithal

@aaithal aaithal commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available: Closes #2727

Description of changes:

nvidia-fabricmanager is 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:

nvidia-fabricmanager-start.sh: request to query NVSwitch device information from NVSwitch driver failed with error:WARNING Nothing to do [NV_WARN_NOTHING_TO_DO]
systemd: Failed to start nvidia-fabricmanager.service - NVIDIA fabric manager service.

This adds an ExecCondition drop-in, so on those hosts the unit is skipped instead of failed. Enablement in setup-nvidia.sh is 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:

Check Result Covers
/proc/driver/nvidia-nvswitch/devices/ is non-empty start the nvidia driver registered an NVSwitch (HGX A100/H100/H200)
NVIDIA device of PCI class 0680 start the same switches, without depending on the driver having loaded
Mellanox device with SW_MNG in its VPD start B200/B300, NVSwitches behind CX7 bridges
none of the above skip single-GPU, PCIe multi-GPU, vGPU, and GB200/GB300 NVL72 (switches off-host)

The procfs and SW_MNG checks are the ones NVIDIA's gpu-driver-container uses to decide whether to start Fabric Manager; SW_MNG is also how nvidia-fabricmanager-start.sh picks its NVLSM path.

systemd skips the unit on any ExecCondition exit from 1 to 254, so a broken condition would silently skip Fabric Manager on an NVSwitch host. To prevent that, the condition fails open:

  • It starts Fabric Manager whenever lspci can't be read.
  • errexit/nounset are off, so only an explicit decision returns 1.
  • validate.sh runs every decision path against canned lspci output, 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.sh passed, including the new check. On instances from that AMI, on first boot and after a reboot:

Instance Before After
g4dn.xlarge (no fabric) failed, NV_WARN_NOTHING_TO_DO skipped: fabricmanager-condition: no NVSwitch fabric on this host, skipping; not in systemctl --failed
p4d.24xlarge (6 NVSwitches) active active: fabricmanager-condition: found NVSwitch devices, starting, NVSwitches configured, all GPU pairs NV12

After 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 as lspci, and is already populated when the condition runs (it decides about 60 ms after nvidia-setup finishes). NVSwitches configured, all GPU pairs NV12.
  • 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 carries SMDL=SW_MNG (procfs empty, no class 0680 devices, as expected for NVLink5). nvidia-fabricmanager-start.sh then logged Detected NVL5+ system and started NVLSM; NVSwitches configured, all GPU pairs NV18. Its lspci lines match the b200/cx7 fixtures in validate.sh.

Also:

  • The lspci fixtures match output captured on both instances.
  • validate.sh runs 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.
  • shfmt and shellcheck are clean with the make lint-code flags.

Not tested: a node joining a cluster; B300 and GB200/GB300 hardware.

…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.
@aaithal aaithal changed the title feat(al2023/nvidia): only start fabric manager on hosts with an NVSwitch fabric fix(nvidia): only start fabric manager on hosts with an NVSwitch fabric Sep 30, 2026
@aaithal
aaithal marked this pull request as ready for review September 30, 2026 22:32
@aaithal
aaithal requested a review from a team as a code owner September 30, 2026 22:32

@mselim00 mselim00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this, I just have a few small suggestions!

fi
done
return 1
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mselim00 mselim00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conditionally enable fabric manager service in NVIDIA AMIs

3 participants