Module bastionlab.torch.client
Classes
BastionLabTorch()-
BastionLab Torch RPC Handle
Methods
RemoteDataset(self, *args, **kwargs) ‑> bastionlab.torch.RemoteDataset-
Returns a RemoteDataset object encapsulating a training and testing dataloaders on the remote server that uses this client to communicate with the server.
Args: *args: all arguments are forwarded to the
bastionlab.torch.RemoteDatasetconstructor. **kwargs: all keyword arguments are forwarded to thebastionlab.torch.RemoteDatasetconstructor. RemoteLearner(self, *args, **kwargs) ‑> bastionlab.torch.RemoteLearner-
Returns a
bastionlab.torch.RemoteLearnerobject encapsulating a model and hyperparameters for training and testing on the remote server and that uses this client to communicate with the server.Args: *args: all arguments are forwarded to the
bastionlab.torch.RemoteLearnerconstructor. **kwargs: all keyword arguments are forwarded to thebastionlab.torch.RemoteLearnerconstructor. RemoteTensor(self, tensor: torch.Tensor) ‑> bastionlab.torch.RemoteTensor-
Returns a RemoteTensor which represents a reference to the uploaded tensor.
Args: tensor: The tensor to be uploaded.
delete_dataset(self, ref: Union[ForwardRef('bastionlab.torch.RemoteDataset'), bastionlab_pb2.Reference])-
Deletes the dataset correponding to the given
refreference on the BastionLab Torch server.Args: ref: BastionLab Torch gRPC protocol reference of the dataset to be deleted.
delete_module(self, ref: bastionlab_pb2.Reference) ‑> None-
Deletes the module correponding to the given
refreference on the BastionLab Torch server.Args: ref: BastionLab Torch gRPC protocol reference of the module to be deleted.
fetch_dataset(self, ref: Union[ForwardRef('bastionlab.torch.RemoteDataset'), bastionlab_pb2.Reference]) ‑> bastionlab.torch.utils.TensorDataset-
Fetches the distant dataset with a BastionLab Torch gRPC protocol reference.
Args: ref: BastionLab Torch gRPC protocol reference object corresponding to the distant dataset.
Returns: A dataset instance built from received data.
fetch_model_weights(self, model: torch.nn.modules.module.Module, ref: bastionlab_pb2.Reference) ‑> None-
Fetches the weights of a distant trained model with a BastionLab Torch gRPC protocol reference and loads the weights into the passed model instance.
Args: model: The Pytorch's nn.Module whose weights will be replaced by the fetched weights. ref: BastionLab Torch gRPC protocol reference object corresponding to the distant trained model.
get_available_datasets(self) ‑> List[bastionlab_pb2.Reference]- Returns the list of BastionLab Torch gRPC protocol references of all datasets on the server.
get_available_devices(self) ‑> List[str]- Returns the list of devices available on the server.
get_available_models(self) ‑> List[bastionlab_pb2.Reference]- Returns the list of BastionLab Torch gRPC protocol references of all available models on the server.
get_available_optimizers(self) ‑> List[str]- Returns the list of optimizers supported by the server.
get_metric(self, run: bastionlab_pb2.Reference) ‑> bastionlab_torch_pb2.Metric-
Returns the value of the metric associated with the given
runreference.Args: run: BastionLab Torch gRPC protocol reference of the run whose metric is read.
send_dataset(self, dataset: torch.utils.data.dataset.Dataset, name: str, description: str = '', privacy_limit: Optional[float] = None, chunk_size: int = 4194285, batch_size: int = 1024, train_dataset: Optional[bastionlab_pb2.Reference] = None, progress: bool = False) ‑> bastionlab_pb2.Reference-
Uploads a Pytorch Dataset to the BastionLab Torch server.
Args: model: The Pytorch Dataset to upload. name: A name for the dataset being uploaded. description: A string description of the dataset being uploaded. chunk_size: Size of a chunk in the BastionLab Torch gRPC protocol in bytes. batch_size: Size of a unit of serialization in number of samples, increasing this value may increase serialization throughput at the price of a higher memory consumption. train_dataset: metadata, True means this dataset is suited for training, False that it should be used for testing/validating only
Returns: BastionLab Torch gRPC protocol's reference object.
send_model(self, model: torch.nn.modules.module.Module, name: str, description: str = '', chunk_size: int = 4194285, progress: bool = False) ‑> bastionlab_pb2.Reference-
Uploads a Pytorch module to the BastionLab Torch server.
This endpoint transforms Pytorch modules into TorchScript modules and sends them to the BastionLab Torch server over gRPC.
Args: model: The Pytorch nn.Module to upload. name: A name for the module being uploaded. description: A string description of the module being uploaded. chunk_size: Size of a chunk in the BastionLab Torch gRPC protocol in bytes.
Returns: BastionLab Torch gRPC protocol's reference object.