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

Aperta Adatta ai principianti
#344 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

Inizia da cache_model_1/prepare_training_data.py alla riga Subset(full_train, indices[start:end]) e alla chiamata torch.save subito sotto, poi confronta con il pattern a lista di coppie in cid_services/distribute_mnist.py intorno alle righe 115-117. Sposta il passaggio di suddivisione e salvataggio fuori da main() in una funzione che riceve un dataset sintetico, e verifica che il percorso DataLoader in client.py carichi ancora il file. È completato quando un test con 10 esempi sentinella e 3 account mostra che ogni file contiene solo i propri esempi, senza attributo .dataset e con gli stessi conteggi di prima.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Python
Stelle
4
Fork
7
Merge medio
5g 15h
PR unite (30g)
43

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di InfiniteZeroFoundation/DevNet

Tutte le issue di InfiniteZeroFoundation/DevNet

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.