Skip to content

Replace Gen2 window hammer with bounded multi-GPU second-pass activation - #65

Closed
rjohny55 wants to merge 1 commit into
amoghmunikote:masterfrom
rjohny55:feat/bounded-gen2-second-pass
Closed

rjohny55 wants to merge 1 commit into
amoghmunikote:masterfrom
rjohny55:feat/bounded-gen2-second-pass

Conversation

@rjohny55

@rjohny55 rjohny55 commented Oct 9, 2026

Copy link
Copy Markdown

Summary

Replace the default 600-iteration Gen2 "window hammer" service with a bounded, endpoint-first retrain and conditional FLR/second-driver-pass sequence. This avoids waiting for the hammer counter when the endpoint still reports a Gen1-only policy, and supports every enumerated supported CMP 170HX rather than a fixed GPU count.

Changes

  • Add tools/gen2-second-pass.sh, adapted from the activation method in rjohny55/cmp170hx-unlocker. It initializes the already-patched driver, tries endpoint-first then upstream-port retraining, and checks target-speed readback. If necessary, it unbinds the idle cards, unloads the NVIDIA modules, performs FLR, initializes the same driver again, and repeats retraining.
  • Select this helper in the existing gen2.service and installer, keeping tools/service.sh install/remove/status/verify and the systemd.mask=gen2.service recovery option. Installing the service does not run activation in the current session. The old hammer source remains available in the repository, but is no longer the installed/default helper.
  • Automatically enumerate PCI IDs 10de:20c2 and 10de:2082 on each invocation. An optional positive count is an extra inventory guard; it is not hard-coded to one or four GPUs. Generation and lane width are independent: the same speed/retrain masks work at x4/x8/x16 without trying to force lane width.
  • Bound retries to two retrains per card per driver pass, with short status polling and immediate early exit once both endpoint and upstream port are Gen2 or better. There is no 600-iteration hammer counter. Keep a finite service watchdog (180 seconds); this is not a promise that every host activates instantly.
  • Check active device-file users before initialization and again before FLR; reject failed client inspection, invalid PCI reads/writes, unavailable FLR and non-NVIDIA bindings. Serialize activation/installation with flock, restore previously loaded NVIDIA modules on exit, and log failures instead of reporting false success. Resetting the driver is intended for early boot or an idle maintenance window, not a live desktop/GPU workload.
  • Preserve the current early-boot ordering (Before=basic.target). This PR does not make activation asynchronous/non-blocking: GPU clients should not race an FLR/driver reload. It removes the long repeated window-hunting approach, but further boot targets still wait for this one-shot operation.
  • No GPU-register unlock, memory/SM/ECC/BAR1 patches, driver version selection or VFIO policy changes. No claimed CUDA/inference speedup.

Testing

Local validation of this proposed integration: bash -n and ShellCheck 0.11.0 passed; pytest passed 45 tests plus 31 subtests. Fixtures exercise 1/2/4/8 mixed supported cards, x4/x8/x16, first-pass and FLR/second-pass success, already-Gen2 no-op, unsupported devices, stale/empty inventory, active clients, client-inspection errors, missing FLR, PCI I/O failures, failed driver initialization, failed second pass, module restoration and a link dropping during the stability check. No real PCI device or loaded driver is touched by these fixtures.

Command: PATH=/tmp/shellcheck-v0.11.0:$PATH python -m pytest -q tests/test_lint.py tests/test_compile.py tests/test_gen2_second_pass.py tests/test_patches.py -k 'not passthrough_module_builds and not patches_apply' -p no:cacheprovider. Six existing kernel-module/patch-matrix cases were not run locally: this container has no /lib/modules headers and the driver patch files are unchanged. The existing GitHub CI remains responsible for those checks; no full kernel-build result is claimed here.

The underlying endpoint-first/second-driver-pass method was previously exercised on physical hardware. The newly adapted installer/extra fail-closed checks in this branch have only been tested with fixtures, not reinstalled on the live servers during PR preparation.

Hardware tested on (underlying activation method):

  • GPU variant: CMP 170HX 10de:20c2, 65536 MiB per card.
  • PCIe slot / host: one enumerated card on a dual Xeon E5-2686 v4/X99 host reached Gen2 x16 after FLR and a second initialization. The old 600-attempt root-port hammer had failed on that same host; the new cold-boot service subsequently completed in approximately 10 seconds. Four cards on the later host reached Gen2 x4, with a recorded successful service duration of 48 seconds. Eight cards on an AMD EPYC 7402P / Gigabyte server reached Gen2 x16 on the first endpoint-first pass and after reboot. These are observations, not a controlled universal speedup benchmark.
  • Kernel / OS: Ubuntu 24.04.5, Linux 6.8.0-142-generic, patched NVIDIA open driver 610.57.04. A later eight-card startup smoke check also used 615.71.09; that host required a separate serialized-probe driver fix, which is deliberately not part of this PR. No hardware result is claimed for the author's latest 615.78.08 here.

Reproducible records for the underlying method:

Only startup/retrain smoke checks are claimed. Long-term link/workload stability and platform-specific FLR behavior still need validation; this is not a benchmark against every BIOS, card sample or upstream revision.

@amoghmunikote

Copy link
Copy Markdown
Owner

NO SLOP!

@rjohny55

rjohny55 commented Oct 9, 2026

Copy link
Copy Markdown
Author

Manually replace your very slow Gen2 activation method with a faster one.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants