← Back to Pull requests

Migrate CIFAR-10 example splitters to nvflare.utils.data.partition #5760

Closed
unknown closed this pull request without merging on Nov 30, 2026 16:45 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 03:34 UTC
Author

Part of #5265

Description

I migrated the duplicated CIFAR-10 Dirichlet splitters across the PyTorch, TensorFlow, Collab, Job API, self-paced tutorial, and Auto-FL research examples onto dirichlet_label_partition from nvflare.utils.data.partition (added in PR #5503). Each example keeps its dataset loading, site-.npy export format, and thin wrapper API (split_and_save, Cifar10DataSplitter, cifar10_split, create_data_splits) so existing job scripts continue working without changes.

Main details from review of PR #5503:

  • TensorFlow and Job API TF copies now pass seed cleanly through _partition_data and reshape Keras 2-D label arrays to 1-D before calling dirichlet_label_partition, so PyTorch and TensorFlow preparation paths produce identical site indices for the same ordered labels, parameters, and seed.

  • Caching splitters (Cifar10DataSplitter, fedavg_script_runner_xsite_val_cifar10 create_data_splits, and research/auto-fl-research) now record Seed and Partitioner in summary.txt and check line-exact matches, so cached legacy np.random splits are regenerated instead of being reused.

  • Replaced np.random.seed and np.random.dirichlet calls across all eight CIFAR-10 splitters, leaving non-CIFAR-10 examples and launcher seed/plotting changes for separate follow-up PRs.
  • Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).

  • Breaking change (fix or new feature that would cause existing functionality to change).

  • New tests added to cover the changes.

  • Quick tests passed locally by running ./runtest.sh.

  • In-line docstrings updated.

  • Documentation updated.
  • Testing

  • pytest tests/unit_test/examples/cifar10_data_split_test.py tests/unit_test/utils/data/partition_test.py: 68 passed (12 new tests plus 56 partition tests). They verify site-.npy export and loader compatibility, stale legacy cache rejection and regeneration, identical splits across all eight PyTorch and TensorFlow entry points without mutating global NumPy RNG state, non-positive alpha rejection, and no remaining np.random.dirichlet calls. Because PyTorch and TensorFlow are not installed in this local Windows environment, the new unit tests stub optional framework modules and use synthetic ordered label arrays; create_datasets is covered automatically when torch and torchvision are present in CI.

  • isort --check, black --check, flake8 (0 issues), ci/check_license_header.py, and research/auto-fl-research static compile/contract checks all pass after the final edit.
  • Risk

    Low risk to existing workflows. The partitioning algorithm is unchanged from nvflare.utils.data.partition, and because default_rng produces different index sequences than legacy global np.random, summary.txt partitioner checks ensure older cached site-*.npy directories are regenerated cleanly rather than mixed across versions.

    PTAL @holgerroth

    Diff: 364 lines (+273 / -91) across 4 files Reviewer: akshat-lakhera Review duration: 26711m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.66) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 364 lines diff across 4 files
    0.66
    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%
    56%
    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.353
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #5760"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    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: 65.9% (HIGH) · Higher = larger blast radius
    65.9%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 28.5% · Safe to merge
    28.5%
    Repository