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

Offen Anfängerfreundlich
#344 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
70/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python, pytorch

Rechercherichtung

Beginne in cache_model_1/prepare_training_data.py bei der Zeile Subset(full_train, indices[start:end]) und beim darunterliegenden Aufruf von torch.save, vergleiche dann mit dem Muster der Liste von Paaren in cid_services/distribute_mnist.py um die Zeilen 115-117. Verschiebe den Schritt zum Aufteilen und Speichern aus main() in eine Funktion, die einen synthetischen Datensatz entgegennimmt, und prüfe, ob der DataLoader-Pfad in client.py die Datei weiterhin lädt. Fertig ist es, wenn ein Test mit 10 Sentinel-Beispielen und 3 Konten zeigt, dass jede Datei nur ihre eigenen Beispiele enthält, ohne das Attribut .dataset und mit denselben Anzahlen wie zuvor.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.
Vorherrschende Sprache
Python
Sterne
4
Forks
7
Ø Merge
5 T. 15 Std.
Gemergte PRs (30 T.)
43

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus InfiniteZeroFoundation/DevNet

Alle Issues in InfiniteZeroFoundation/DevNet

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.