This issue covers improvements to the differential privacy pipeline used by Infinite Zero Network during local client training and update submission.
The DevNet baseline in client.py now supports three manifest-driven DP mechanisms:
post_training_gaussianpost_training_laplaceupdate_gaussian
That is still a starter privacy layer rather than a production-ready one. The next step is to keep improving the privacy math, accounting, and service-generation workflow while preserving a clean manifest-driven developer experience.
The model manifest at manifest.json can be used to define differential privacy parameters for a task.
That means DP behavior should not be limited to hardcoded values inside client.py. A model owner should be able to place DP-related settings in the manifest and let services read them at runtime.
Recommended manifest shape:
{
"dp": {
"enabled": true,
"mode": "afterTraining",
"mechanism": "post_training_gaussian",
"parameters": {
"clipping_norm": 1.0,
"noise_multiplier": 0.5,
"laplace_scale": 0.35,
"clip_scope": "per_layer"
}
}
}The nested dp object is the current config surface for the DevNet client service.
These parameters can be accessed inside services through the injected service runtime context:
# Example of how to resolve DP parameters in a service from manifest:
def train_client_model_and_upload_to_ipfs(
genesis_model_ipfs_hash,
account_address,
effective_network="local",
initial_model_ipfs_hash=None,
model_base_dir="",
gi=None,
runtime=None,
):
dp_config = resolve_dp_config(runtime=runtime)For example, a client service can resolve manifest-driven DP settings from runtime instead of hardcoding them or reloading manifest state manually:
if dp_config["enabled"] and dp_config["mode"] == "afterTraining":
private_state_dict = apply_dp_mechanism(
trained_state_dict,
dp_config,
reference_state_dict=reference_state_dict,
)This is why the runtime context was added: dincli resolves the manifest once for a service run, injects it into the service call, and lets service code read DP configuration through runtime.get_manifest_key(...). That keeps privacy configuration in the manifest, makes service behavior easier to tune per model, and avoids coupling service code to CLI-side manifest lookup details.
Current behavior in client.py:
post_training_gaussian: clips the final model weights and adds Gaussian noise tensor-by-tensor.post_training_laplace: clips the final model weights and adds Laplace noise tensor-by-tensor.update_gaussian: computes the local update relative to the starting model, clips that update, adds Gaussian noise, and reconstructs a full private weight file so the existing aggregator contract does not change.
Supported parameters in the manifest today:
clipping_normnoise_multiplierlaplace_scaleclip_scopewith valuesper_layerorglobal
Compatibility notes:
dp.enabled: falsebypasses privacy and uploads the raw trained weights.- if the
dpblock is absent, privacy is treated as disabled. update_gaussianuses the starting model for the round as its reference, which is the latest global model when one is available and the genesis model otherwise.
Current lineage for the DevNet client-side DP implementation:
- The shipped implementation in client.py was written directly for this repository and is the authoritative source for the current behavior.
- The manifest/runtime access pattern is based on the local
dincliruntime context in runtime.py, not on an external DP library. - The current mechanisms use plain PyTorch tensor operations and do not directly vendor code from an external privacy library or from the data-valuation repositories below.
Related research and repository references that informed the direction:
- Threshold KNN-Shapley paper: https://arxiv.org/abs/2308.15709
- TKNN-Shapley: README.md
- TKNN-Shapley privacy/accounting helpers: helper_privacy.py and helper_knn.py
- Datascope repository: README.md
- Awesome Data Valuation list: README.md
The important boundary is this:
- DevNet currently implements simple manifest-driven Gaussian/Laplace/update perturbation for local model submission.
- TKNN-Shapley and the related valuation repositories were used as reference material for DP accounting hooks. Note that TKNN-Shapley itself is rejected for client model scoring due to FL privacy constraints (see Rejected Ideas: TKNN-Shapley).
Differential privacy helps reduce the risk that sensitive information can be inferred from model updates shared during federated learning.
For Infinite Zero Network, this matters because the protocol is intended to support:
- decentralized training across many participants
- validator-coordinated aggregation
- auditable reward and evaluation workflows
- future secure aggregation and privacy-preserving infrastructure
If privacy is only applied in a simplistic way, contributors cannot reason clearly about the trade-off between privacy and model utility, and the wider system cannot build reliable guarantees on top of it.
This also matters because the intended developer workflow is modular: model owners should be able to assemble service artifacts with different privacy options instead of editing low-level training code by hand.
dincli is expected to become a tool that helps model owners build the service artifacts used in a deployment, such as:
aggregator.pyauditor.pyclient.pymodel.pymodelowner.py
The goal is a modular workflow where a model owner can choose implementation options and parameters, generate the final service artifacts, and place those artifacts into the deployment manifest.
Within that workflow, differential privacy should be treated as a selectable capability rather than a single hardcoded implementation.
Current implementation lives primarily in:
cache_model_0/services/client.pycache_model_0/services/model.py
Related integration points include:
dincli/- aggregation workflows
- auditor workflows
- model-owner service generation workflows
The current approach roughly does the following:
- Train the local model.
- Resolve DP settings from the manifest/runtime.
- Apply the selected mechanism to either final weights or the local update.
- Upload a private
state_dictthat remains compatible with the current aggregator.
Representative logic now looks like:
dp_config = resolve_dp_config(runtime=runtime)
private_state_dict = apply_dp_mechanism(
model_architecture.state_dict(),
dp_config,
reference_state_dict=reference_state_dict,
)The current mechanism perturbs weights after local training completes.
That is simple to implement, but it is weaker and less principled than approaches such as:
- DP-SGD
- per-step clipping
- per-sample gradient clipping
The system does not currently report:
- epsilon (
ε) - delta (
δ) - privacy budget consumption
- accountant outputs over time
Without this, privacy claims are not measurable.
Parameters such as sigma = 0.5 and S = 1.0 are effectively hardcoded in the implementation. Those values should be configurable through the model manifest, code, config, or CLI inputs.
There is no clear mechanism for a model owner to choose among multiple differential privacy approaches when building a service package.
The product direction should support selecting between strategies such as:
- no differential privacy
- weight-level noise after training
- update-level privacy
- DP-SGD
- future custom privacy modules
That choice should be explicit in dincli and preserved in the generated artifacts or manifest configuration.
The current implementation modifies raw model weights directly rather than working with:
- gradients
- local deltas
- layer-level updates
That makes experimentation harder and weakens the connection to standard DP training practice.
The privacy logic is not yet designed to fit future workflows such as:
- secure aggregation
- subgroup aggregation
- encrypted or masked updates
- validator-side privacy-aware evaluation
Contributors should aim to improve the privacy pipeline while keeping the implementation practical for the current DevNet codebase.
Useful directions include:
- defining a
dincliinterface for selecting DP mechanisms during service generation - replacing or extending post-training noise with a more principled DP method
- reading DP parameters from the model manifest in client services
- making parameters configurable through
dincliand config files - making those selections visible in generated service artifacts and manifests
- adding privacy accounting outputs
- benchmarking privacy versus model utility
- documenting trade-offs and operational assumptions
The intended workflow for a model owner should look roughly like this:
- Define the model and service requirements.
- Choose whether differential privacy is enabled.
- Select a DP mechanism.
- Set mechanism-specific parameters in the manifest.
- Generate service artifacts with
dincli. - Reference the generated artifacts in the model-owner manifest.
The issue is not only about the privacy math. It is also about designing a clean developer experience for selecting, configuring, and materializing privacy behavior.
dincli should eventually support multiple differential privacy modes that a model owner can select during service generation.
Possible examples:
nonepost_training_gaussianupdate_gaussiandp_sgd
Each mode should define:
- where privacy is applied
- which parameters are required
- which optional parameters are available
- whether privacy accounting is supported
- whether the mode is compatible with future aggregation strategies
The tool should make it clear how parameters are chosen and applied.
Examples of parameters that may vary by DP strategy include:
sigmaornoise_multiplierclipping_normdelta- target
epsilon - accountant type
- per-layer versus global clipping
- update-level versus gradient-level privatization
Contributors should think about both:
- the user-facing configuration model
- the internal implementation path that maps those settings into generated code or runtime configuration
One acceptable direction is for dincli to generate service artifacts from modular templates or configuration-driven builders.
For example, a model owner might choose:
- a client training strategy
- a DP mechanism
- aggregation behavior
- auditor behavior
That selection should then influence generated files such as:
client.pyaggregator.pyauditor.pymodelowner.py
The exact implementation can vary, but the result should make it clear:
- which DP mechanism is active
- which parameters were selected
- where the mechanism is applied
- what assumptions the generated service makes
Move hardcoded privacy parameters into configuration or CLI options.
Example:
dp:
enabled: true
mechanism: post_training_gaussian
sigma: 1.0
clipping_norm: 1.0Expose useful training and privacy metadata, for example:
- clipping norm
- noise multiplier
- DP mode
- training accuracy
- privacy accountant status
Add flags in dincli so model owners can select privacy settings without patching code.
Example:
dincli build service \
--service client \
--dp post_training_gaussian \
--sigma 1.0 \
--clip-norm 1.0Replace a single global clipping pass with per-layer clipping, or at least make the clipping strategy swappable.
Design a CLI or config interface that allows model owners to choose one DP mode from multiple supported implementations.
The first version does not need every mechanism fully implemented, but it should establish a clean extension model.
Integrate an accountant and expose measurable privacy outputs.
Candidate options:
- Opacus accountant
- Renyi DP accountant
- moments accountant
Example output:
Privacy Budget:
epsilon = 4.82
delta = 1e-5
Evaluate or integrate a more standard private optimization flow.
Candidate options:
- Opacus
- TensorFlow Privacy
- custom DP-SGD implementation
Example:
from opacus import PrivacyEngine
privacy_engine = PrivacyEngine()
model, optimizer, data_loader = privacy_engine.make_private(
module=model,
optimizer=optimizer,
data_loader=data_loader,
noise_multiplier=1.1,
max_grad_norm=1.0,
)Instead of perturbing full model weights, compute and privatize the client update itself.
Example:
local_update = local_model - global_modelConnect DP strategy selection to the modular service-generation workflow so generated artifacts consistently reflect the chosen privacy behavior.
This may involve:
- config schema design
- template selection
- builder logic in
dincli - manifest-facing metadata
Research and prototype approaches that remain compatible with decentralized aggregation, such as:
- additive masking
- Bonawitz-style secure aggregation
- MPC-friendly update handling
Investigate whether future privacy layers could work alongside encrypted aggregation approaches, for example:
- CKKS
- TenSEAL
Explore robust aggregation methods that pair well with private updates, such as:
- Krum
- median aggregation
- trimmed mean
Investigate whether privacy metadata can inform:
- auditor-side validation
- reward scoring
- contributivity analysis
Contributors may submit one or more of the following:
- code improvements
- tests
- benchmarking results
- research notes
- documentation updates
- example experiments
- service-generation design proposals
A strong contribution to this issue should:
- improve the current privacy mechanism in a measurable way
- make DP selection understandable for model owners
- explain the privacy and utility trade-off clearly
- avoid hardcoded assumptions where configuration is more appropriate
- include tests or reproducible evaluation notes where possible
- fit the existing DevNet architecture rather than introducing isolated code
- align with a modular artifact-generation workflow in
dincli
| Topic | Description |
|---|---|
| DP-SGD | Proper private optimization |
| Adaptive Clipping | Dynamic clipping thresholds |
| Secure Aggregation | Privacy-preserving aggregation |
| Local vs Global DP | Compare approaches |
| Sparse Updates | Reduce communication overhead |
| Compression + DP | Quantization plus privacy |
| Personalized Privacy | Different budgets per client |
| Byzantine Robustness | Defend against malicious clients |
Differential privacy:
- Opacus
- TensorFlow Privacy
Cryptography and privacy tooling:
- PySyft
- TenSEAL
- PyCryptodome
Federated learning frameworks:
- Flower
- FedML
Relevant material:
TKNN-Shapley(Rejected for client model scoring, but remains a reference for privacy-aware data valuation). It includes:- private threshold KNN-Shapley
- naively privatized KNN-Shapley
- subsampled Gaussian mechanisms
- RDP and PRV-based privacy accounting hooks in
helper_knn.pyandhelper_privacy.py
datascopeis useful for scalable data valuation and KNN-Shapley context, but it is not a direct DP implementation in the checked-in code.awesome-data-valuationis a curated research index that is helpful for contribution-scoring scenarios, especially where privacy, valuation, and federated workflows intersect.
Concrete scenarios worth exploring next for Infinite Zero Network:
- privacy-preserving contributivity scoring for local model submissions (e.g., using leave-one-out or model-only updates)
- update subsampling plus privacy accounting for repeated rounds
- combining private updates with future secure aggregation or robust aggregation logic
cache_model_0/services/client.pycache_model_0/services/model.pydincli/- aggregation-related services
- auditor-related services
- model-owner service builder logic
This issue supports the broader goal of building decentralized AI systems where:
- users retain data ownership
- training happens collaboratively
- validators coordinate aggregation
- rewards remain transparent
- privacy guarantees become stronger and more measurable
It also supports a better developer experience where model owners can compose service behavior from explicit options and generate artifacts that are ready to place into a deployment manifest.
- Review the current implementation in
cache_model_0/services/client.py. - Identify where
dinclishould expose DP selection and parameter configuration. - Decide whether your contribution is implementation-focused, UX/config-focused, benchmarking-focused, or research-focused.
- Keep changes scoped and measurable.
- Add tests or documentation that explain the behavior you introduce.
- Submit a pull request with a concise summary of the privacy improvement and its trade-offs.
For a dedicated differential privacy reviewer, the key asks are:
- review the current code and documentation together;
- assess how effective the implemented mechanisms are likely to be in practice;
- explain the privacy versus utility tradeoff we should expect from each mechanism;
- identify where different classes of models should use different privacy mechanisms.
Important framing:
- different kinds of models may need different privacy mechanisms;
- a baseline that is acceptable for a small MNIST-style MLP may not be acceptable for CNNs, transformer-style models, recommender systems, sequence models, or embedding-heavy workloads;
- the correct privacy layer may vary between weight-level, update-level, gradient-level, and optimizer-level mechanisms depending on the model and task.
Please review these local files first:
- cache_model_0/services/client.py
- cache_model_0/manifest.json
- cache_model_0/services/aggregator.py
- dincli/services/runtime.py
- dincli/cli/client.py
- tests/test_cache_client_dp.py
- Documentation/technical/services/clients.md
- Documentation/technical/manifest.md
- Developer/CONTRIBUTING.md
Useful reference material (Note: TKNN-Shapley is rejected for client model scoring due to FL privacy constraints - see Rejected Ideas: TKNN-Shapley):
- Threshold KNN-Shapley paper: https://arxiv.org/abs/2308.15709
- TKNN-Shapley README
- TKNN-Shapley helper_privacy.py
- TKNN-Shapley helper_knn.py
- https://github.com/easeml/datascope
- https://github.com/daviddao/awesome-data-valuation
- Which of the three implemented mechanisms are useful enough to keep?
- Which of them should be treated only as temporary baselines?
- Which model classes likely need different privacy mechanisms entirely?
- How should we evaluate privacy effectiveness in a way that is honest and reproducible?
- What utility metrics should we track alongside privacy settings?
- What should be prioritized next: accountant integration, DP-SGD, adaptive clipping, update privatization, or privacy-aware scoring?