Repository navigation
Conversation
Adds a `cuda.pathfinder` logger, disabled by default, enabled by setting CUDA_PATHFINDER_LOG_LEVEL to a standard level name or an integer. `logging` is imported only when the variable is set. Importing it pulls in seven additional modules and measurably slows `import cuda.pathfinder`, which sits on the import hot path of every consumer, so the disabled path imports nothing and costs one module-global lookup plus an identity check (~5 ns) at each call site. No message string or `extra` dict is built when logging is off. Instruments the dynamic-library search only: each find step reports whether it matched, a successful load reports the resolved path and `found_via`, and the failure path emits the accumulated candidate list as structured fields. Records carry `pathfinder_*` fields so consumers can filter without parsing messages. The logger attaches a NullHandler, never calls basicConfig, and never touches the root logger. Invalid CUDA_PATHFINDER_LOG_LEVEL values warn once and leave logging disabled rather than raising. The environment variable is read once at import, matching the documented read-once policy of get_cuda_path_or_home(). Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
…odules The cascade fixture reloaded search_steps and load_nvidia_dynamic_lib to pick up a LOGGER enabled after import. A reload rebinds everything the module defines, including FindResult, so any test module that imported FindResult beforehand held a different class object than the one the reloaded search_steps returned. Dataclass equality compares classes, so those assertions failed on values that print identically, and which tests broke depended on execution order. The consumers bind LOGGER by value at import, so setting that one attribute through monkeypatch is enough and leaves no state behind. test_silent_when_ disabled asserts the disabled default rather than reloading into it. Against current main this fixes 13 failures in test_search_steps.py and test_windows_nsight.py; on the original base it was 2 in test_load_nvidia_dynamic_lib_using_mocker.py. CI never ran on this PR, so it was never reported. Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
|
Fair challenge. I didn't come to this from a production incident. I picked #650 up from the backlog. But when I checked whether anyone actually needs it, it turns out every downstream project is already working around the gap:
To keep this cheap for you to accept, I can cut the PR down to the minimum:
That's a few lines in |
Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
|
Pushed the smaller version: one INFO record per successful load, off by default, 51 lines of source plus tests. @rwgk could you take a look? |
…namic_lib Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
|
Reopened (closed by mistake), merged main, and updated the description to match the smaller diff. @rparolin could you add the |
|
No actionable comments were generated in the recent review. Summary
Change: Feature Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: NVIDIA/cuda-python
- Branch: main
- File: .coderabbit.yaml
- Commit: 03b4153
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Enterprise
- Run ID:
810878d9-111a-4d96-b48a-8caafc4d1658
Files selected for processing: 3-
cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.pycuda_pathfinder/cuda/pathfinder/_utils/diagnostic_log.pycuda_pathfinder/tests/test_diagnostic_log.py
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
-
|
/ok to test 4c9b60e |
|
… decimal levels Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
|
The free-threaded failures were from my tests reloading the module under a patched |
Description
closes #650
Opt-in logging of where
load_nvidia_dynamic_libfound each library. Cut down per the discussion below to oneINFOrecord per successful load:loggingis only imported whenCUDA_PATHFINDER_LOG_LEVELis set (level name or integer); an invalid value warns and leaves it off.load_nvidia_dynamic_libis cached. Nothing is logged on failure;DynamicLibNotFoundErroralready carries that.cuda.pathfinderlogger with aNullHandleronly; the root logger is never configured.load_nvidia_dynamic_libdocstring.Locally:
pytest tests/incuda_pathfinderpasses (1627 passed, 5 skipped). New tests are markedagent_authored.Checklist