Repository navigation
Conversation
With no visible-device environment variable, the generated code selects device rank % ngpus, but ArgumentsMap._physical_deviceid used the bare rank. With more ranks than GPUs (e.g., two decoupler workers on a 1-GPU node), the device memory query then fails (None) and nbytes_avail_mapper raises TypeError: unsupported operand type(s) for -=: 'NoneType' and 'Integer'.
An explicit `deviceid` at or beyond the number of devices (visible ones, if e.g. CUDA_VISIBLE_DEVICES is set) was silently ignored by the generated code, which then ran on the current device, while the memory query either raised IndexError (an off-by-one on the visible devices) or wrapped around them. Check it along with the other runtime arguments and raise an InvalidArgument naming the device and the number available
…is one The OpenACC runtime was initialized before selecting the device, so every rank not using the default device also created a context on it. And with no device found, the MPI device selection computed `rank % 0`
This was referenced Oct 16, 2026
mloubout
reviewed
Oct 20, 2026
| deviceid = self.get('deviceid', -1) | ||
| var, visible_devices = get_visible_devices() | ||
| if visible_devices is None: | ||
| ngpus = self.platform.numa_domains |
Contributor
There was a problem hiding this comment.
That doesn't seem right, if there is no visible device we can't just create ngpus device ids none of those ids will be valid.
EdCaunt
requested changes
Oct 21, 2026
Comment on lines
+209
to
+213
| # Reversed order to ensure it is different to default | ||
| rank = grid.distributor.myrank | ||
| ngpus = op._platform.numa_domains | ||
| deviceid = (ngpus - 1 - rank) % ngpus | ||
|
|
Contributor
There was a problem hiding this comment.
This change seems seems pointless, possibly even detrimental when there is only one GPU on the system?
| if not isinstance(self.platform, Device): | ||
| return None | ||
|
|
||
| # The logical device ID is relative to the visible devices, if any |
Contributor
There was a problem hiding this comment.
This seems like a lot of unnecessary churn for what is ultimately a small tweak.
| raise InvalidArgument( | ||
| f"Device {deviceid} does not exist: {ngpus} device(s) available" | ||
| f"{visible}" | ||
| ) |
Contributor
There was a problem hiding this comment.
Previous behaviour was just to wrap around and warn the user. This seems like a downgrade in behaviour
Comment on lines
+1458
to
+1459
| if visible_devices is None: | ||
| return deviceid |
Contributor
There was a problem hiding this comment.
This was checked earlier, why is it being checked again here?
ggorman
force-pushed
the
fix-default-device-id
branch
from
October 21, 2026 21:53
cddcdcb to
f8d6cbb
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #3066; the base switches to
mainonce that merges.deviceidat or beyond the number of devices (the visible ones if e.g.CUDA_VISIBLE_DEVICESis set) was ignored by the generated code, which ran on the current device; the memory query raisedIndexError(an off-by-one on the visible devices) or wrapped around them.DeviceID._arg_checknow raisesInvalidArgument: Device 2 does not exist: 2 device(s) available (CUDA_VISIBLE_DEVICES=0,1)before anything is launched. Tests:TestDeviceID::test_nonexistent_deviceid[None|0,1];test_deviceid_per_ranknow picks devices that exist on any node.nvidia-smion two H200s: odd ranks held contexts on both GPUs; after the fix one each). With no device found, the MPI default selection computedrank % 0, a SIGFPE with an OpenMP runtime reporting zero devices. Tests:test_gpu_openacc.py::TestCodeGeneration::test_init_acc_env;test_gpu_openmp.py::test_init_omp_env_w_mpiexpectation updated.Each test fails on the parent commit.
Coordination with #2930: this PR validates the device ID in
arguments(), so with both changes #2930'stest_no_visible_devicesraises insideop.arguments()(verified for the masks-1,''andNoDevFiles); that call needs to move insidepytest.raises. Whichever lands second rebases.Refs #2711, #2930. Out of scope, as follow-ups: visible-device lists naming devices the process cannot see (e.g. a container with
--gpus device=1andCUDA_VISIBLE_DEVICES=1), UUID/MIG masks, and validatingdeviceidinestimate_memory(). Does not close #2711.🤖 Generated with Claude Code