Skip to content

test(helpers): narrow EGL device probe catch to MissingFunctionException - #3020

Merged
juenglin merged 1 commit into
NVIDIA:mainfrom
juenglin:egl-follow-up
Oct 5, 2026
Merged

juenglin merged 1 commit into
NVIDIA:mainfrom
juenglin:egl-follow-up

Conversation

@juenglin

@juenglin juenglin commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Description

closes #2864

Follow-up to #2865.

select_headless_egl_device_for_cuda in cuda_python_test_helpers/cuda_python_test_helpers/graphics.py is a capability probe, but it caught except Exception: return None, which violates the "Capability probes must not swallow real bugs" rule in cuda_core/tests/AGENTS.md. A real failure (ctypes drift, a pyglet internal rename, a transient EGL error) was swallowed and turned into None, which makes _configure_pyglet_headless() leave pyglet.options["headless_device"] unset and fall back to EGL device 0 -- the broken path on the multi-GPU systems #2865 fixes -- so the test would re-fail with the original CUDA_ERROR_INVALID_DEVICE and no sign the fix ran.

The only genuine "extension not available" signal here is pyglet.gl.lib.MissingFunctionException: link_EGL returns a stub for an unresolvable entry point (e.g. an EGL stack that has eglQueryDevicesEXT but not eglQueryDeviceAttribEXT), and the stub raises MissingFunctionException when called. Narrow the catch to that type and let everything else propagate. EGL_FALSE returns are already handled as "no match", and the caller already skips when libEGL is absent, so no ImportError handling is needed.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

select_headless_egl_device_for_cuda caught `except Exception: return None`,
which violates the "Capability probes must not swallow real bugs" rule in
cuda_core/tests/AGENTS.md. A real failure (ctypes drift, a pyglet internal
rename, a transient EGL error) was swallowed and turned into None, which
makes the caller fall back to EGL device 0 -- the broken path on the
multi-GPU systems NVIDIA#2865 fixes -- so the test re-failed with the original
CUDA_ERROR_INVALID_DEVICE and no sign the fix ran.

The only genuine "extension not available" signal is
pyglet.gl.lib.MissingFunctionException: link_EGL returns a stub for an
unresolvable entry point, and the stub raises it when called. Narrow the
catch to that type and let everything else propagate. EGL_FALSE returns
are already handled as "no match", and the caller already skips when
libEGL is absent, so no ImportError handling is needed.

Follow-up to NVIDIA#2865. Refs NVIDIA#2864.
@juenglin juenglin added this to the cuda.core 1.3.0 milestone Oct 5, 2026
@juenglin juenglin added the bug Something isn't working label Oct 5, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@juenglin juenglin self-assigned this Oct 5, 2026
@juenglin juenglin added the test Improvements or additions to tests label Oct 5, 2026
@juenglin juenglin added P1 Medium priority - Should do cuda.core Everything related to the cuda.core module labels Oct 5, 2026
@juenglin

juenglin commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f4fe917

@juenglin
juenglin requested a review from Andy-Jost October 5, 2026 17:56
@juenglin
juenglin enabled auto-merge (squash) October 5, 2026 18:02
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Doc Preview CI
Preview removed because the pull request was closed or merged.

@juenglin
juenglin requested a review from rparolin October 5, 2026 18:11
@juenglin
juenglin merged commit 669e608 into NVIDIA:main Oct 5, 2026
232 of 241 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 6, 2026
Removed preview folders for the following PRs:
- PR #2958
- PR #2963
- PR #2978
- PR #2988
- PR #2999
- PR #3000
- PR #3006
- PR #3011
- PR #3013
- PR #3019
- PR #3020
Andy-Jost added a commit that referenced this pull request Oct 6, 2026
)

* test(helpers): keep the EGL device probe from importing pyglet.gl

select_headless_egl_device_for_cuda runs before the graphics tests set
pyglet.options["headless_device"]. Importing pyglet.gl there creates
pyglet's shadow window, which in headless mode opens the EGL display on
device 0 and caches it, so the later headless_device assignment has no
effect and the GL context lands on EGL device 0 again (#2864).

Match MissingFunctionException by module and name instead, as
is_gl_context_unavailable already does, and add a subprocess test that
asserts the probe leaves pyglet.gl unimported.

Follow-up to #3020.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(graphics): hand the probe child the test-helpers package path

CI does not install cuda_python_test_helpers; the parent imports it only
through the conftest sys.path fallback, which the -c child does not
inherit, so test_egl_device_probe_does_not_import_pyglet_gl failed in
every Linux row with ModuleNotFoundError. The child now gets a PYTHONPATH
that names the parent directory of the package the parent imported, and
a failure reports the child's stderr.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module P1 Medium priority - Should do test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cuda.core] test_graphics.py fails on headless multi-GPU Linux: EGL device does not match current CUDA device

3 participants