syft.grid.private_grid

Module Contents

class syft.grid.private_grid.PrivateGridNetwork(*workers)

Bases: syft.grid.abstract_grid.AbstractGrid

search(self, *query)

Searches over a collection of workers, returning pointers to the results grouped by worker. :param query: List of tags used to identify the desired tensor.

Returns

list of pointers with pointers that matches with tags.

Return type

results

serve_model(self, model, id: str, mpc: bool = False, allow_remote_inference: bool = False, allow_download: bool = False, n_replica: int = 1)

Choose some node(s) on grid network to host a unencrypted / encrypted model. :param model: Model to be hosted. :param id: Model’s ID. :param mpc: Boolean flag to host a plain text / encrypted model :param allow_remote_inference: Allow to run inference remotely. :param allow_download: Allow to copy the model and run it locally. :param n_replica: Number of copies distributed through grid network.

Raises
  • RuntimeError – If grid network doesn’t have enough nodes to replicate the model.

  • NotImplementedError – If workers used by grid network aren’t grid nodes.

run_remote_inference(self, id: str, data: torch.Tensor, mpc: bool = False)

Search for a specific model registered on grid network, if found, It will run inference. :param id: Model’s ID. :param dataset: Data used to run inference. :param mpc: Boolean flag to run a plain text / encrypted model

Returns

Inference’s result.

Return type

Tensor

Raises
  • NotImplementedError – If workers used by grid network aren’t grid nodes.

  • RuntimeError – If model id not found.

query_model_hosts(self, id: str, mpc: bool = False)

Search for node host from a specific model registered on grid network, if found, It will return the frist host/ set of hosts that contains the desired model. :param id: Model’s ID. :param data: Data used to run inference. :param mpc: Boolean flag to search for a plain text / encrypted model

Returns

First worker that contains the desired model.

Return type

workers

Raises
  • NotImplementedError – If workers used by grid network aren’t grid nodes.

  • RuntimeError – If model id not found.

_host_encrypted_model(self, model, n_shares: int = 4)

This method wiil choose some grid nodes at grid network to host an encrypted model.

Parameters
  • model – Model to be hosted.

  • n_shares – number of workers used by MPC protocol.

Raise:

RuntimeError : If grid network doesn’t have enough workers to host an encrypted model or if model is not a plan.

_query_encrypted_model_hosts(self, id: str)

Search for an encrypted model and return its mpc nodes.

Parameters

id – Model’s ID.

Returns

Tuple structure containing Host, MPC Nodes and crypto provider.

Return type

Tuple

Raises

RuntimeError – If model id not found.

_run_unencrypted_inference(self, id: str, data)

Search for a plain-text model registered on grid network, if found, It will run inference. :param id: Model’s ID. :param dataset: Data used to run inference.

Returns

Inference’s result.

Return type

Tensor

Raises

RuntimeError – If model id not found.

_run_encrypted_inference(self, id: str, data)

Search for an encrypted model and perform inference. :param model_id: Model’s ID. :param data: Dataset to be shared/inferred. :param copy: Boolean flag to perform encrypted inference without lose plan.

Returns

Inference’s result.

Return type

Tensor

Raises

RuntimeError – If model id not found.