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

Open Beginner friendly
#344 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Start in cache_model_1/prepare_training_data.py at the Subset(full_train, indices[start:end]) line and the torch.save call below it, then compare with the list-of-pairs pattern in cid_services/distribute_mnist.py around lines 115-117. Move the split-and-save step out of main() into a function that takes a synthetic dataset, and check that client.py's DataLoader path still loads the file. Done when a test with 10 sentinel examples and 3 accounts shows each file holds only its own examples, with no .dataset attribute and the same counts as before.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Python
Stars
4
Forks
7
Avg merge
5d 15h
Merged PRs (30d)
43

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from InfiniteZeroFoundation/DevNet

All issues in InfiniteZeroFoundation/DevNet

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.