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 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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 小时
30 天内合并 PR
43

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

InfiniteZeroFoundation/DevNet 的其他 Issue

查看 InfiniteZeroFoundation/DevNet 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。