A distributed parameter server client component for ND4J, enabling parameter synchronization across multiple nodes in distributed machine learning workloads
npx @tessl/cli install tessl/maven-org-nd4j--nd4j-parameter-server-client@0.9.0ND4J Parameter Server Client is a distributed parameter server client component for ND4J (N-Dimensional Arrays for Java), enabling parameter synchronization across multiple nodes in distributed machine learning workloads. It serves as the client-side interface for communicating with parameter servers in distributed training scenarios.
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-parameter-server-client</artifactId>
<version>0.9.1</version>
</dependency>import org.nd4j.parameterserver.client.ParameterServerClient;import org.nd4j.parameterserver.client.ParameterServerClient;
import org.nd4j.linalg.api.ndarray.INDArray;
import io.aeron.Aeron;
// Build a parameter server client
ParameterServerClient client = ParameterServerClient.builder()
.aeron(aeronInstance)
.ndarrayRetrieveUrl("aeron:udp?endpoint=localhost:40323")
.ndarraySendUrl("aeron:udp?endpoint=localhost:40324")
.subscriberHost("localhost")
.masterStatusHost("localhost")
.masterStatusPort(33000)
.subscriberPort(40625)
.subscriberStream(12)
.build();
// Push model parameters to the server
INDArray modelParameters = model.params();
client.pushNDArray(modelParameters);The ND4J Parameter Server Client operates within a distributed training architecture:
The client uses a builder pattern for configuration and integrates seamlessly with DeepLearning4J training workflows, particularly in distributed training scenarios using ParallelWrapper.
Core client functionality for communicating with distributed parameter servers, supporting high-performance parameter synchronization across multiple training nodes.
public class ParameterServerClient {
public static Builder builder();
public void pushNDArray(INDArray array);
}Sends model parameters to the parameter server for distributed training coordination.
/**
* Push an NDArray containing model parameters to the parameter server
* @param array - The INDArray containing parameters to synchronize
*/
public void pushNDArray(INDArray array);Usage Example:
// After local training step, push updated parameters
INDArray updatedParams = neuralNetwork.params();
parameterServerClient.pushNDArray(updatedParams);Builder pattern for configuring the parameter server client with network endpoints and transport settings.
public static class Builder {
/**
* Set the Aeron messaging transport instance
* @param aeron - Aeron instance for high-performance messaging
* @return Builder instance for method chaining
*/
public Builder aeron(Aeron aeron);
/**
* Set the URL for retrieving NDArrays from the parameter server
* @param url - Aeron URL for parameter retrieval
* @return Builder instance for method chaining
*/
public Builder ndarrayRetrieveUrl(String url);
/**
* Set the URL for sending NDArrays to the parameter server
* @param url - Aeron URL for parameter sending
* @return Builder instance for method chaining
*/
public Builder ndarraySendUrl(String url);
/**
* Set the subscriber host address
* @param host - Host address for subscriber connection
* @return Builder instance for method chaining
*/
public Builder subscriberHost(String host);
/**
* Set the master status server host
* @param host - Host address for status server
* @return Builder instance for method chaining
*/
public Builder masterStatusHost(String host);
/**
* Set the master status server port
* @param port - Port number for status server
* @return Builder instance for method chaining
*/
public Builder masterStatusPort(int port);
/**
* Set the subscriber port
* @param port - Port number for subscriber connection
* @return Builder instance for method chaining
*/
public Builder subscriberPort(int port);
/**
* Set the subscriber stream identifier
* @param stream - Stream identifier for subscriber
* @return Builder instance for method chaining
*/
public Builder subscriberStream(int stream);
/**
* Build and return the configured ParameterServerClient
* @return Configured ParameterServerClient instance
*/
public ParameterServerClient build();
}Configuration Example:
ParameterServerClient client = ParameterServerClient.builder()
.aeron(mediaDriver.getAeron())
.ndarrayRetrieveUrl("aeron:udp?endpoint=localhost:40323")
.ndarraySendUrl("aeron:udp?endpoint=localhost:40324")
.subscriberHost("localhost")
.masterStatusHost("localhost")
.masterStatusPort(33000)
.subscriberPort(40625)
.subscriberStream(12)
.build();/**
* Builder class for configuring ParameterServerClient instances
*/
public static class Builder {
// Builder methods as documented above
}
/**
* ND4J's core n-dimensional array interface for parameter data
* From org.nd4j.linalg.api.ndarray package
*/
interface INDArray {
// Core n-dimensional array operations
// Full definition available in ND4J documentation
}
/**
* Aeron high-performance messaging transport
* From io.aeron package
*/
class Aeron {
// High-performance messaging transport implementation
// Full definition available in Aeron documentation
}The ParameterServerClient integrates with DeepLearning4J's parallel training infrastructure:
// Used within custom trainer implementations
public class ParameterServerTrainer extends DefaultTrainer {
private ParameterServerClient parameterServerClient;
@Override
public void feedDataSet(DataSet dataSet, long time) {
// Perform local training
model.fit(dataSet);
// Synchronize parameters
parameterServerClient.pushNDArray(model.params());
}
}
// Factory for creating parameter server trainers
ParameterServerTrainerContext context = new ParameterServerTrainerContext();
ParallelWrapper wrapper = new ParallelWrapper.Builder(model)
.trainerFactory(context)
.workers(numWorkers)
.build();The client requires these key dependencies:
io.aeron:aeron-all)org.nd4j:nd4j-api)org.nd4j:nd4j-parameter-server-node)