Skip to content

fix: use configurable GPU resource name instead of hardcoded nvidia.com/gpu#7237

Open
nuthalapativarun wants to merge 3 commits intoflyteorg:masterfrom
nuthalapativarun:fix/gpu-resource-name-hardcoding-6746
Open

fix: use configurable GPU resource name instead of hardcoded nvidia.com/gpu#7237
nuthalapativarun wants to merge 3 commits intoflyteorg:masterfrom
nuthalapativarun:fix/gpu-resource-name-hardcoding-6746

Conversation

@nuthalapativarun
Copy link
Copy Markdown

Tracking issue

Closes #6746

Why are the changes needed?

Two code paths hardcoded "nvidia.com/gpu" when building Kubernetes ResourceList entries from Flyte GPU resource requirements. This hardcoding took precedence over the GpuResourceName field already configurable in K8sPluginConfig (via the gpu-resource-name Helm/propeller config value), making it impossible to use alternative GPU resource types such as amd.com/gpu or intel.com/gpu.

The affected paths were:

  • flyteplugins/go/tasks/pluginmachinery/flytek8s/utils.goToK8sResourceList used the package-level ResourceNvidiaGPU constant.
  • flytepropeller/pkg/controller/nodes/task/taskexec_context.goconvertTaskResourcesToRequirements used utils.ResourceNvidiaGPU.

Note that SanitizeGPUResourceRequirements and ApplyResourceOverrides in container_helper.go already correctly read from config.GetK8sPluginConfig().GpuResourceName. This PR brings the two remaining call sites into alignment.

What changes were proposed in this pull request?

  • flyteplugins/.../flytek8s/utils.go: Import flytek8s/config and replace ResourceNvidiaGPU with config.GetK8sPluginConfig().GpuResourceName in ToK8sResourceList.
  • flytepropeller/.../taskexec_context.go: Import flytek8s/config and replace utils.ResourceNvidiaGPU with flytek8sConfig.GetK8sPluginConfig().GpuResourceName in convertTaskResourcesToRequirements. Remove now-unused flytepropeller/pkg/utils import.
  • Tests: Update both test files to assert against config.GetK8sPluginConfig().GpuResourceName rather than the hardcoded constant, confirming the behavior is config-driven.

How was this patch tested?

  • go test ./go/tasks/pluginmachinery/flytek8s/... in flyteplugins/ — passes.
  • go test ./pkg/controller/nodes/task/... in flytepropeller/ — passes.

Labels

  • fixed

  • I updated the documentation accordingly.

  • All new and existing tests passed.

  • All commits are signed-off.

@Sovietaced
Copy link
Copy Markdown
Member

I've fixed this in our company's fork and I believe it was more involved than this due to handling of pod templates and needing to normalize the dummy GPU resource name to the configured one. If you can wait a week or two I can probably pull that work into master.

@Sovietaced
Copy link
Copy Markdown
Member

I've fixed this in our company's fork and I believe it was more involved than this due to handling of pod templates and needing to normalize the dummy GPU resource name to the configured one. If you can wait a week or two I can probably pull that work into master.

Oh this looks like some drive by AI assisted pull request so I'll wait to review this until I get back from vacation.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.95%. Comparing base (e938b03) to head (1ee6ed9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7237      +/-   ##
==========================================
- Coverage   56.96%   56.95%   -0.01%     
==========================================
  Files         931      931              
  Lines       58246    58247       +1     
==========================================
- Hits        33178    33173       -5     
- Misses      22014    22020       +6     
  Partials     3054     3054              
Flag Coverage Δ
unittests-datacatalog 53.51% <ø> (ø)
unittests-flyteadmin 53.10% <ø> (-0.04%) ⬇️
unittests-flytecopilot 43.06% <ø> (ø)
unittests-flytectl 64.14% <ø> (ø)
unittests-flyteidl 75.71% <ø> (ø)
unittests-flyteplugins 60.17% <100.00%> (ø)
unittests-flytepropeller 53.71% <100.00%> (+<0.01%) ⬆️
unittests-flytestdlib 62.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

nuthalapativarun and others added 2 commits April 19, 2026 01:52
…om/gpu

Two code paths hardcoded "nvidia.com/gpu" when mapping Flyte GPU resource
requirements to Kubernetes ResourceList entries, ignoring the
GpuResourceName field available in K8sPluginConfig. This prevented users
from using alternative GPU resource types (e.g. amd.com/gpu,
intel.com/gpu) even when correctly configured via the gpu-resource-name
Helm value.

- flyteplugins: ToK8sResourceList now reads GpuResourceName from
  config.GetK8sPluginConfig() instead of using the ResourceNvidiaGPU
  constant directly.
- flytepropeller: convertTaskResourcesToRequirements now reads
  GpuResourceName from flytek8sConfig.GetK8sPluginConfig() instead of
  utils.ResourceNvidiaGPU.
- Update tests in both packages to assert against the config-driven key.

Closes flyteorg#6746

Signed-off-by: Varun Nuthalapati <nuthalapativarun@gmail.com>
- Fix gci import ordering in taskexec_context_test.go (flytek8sConfig must
  come before io/mocks alphabetically)
- Set GpuResourceName explicitly in TestBuildResourceRayCustomK8SPod to
  match resourceRequirements fixture which uses nvidia.com/gpu; empty
  K8sPluginConfig caused key mismatch after ToK8sResourceList was updated
  to use configurable GPU resource name

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Varun Nuthalapati <nuthalapativarun@gmail.com>
@nuthalapativarun nuthalapativarun force-pushed the fix/gpu-resource-name-hardcoding-6746 branch from 18bd4af to 3522587 Compare April 19, 2026 08:53
@kumare3
Copy link
Copy Markdown
Contributor

kumare3 commented Apr 19, 2026

This has been greatly improved in v2, check the v2 branch - close
To release

@nuthalapativarun
Copy link
Copy Markdown
Author

Thanks for the context, @Sovietaced — happy to expand the scope to cover pod template normalization and dummy GPU resource name handling as well. If you can point me to the relevant code paths (or describe what your fork's fix looks like at a high level), I can incorporate that before your review. No rush given the vacation timeline.

@kumare3 — do you mean this should target the v2 branch instead of master, or that the issue is already resolved there and this PR should be closed? Happy to follow whichever path makes more sense for the project.

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.

[BUG] Unable to use GPUs besides "nvidia.com/gpu" due to hardcoding

3 participants