How to Detect During Acceptance Testing NUMA Misplacement

You can detect during acceptance testing NUMA misplacement with a simple comparison. Read the NUMA node ID of each GPU and each NIC from the operating system, then compare the IDs for every intended GPU/NIC pair. The tools you need are already on the machine: nvidia-smi, nvidia-smi topo -m, lspci, and sysfs. A standard Linux install with the GPU driver provides all of them, so no special software is required. Treat the check as a pass/fail gate. When both devices report the same node ID, the pair passes. When the IDs differ, the topology shows a misplacement, and the build fails.
GPU Topology and NUMA Node Basics
Read GPU NUMA Node with nvidia-smi
Start with a single query that returns one row per GPU. Run nvidia-smi --query-gpu=index,pci.bus_id,numa_node --format=csv. The output lists each GPU index, its PCI bus ID, and the NUMA node the driver reports. A healthy result shows a small integer for every card, such as 0 or 1, matching the socket that owns the PCIe slot.
This query gives you the fastest read on numa layout. Each row ties a GPU to a node, so you can spot a card that landed on the wrong socket before you touch any cabling. Record the values. You will compare them against the NIC readings later.
Cross-Check with lspci and sysfs
Confirm the driver’s answer against the kernel. Take the gpu pci address from the CSV, convert it to the sysfs form, and read /sys/bus/pci/devices/<bus_id>/numa_node. The file returns the same integer when the mapping is correct. A value of -1 or N/A means the node is unknown, and you should flag that card for manual review rather than pass it.
The nvidia-smi topo -m view is your primary topology map. It draws the gpu and network-card pci topology in one grid. Look for GPUDirect RDMA links annotated NODE. That label confirms same numa node locality between a GPU and a NIC, which is exactly the condition you want for numa binding. Links marked SYS cross numa sockets and signal a placement problem. Use this grid to sanity-check the raw node IDs and to document the pci topology for the acceptance record.
NIC NUMA Node Identification
Locate the NIC PCI Address with lspci
You need the PCI address of every network card before you can read its node. Run lspci -nn | grep -i ethernet to list the Ethernet controllers. Each line starts with a slot address such as 0000:3b:00.0, followed by the device name and vendor ID. If your card uses a different driver, swap the grep term for the driver name, for example grep -i mellanox. Copy the address of each card you plan to pair with a GPU.
That address is your selected nic pci address for the check. Write it down next to the GPU rows you recorded earlier. The pcie slot number tells you which riser and socket the card sits in, and the address becomes the lookup key for the next step.
Read numa_node from sysfs
The linux pci sysfs tree exposes the node for every device. Read /sys/bus/pci/devices/<addr>/numa_node for each address you collected. The file returns a small integer, and that integer is the numa node of the card. Compare it against the GPU values from the previous section.
Some interfaces do not expose the file. Virtual functions, bonded interfaces, and software bridges often return nothing useful. In that case, walk up to the parent PCI device or the physical function and read the node there. The parent device carries the real hardware locality, so the fallback still gives you a trustworthy answer.
Record each result in the same table as the GPUs. You now hold both halves of the topology picture, and the comparison step can begin.
Topology Comparison for NUMA Placement
Match Each GPU to Its Intended NIC
You now hold two lists of node IDs. The next step pairs them the way your workload actually uses them. Do not pair cards by physical proximity on the board. Pair each GPU with the network card that carries its traffic in production.
Start from the workload. If a training job pins rank 0 to GPU 0 and sends its gradient traffic through a specific port, that port is the intended partner for GPU 0. If you run NCCL rings, follow the ring order and pair each GPU with the adapter its ring segment uses. Write the pairing down before you compare anything. A clear gpu and nic mapping keeps the check honest and repeatable across builds.
Now compare the two numbers for each pair. Read the GPU value from your nvidia-smi output and the adapter value from sysfs. Place them side by side in a table with four columns: GPU index, GPU node, NIC node, and result. The table stays small and readable, and it gives the acceptance record a clean artifact.
Flag Cross-Node Pairs
A match is a pass. When both devices report the same numa node, the pair has gpu↔nic locality, and traffic stays inside one socket. That is the condition numa binding and numa affinity settings assume. A mismatch is a finding. When the two values differ, the pair crosses sockets, and every packet between them pays the interconnect penalty. Mark it as a NUMA misplacement and fail the gate.
Watch for the unknown case as well. A value of -1 or N/A means the kernel could not resolve the node. Treat that as a flag for manual review, not a pass. An unresolved value hides the real placement, and topology-aware placement decisions built on it are guesses.
The comparison also exposes subtler problems. Suppose GPU 0 reports node 0 and its partner adapter reports node 1. The gpu topology looks fine in isolation, and the adapter looks fine in isolation. Only the paired view reveals the cross-socket link. This is why the check compares pairs rather than devices. A single numa alignment error on one pair can drag a whole collective operation down, because the slowest link sets the pace.
Keep the result column strict. Use pass, fail, or review, and nothing else. Strict labels make the report easy to scan and easy to automate in the next step. They also prevent debate later, when someone asks whether a warning counted as a failure. Record the pci topology alongside the table, so the evidence sits with the verdict. The topology map from nvidia-smi topo -m serves well here, and it shows the same story in graphical form.
Automate the NUMA Placement Check
Loop Over GPUs and NICs
Manual checks do not scale across a fleet. Write a short script that repeats the comparison for every card and every adapter. The script reads the GPU node IDs from nvidia-smi, reads the adapter node IDs from sysfs, and pairs them in the order you defined earlier.
A compact bash loop handles the job. It queries each GPU index and its node, then walks the adapter list and reads the matching sysfs file. Keep the pairing list in a small text file, one line per pair, so the script stays readable and the mapping stays visible to reviewers.
Emit a Pass/Fail Report
The script prints one line per pair. Each line names the GPU, the adapter, and the verdict. Pipe the output to a log file and attach it to the acceptance record. A reviewer can scan the file in seconds and see every numa placement result at once.
Wire the script into the acceptance test suite so every build runs it. A failing line should stop the gate, just as a failed benchmark would. For deeper evidence, set NCCL_DEBUG=INFO and compare the selected-NIC and transport lines between nodes. Those lines show which adapter each rank actually chose, and they confirm the topology your script reported. Store both artifacts together, and the placement check becomes a repeatable, auditable step in every acceptance run.
Interpret Results and Detect During Acceptance Testing
Read the Pass/Fail Output
The report gives you three verdicts, and each one demands a different response. A pair marked pass reports the same numa node ID for both devices. That pair has locality, and you can sign it off. A pair marked fail reports two different numa node IDs. That pair creates a cross-socket link, and the build should not pass the gate. A pair marked review reports -1 or N/A. The kernel could not resolve the node, so a human must inspect the hardware before anyone trusts the result. The three labels keep the verdict strict and easy to scan.
Read the report line by line, not as a whole. One failing line among many passing lines still means the machine has a placement defect. The defect hides in normal operation, because the machine boots and runs. Only the paired comparison exposes it. This is the reason you detect during acceptance testing rather than after deployment. A misplacement caught at the gate costs a re-seat or a re-cable. The same defect found in production costs debugging time and lost throughput.
Pay attention to the review lines as well. An unknown node value often points to a virtual function or a firmware setting that hides the real device. Do not let a review line slide into the pass column. Mark it open until someone resolves it. A review line is not a soft pass. It is a gap in your evidence, and the gate should treat it that way. Strict labels prevent debate later, when someone asks whether a warning counted as a failure.
Benchmark and Escalate
A flagged pair deserves confirmation before you escalate. Run a cross-node benchmark and compare the flagged machine against an identically configured healthy node. A simple NCCL all-reduce across the two machines works well. Mellanox ngc_multinode_perf is another solid choice. Watch the throughput numbers. The flagged node should show degraded throughput next to the healthy node, and that gap confirms the finding. A cross-socket pair pays a penalty on every packet, and the benchmark makes that penalty visible.
Keep the comparison fair. Use the same message size, the same rank count, and the same software stack on both machines. A benchmark run under different conditions proves nothing. When the flagged node underperforms, you hold two pieces of evidence: the numa node ID mismatch and the throughput gap. Document both in the acceptance record. Attach the report, the topology map, and the benchmark output. A reviewer who reads the ticket later should see the same evidence you saw, without rerunning anything.
Escalation follows a clear path. Send the finding to the team that owns the hardware, and name the specific GPU and nic pair. Ask for a physical inspection of the GPU slot and the riser. A card in the wrong slot, a mislabeled riser, or a swapped cable all produce the same symptom. The inspection resolves which one applies. Record the root cause in the ticket, so the next build with the same symptom gets a faster answer.
Finally, treat every flagged machine the same way. You detect during acceptance testing to catch placement errors early, and the benchmark turns a suspicion into a documented fact. A consistent process keeps the fleet uniform and keeps cross-socket traffic out of your production clusters.
The detection chain is short. Read each GPU node ID, read each NIC node ID, compare every intended pair, automate the comparison, and record the verdict. Run this check in every acceptance test, because a misplaced card boots and runs without complaint. Only the paired comparison exposes it. Cross-node benchmarking then confirms the finding with a throughput gap against a healthy machine. Make the script part of your standard suite, and every future build gets the same numa and topology review. That habit keeps placement errors out of production and keeps your fleet uniform.
FAQ
Does this check work on virtual machines and cloud instances?
Often it does not. Virtualized guests frequently hide the host PCI layout, and sysfs may return -1 for every device. Run the check on bare metal instead. On cloud platforms, ask the provider for the placement map and verify it against your own readings where the data is exposed.
How often should I run the placement check?
Run it on every new machine and after any hardware change. A re-seated card, a swapped riser, or a replaced NIC can shift placement without any visible symptom. Wiring the script into the acceptance suite covers both cases automatically. You then detect during acceptance testing instead of discovering the defect in production.
What if nvidia-smi reports a numa node but sysfs disagrees?
Trust neither value on its own. A disagreement means the driver view and the kernel view diverge, and that gap deserves investigation. Re-read the PCI address carefully, confirm you queried the right device, and check the firmware settings. Flag the pair for manual review until both sources agree.
Is the nvidia-smi query enough by itself?
No. The query gives you the GPU side of the topology, and that is only half the picture. You still need the NIC node IDs from sysfs to complete each pair. The paired comparison is what exposes a cross-socket link. A single-sided reading can look perfectly healthy while the pair fails.
Does a passing result guarantee good performance?
No. A pass confirms same-node locality, and that removes one common penalty. Other factors still shape throughput: link width, cable quality, firmware versions, and driver settings. Treat the pass as a necessary gate, not a performance guarantee. Benchmark when you need proof.
