fix: preserve case for extended resource keys #264
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 361 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.352
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #264"
general
weight: 0.35
szaher
<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, check our contributor guidelines: https://www.kubeflow.org/docs/about/contributing
2. To know more about Kubeflow SDK, check the developer guide:
https://github.com/kubeflow/sdk/blob/main/CONTRIBUTING.md
3. If you want faster PR reviews, check how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
-->
What this PR does / why we need it:
fix: preserve case for extended resource keysThis PR fixes a bug in the Kubeflow Trainer SDK where resource keys were being unconditionally lowercased. While this is acceptable for standard Kubernetes resources (like
cpuandmemory), it causes resource allocation failures for Extended Resources (e.g.,huawei.com/Ascend910) which are case-sensitive.The Problem
Device plugins (like the Huawei Ascend plugin) register resources with specific casing. When a user specifies
huawei.com/Ascend910in their [resources_per_node](cci:1://file:///home/danish/opensource/kubeflow/sdk/kubeflow/trainer/backends/kubernetes/utils.py:222:0-260:20), the SDK previously converted this tohuawei.com/ascend910. Since the Kubernetes control plane is looking for the exact string, it would fail to find the resource, leaving theTrainJobpods in aPendingstate.Proposed Changes
Modified [sdk/kubeflow/trainer/backends/kubernetes/utils.py](cci:7://file:///home/danish/opensource/kubeflow/sdk/kubeflow/trainer/backends/kubernetes/utils.py:0:0-0:0) to implement a selective lowercasing strategy:
1. Whitelist normalization: Only lowercase keys that are standard Kubernetes resources (
cpu,memory,ephemeral-storage) or known aliases (gpu,mig-*).2. Case preservation: For all other keys (extended resources), maintain the original casing provided by the user.
Resource Transformation Logic
```mermaid
graph TD
User["User Input (Python dict)"] -->|"e.g., {'huawei.com/Ascend910': '1'}"| SDK["SDK Logic (get_resources_per_node)"]
subgraph Buggy_Logic ["Before Fix (Indiscriminate Lowercasing)"]
SDK -->|"k.lower()"| LowerCase["All keys lowercased"]
LowerCase -->|Result| FailedYAML["TrainJob YAML: huawei.com/ascend910"]
end
subgraph Fixed_Logic ["After Fix (Selective Normalization)"]
SDK -->|"Check if standard?"| Branch{Standard / Alias?}
Branch -->|Yes| Lower["Lowercase (cpu, memory, etc.)"]
Branch -->|No| Preserve["Preserve Case (huawei.com/Ascend910)"]
Lower -->|Result| GoodYAML["TrainJob YAML: Correct keys"]
Preserve -->|Result| GoodYAML
end
FailedYAML -->|"Scheduling Error"| Fail["NPU Not Allocated (Mismatch)"]
GoodYAML -->|"Scheduling Success"| Success["NPU Allocated Successfully"]