cache_model_1: save client training partitions as standalone lists, not Subset (each client's data.pt holds the full training set)

オープン 初心者向け
#344 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

cache_model_1/prepare_training_data.py の Subset(full_train, indices[start:end]) の行と、その下にある torch.save の呼び出しから始め、次に cid_services/distribute_mnist.py の 115〜117 行目付近にあるペアのリストのパターンと比較してください。分割と保存の処理を main() から取り出し、合成データセットを受け取る関数にまとめ、client.py の DataLoader のパスが今もそのファイルを読み込めることを確認してください。10 個のセンチネル例と 3 つのアカウントを使ったテストで、各ファイルが自分の例だけを含み、.dataset 属性がなく、以前と同じ件数であることが示されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Follow-up from the approval review of issue No. 329, which found this writer and left it out of that PR. Checked against origin/develop @ c871ed1.

Problem

cache_model_1/prepare_training_data.py splits the Fashion-MNIST training set across client accounts by saving a torch.utils.data.Subset for each client:

  • cache_model_1/prepare_training_data.py:107: subset = Subset(full_train, indices[start:end])
  • :112: torch.save(subset, str(dest))

A Subset keeps a reference to its parent dataset, and torch.save serializes that parent too. So every client's data.pt contains all 60,000 training examples, not just its share. This is the same pattern issue No. 329 fixes for the audit shards.

Training itself is unaffected. cache_model_1/services/client.py:486 loads the file, and :508 iterates a DataLoader over it, which uses only the client's own indices. The problems are that each client's file includes the other clients' partitions, and each file is the size of the full training set.

Severity

This is low. The script is the local setup step from Documentation/public/guides/fashion-mnist-cnn.md (Step 2) and runs on public Fashion-MNIST, so no private data is exposed today. It matters because the script is the example that model owners copy. A real deployment with private client data that followed it would hand every client everyone else's data.

Proposed change

Save each partition as a standalone list of (image, label) pairs instead of a Subset. cid_services/distribute_mnist.py:115-117 already does this for MNIST:

subset_data = [(train_dataset[idx][0], train_dataset[idx][1]) for idx in idxs]
torch.save(subset_data, save_path)

Keep the existing split unchanged: the same contiguous ranges, with the remainder going to the last client. Keep the output path and the printed per-client counts too.

Out of scope
  • The audit shards (cache_model_*/services/modelowner.py:237), which are issue No. 329.
  • Changing the partitioning scheme (for example to shuffled or non-IID splits).
Acceptance criteria
  • A test runs the partitioning on a small synthetic training set with recognizable sentinel examples, for example one with 10 examples and 3 accounts. After torch.load, each client's file holds exactly its own examples, has no .dataset attribute, and contains no other client's sentinels.
  • Each client gets the same sample count it gets today, including the remainder going to the last client.
  • client.py's DataLoader path still loads and iterates the file unchanged.
  • The test needs no network access. Factor the split-and-save step out of main() so it can run without downloading Fashion-MNIST.
主要言語
Python
スター
4
フォーク
7
平均マージ
5日 15時間
マージ済み PR(30日)
43

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

InfiniteZeroFoundation/DevNet のほかの issue

InfiniteZeroFoundation/DevNet の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。