docs/design/psf_get_en.md
Dividing the Request
The parameter server interface manipulates the entire model parameters, where the model parameters are divided into multiple partitions stored on different PS instances; therefore, division needs to be done as early as the request stage.
Sending the Request
Merging the Results
Interface
GetResult get(GetFunc get) throws AngelException;
Parameters
The parameter type of the get type psFunc is a GetFunc object, which encapsulates the parameters and the process of the get psf method:
public abstract class GetFunc {
protected final GetParam param;
public GetFunc(GetParam param) {
this.param = param;
}
public GetParam getParam() {return param;}
public abstract PartitionGetResult partitionGet(PartitionGetParam partParam);
public abstract GetResult merge(List<PartitionGetResult> partResults);
}
The parameter type of a GetFunc object is GetParam
get psf is PartitionGetParam typeGet type psFunc executes in two steps, represented by the partitionGet and merge methods, respectively.
partitionGet defines the specific process of getting results from a matrix partition; return type is PartitionGetResultmerge defines the process of merging results from all matrix partitions to obtain the final result; return type is GetResultThe two steps above need to be done on the worker side and PSServer side, respectively:
merge done on the worker sideThe specific process is shown in the following charts. The one on the left shows the worker-side process, and the one on the right shows the PS-side process:
Since the getFunc interface is low-level, we recommend users to inherit AggrFunc in creating psFunc, so as to avoid covering details.
public final class Sum extends UnaryAggrFunc {
...
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
double sum = 0.0;
for (PartitionGetResult partResult : partResults) {
sum += ((ScalarPartitionAggrResult) partResult).result;
}
return new ScalarAggrResult(sum);
}
Compile the code and build to create the jar file; when submitting the application, upload the jar using --angel.lib.jars, then the new psFunc can be called in the application with the sample code below:
Sum sumFunc = new Sum(new SumParam(matrixId, rowIndex));
double result = ((SumResult)psModel.get(sumFunc)).getResult();
Amax
Amin
Asum
Max
Min
Sum
Dot
Nnz
Nrm2