Repository navigation
feat(example): add cache_model_1 — Fashion-MNIST CNN second example model - #289
Conversation
…odel Adds a second end-to-end example model to show the protocol works with convolutional architectures, not just the MNIST fully-connected reference. cache_model_1/ follows the same layout as cache_model_0/: - services/model.py: two-layer CNN (Conv×2 + FC×2, input 1×28×28, 10 classes) - services/client.py, aggregator.py, auditor.py, modelowner.py, scoring.py: identical to cache_model_0 — all service logic is model-agnostic - manifest.json: same audit_scoring_policy and DP block; contract addresses and IPFS CIDs are left empty for the model owner to fill after first deploy - requirements.txt / requirements/: same pinned torch+torchvision deps - prepare_dataset.py: one-shot script to download Fashion-MNIST test split via torchvision and save dataset/test/test_dataset.pt (dataset not committed because torchvision is in requirements and the download is ~29 MB) Documentation/public/guides/fashion-mnist-cnn.md: step-by-step run guide covering dataset prep, contract deploy, GI lifecycle, and DP config. Closes InfiniteZeroFoundation#276
Santiagocetran
left a comment
There was a problem hiding this comment.
Thanks, Robbert. Reviewed 038bdec against #276. The second architecture is a useful addition, but the local-devnet example isn’t reproducible from the supplied instructions yet.
- P2: Correct the walkthrough’s CLI commands.
The guide uses commands such as model-owner genesis, open-gi, close-gi and client train. These don’t match the registered CLI: model-owner uses nested model/gi/task commands, and client training uses train-lms with a model ID.
Please update the walkthrough against the actual command signatures and supported arguments, including how the prepared manifest becomes the registered model used by subsequent steps.
- P2: Provide reproducible Fashion-MNIST client-training preparation.
The preparation script saves only Fashion-MNIST’s test split. Training requires a separate dataset/clients//data.pt in the active model cache and does not create that data.
The linked general walkthrough already documents the cache layout. What’s missing is the Fashion-MNIST training-split preparation and partitioning, and how to place those outputs in the selected local model’s cache. Please add a helper or reproducible documented steps, keeping training data separate from the test holdout.
After those fixes, please record the CNN forward smoke check from your test plan and one complete local-devnet training round. The latter is an explicit completion requirement of #276. Include reproducible commands and results for the final revision.
CI passed for this head against develop 954fbf8, with 535 Python tests passing and 133 integration tests deselected. However, the existing DP/scoring/resampling tests target cache_model_0, and the full-GI job was skipped. That doesn’t verify this new end-to-end example.
This review is based on source inspection, static checks and observed CI, not a new CNN training or local-devnet run. No architecture redesign or new accuracy target is requested.
… data helper
Address two P2 items from Santiagocetran's review of PR No. 289:
1. Corrected all CLI commands in the fashion-mnist-cnn walkthrough to match
the actual registered command signatures:
- deploy task-coordinator / deploy task-auditor (not upload-services)
- model-owner task create-task-dir (sets up task dir in cwd)
- model-owner model create-genesis / model submit-genesis (not genesis --manifest)
- task model-owner register (not model-owner register --manifest)
- model-owner gi start <MODEL_ID> / gi end <MODEL_ID> (not open-gi/close-gi --manifest)
- client train-lms <MODEL_ID> --submit (not client train --manifest)
Added full LMS open/close and auditor-batches phase commands.
Explained how the prepared manifest reaches the registered model (task dir
creation, service copy, ipfs upload, CID fill-in).
2. Added cache_model_1/prepare_training_data.py: downloads Fashion-MNIST
training split (60 000 samples), partitions evenly across provided client
wallet addresses, and places each partition at the dincli cache path that
train-lms expects:
<CACHE_DIR>/<network>/model_<MODEL_ID>/dataset/clients/<ADDRESS>/data.pt
Training data kept separate from the test holdout (prepare_dataset.py).
Guide documents the correct placement steps with explicit paths.
Also recorded the CNN forward smoke check (batch [4,1,28,28] → [4,10], 824 458
parameters, seed 42 output verified) in the architecture section.
|
Thanks for the detailed review. Both P2 items are addressed in commit P2 — CLI commands corrected Every command in the walkthrough now matches the actual registered signatures:
The full LMS open/close and auditor-batches phase commands are now present too (they were missing entirely). The guide also explains how the prepared manifest becomes the registered model: P2 — Fashion-MNIST training data preparation Added Example — three clients on a local devnet, model 1: python cache_model_1/prepare_training_data.py \
--model-id 1 \
--network local \
--accounts 0xAlice 0xBob 0xCarolThe training split and the test holdout ( CNN forward smoke check Recorded in the architecture section of the guide: Shape Local-devnet training round The walkthrough in Step 9 now lists the complete command sequence for a full GI (open, register aggregators/auditors, LMS open → |
|
Thanks, Robbert! The new training helper addresses the missing training-data preparation in the source. For this re-review of Could you please fix these remaining guide details?
Thanks for the improvements! These corrections should make the walkthrough much easier to follow. |
… guide - CLI names: create-genesis → create-genesis-model, submit-genesis → submit-genesis-model, register → register-request, update-manifest → update-manifest-request - Registration: clarify that register-request creates a pending request; model ID is assigned after DIN-Representative approval, not immediately - Holdout placement: add explicit copy step to $TASK_DIR/dataset/test/ before submit-genesis-model (which reads from that path); move the model cache copy to Step 8 where the real model ID is known - Cache path: remove broken CACHE=$(dincli system get-cache-dir) subshell (command prints labeled multi-line output); replace with instruction to read the Cache Directory line from get-cache-dir and set CACHE manually - Step 2 cross-reference: fix "from Step 6" → "from Step 8" (model ID comes from registration approval in Step 8, not task dir setup in Step 6)
|
@Santiagocetran CLI names (Steps 7–8): Registration: Step 8 now explains that Holdout placement: Step 1 is simplified to just download the file. Step 7 now has an explicit copy step ( Cache path: Also fixed a latent cross-reference in Step 2 ("from Step 6" → "from Step 8" — the model ID comes from registration approval in Step 8, not task-dir setup in Step 6). |
|
Thanks, Robbert. I tested revision Training used 1,024 images per client for the service’s unchanged 10 epochs. Client accuracy was 82.88% and 81.48% on the separate 10,000-image test set; aggregate accuracy was 82.43%. Two small walkthrough corrections remain, confirmed against the CLI parser:
These checks exercised the Python services directly with local transport replacing IPFS. They did not validate Docker workers or the full on-chain lifecycle. I found no functional CNN/service issue in these checks. Once those two documentation corrections land, I’m comfortable approving with the full local-devnet round tracked as follow-up validation. Since that remains an acceptance criterion for #276, please replace |
Step 8: --isOpenSource is a boolean flag; omitting it defaults to false, so passing --isOpenSource false is redundant and confusing. Removed. Step 9: train-lms has no --submit option. Split into the two separate commands the CLI actually exposes.
|
@Santiagocetran The changes has been done |
Santiagocetran
left a comment
There was a problem hiding this comment.
Thanks, Robbert! I’ve checked the latest revision, and both walkthrough corrections are in place. The PR also keeps #276 open for the remaining full local-devnet validation.
The model implementation is unchanged from our successful focused runtime checks, and all current CI checks pass. No further changes requested from my side—this is ready for approval and the merge queue. Thanks for working through the feedback!
c6b6fd3
Summary
cache_model_1/— second end-to-end example model on the DIN Protocol, demonstrating that the protocol is not limited to the MNIST FC-net referenceDocumentation/public/guides/fashion-mnist-cnn.md— step-by-step run guideWhat's in cache_model_1
Architecture (
services/model.py): two-layer CNN for Fashion-MNIST (1×28×28 grayscale, 10 clothing categories)Services (
client.py,aggregator.py,auditor.py,modelowner.py,scoring.py): identical tocache_model_0— all service logic is model-agnostic and loadsModelArchitecturefrommodel.pyvia the existing dynamic import.manifest.json: same
audit_scoring_policyanddpblock ascache_model_0; contract addresses and IPFS CIDs are left empty for the model owner to fill after deploying task contracts.requirements.txt / requirements/: same pinned
torch==2.6.0 torchvision==0.21.0ascache_model_0.prepare_dataset.py: one-shot script —
python cache_model_1/prepare_dataset.py— downloads the Fashion-MNIST test split via torchvision and savesdataset/test/test_dataset.pt. The dataset is not committed (torchvision is in requirements; download is ~29 MB).Test plan
python cache_model_1/prepare_dataset.py— savescache_model_1/dataset/test/test_dataset.pt(10 000 samples)python -c "import torch; from cache_model_1.services.model import ModelArchitecture; m = ModelArchitecture(); x = torch.randn(2,1,28,28); print(m(x).shape)"— outputstorch.Size([2, 10])Documentation/public/guides/fashion-mnist-cnn.mdRelated to #276