← Back to Pull requests

fix: preserve case for extended resource keys #264

Closed
unknown closed this pull request without merging on Feb 07, 2026 20:32 UTC
View on GitHub
unknown unknown commented on Feb 04, 2026 12:37 UTC
Author

<!-- 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 keys

  • fix https://github.com/kubeflow/sdk/issues/263
  • This 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 cpu and memory), 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/Ascend910 in 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 to huawei.com/ascend910. Since the Kubernetes control plane is looking for the exact string, it would fail to find the resource, leaving the TrainJob pods in a Pending state.

    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"]

    Diff: 361 lines (+270 / -91) across 4 files Reviewer: szaher Review duration: 4795m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.6% (MEDIUM) · Higher = larger blast radius
    42.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%
    Repository