This is an automated email from the ASF dual-hosted git repository. sebwrede pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push: new 56b03de [SYSTEMDS-3018] Federated L2SVM Performance Test With Federated Compilation 56b03de is described below commit 56b03de92ae6d6c883ea5b4ad1290661c95546b1 Author: sebwrede <swr...@know-center.at> AuthorDate: Wed Oct 27 17:10:01 2021 +0200 [SYSTEMDS-3018] Federated L2SVM Performance Test With Federated Compilation This commit adds a performance test of federated L2SVM with and without federated compilation. Execution time is written to the usual execution time result file and compilation times are written to another result file in the same results folder. Closes #1425. --- scripts/perftest/fed/runL2SVMFed.sh | 73 ++++++++++++++++++++++ scripts/perftest/genL2SVMData.sh | 32 ++++++++++ scripts/perftest/runL2SVM.sh | 25 +++++--- src/main/java/org/apache/sysds/api/DMLOptions.java | 12 +++- src/main/java/org/apache/sysds/api/DMLScript.java | 2 +- .../sysds/test/usertest/UserInterfaceTest.java | 4 +- 6 files changed, 134 insertions(+), 14 deletions(-) diff --git a/scripts/perftest/fed/runL2SVMFed.sh b/scripts/perftest/fed/runL2SVMFed.sh new file mode 100755 index 0000000..62b9ee1 --- /dev/null +++ b/scripts/perftest/fed/runL2SVMFed.sh @@ -0,0 +1,73 @@ +#!/bin/bash +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + +# Read Parameters +FILENAME=$0 +CMD=${1:-"systemds"} +DATADIR=${2:-"temp"}/L2SVM +NUMFED=${3:-2} +MAXITR=${4:-100} + +# Error Prints +err_report() { + echo "Error in $FILENAME on line $1" +} +trap 'err_report $LINENO' ERR + +# Set Properties +export SYSDS_QUIET=1 +BASEPATH=$(dirname "$0") + +# Generate Data +${BASEPATH}/../genL2SVMData.sh systemds $DATADIR; + +# Start the Federated Workers on Localhost +${BASEPATH}/utils/startFedWorkers.sh systemds $DATADIR $NUMFED "localhost"; + +for d in "10k_1k_dense" "10k_1k_sparse" +do + # Split the generated data into partitions and create a federated object + ${CMD} -f ${BASEPATH}/data/splitAndMakeFederated.dml \ + --config ${BASEPATH}/../conf/SystemDS-config.xml \ + --nvargs data=${DATADIR}/X${d} nSplit=$NUMFED transposed=FALSE \ + target=${DATADIR}/X${d}_fed.json hosts=${DATADIR}/workers/hosts fmt="csv" + + ${CMD} -f ${BASEPATH}/data/splitAndMakeFederated.dml \ + --config ${BASEPATH}/../conf/SystemDS-config.xml \ + --nvargs data=${DATADIR}/Y${d} nSplit=$NUMFED transposed=FALSE \ + target=${DATADIR}/Y${d}_fed.json hosts=${DATADIR}/workers/hosts fmt="csv" + + + + for fedCompile in "" "--federatedCompilation" + do + runningMessage="-- Running L2SVM "$fedCompile" with federated data ("$d") on "$NUMFED" federated workers"; + echo "$runningMessage" >> results/times.txt + echo "$runningMessage" >> results/compiletimes.txt + # Run the L2SVM algorithm on the federated object + # $1 X, $2 Y, $3 unknown, $4 BASE, $5 maxiter, $6 CMD, $7 RunPrediction, $8 FEDERATEDCOMPILATION + ${BASEPATH}/../runL2SVM.sh ${DATADIR}/X${d}_fed.json ${DATADIR}/Y${d}_fed.json 2 $DATADIR ${MAXITR} systemds false $fedCompile | egrep -w 'compilation|L2SVM' | tee -a results/compiletimes.txt; + done +done + +# Kill the Federated Workers +${BASEPATH}/utils/killFedWorkers.sh $DATADIR; diff --git a/scripts/perftest/genL2SVMData.sh b/scripts/perftest/genL2SVMData.sh new file mode 100755 index 0000000..237de1d --- /dev/null +++ b/scripts/perftest/genL2SVMData.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +CMD=$1 +DATADIR=$2 + +FORMAT="binary" # can be csv, mm, text, binary +DENSE_SP=0.9 +SPARSE_SP=0.01 + +BASEPATH=$(dirname $0) + +#generate XS scenarios (80MB) +${CMD} -f ${BASEPATH}/../datagen/genRandData4LogisticRegression.dml --args 10000 1000 5 5 ${DATADIR}/w10k_1k_dense ${DATADIR}/X10k_1k_dense ${DATADIR}/Y10k_1k_dense 1 0 $DENSE_SP $FORMAT 1 +${CMD} -f ${BASEPATH}/../datagen/genRandData4LogisticRegression.dml --args 10000 1000 5 5 ${DATADIR}/w10k_1k_sparse ${DATADIR}/X10k_1k_sparse ${DATADIR}/Y10k_1k_sparse 1 0 $SPARSE_SP $FORMAT 1 diff --git a/scripts/perftest/runL2SVM.sh b/scripts/perftest/runL2SVM.sh index 03e966d..6c0ffd1 100755 --- a/scripts/perftest/runL2SVM.sh +++ b/scripts/perftest/runL2SVM.sh @@ -23,6 +23,8 @@ set -e CMD=$6 BASE=$4 +RUNPrediction=${7:-true} +FEDERATEDCOMPILATION=${8:-""} #for all intercept values for i in 0 1; do @@ -30,7 +32,8 @@ for i in 0 1; do tstart=$(date +%s.%N) # /algorithms/l2-svm.dml already calls a built-in function for the l2 svm. - ${CMD} -f ./algorithms/l2-svm.dml \ + ${CMD} -f ./../algorithms/l2-svm.dml \ + "$FEDERATEDCOMPILATION" \ --config conf/SystemDS-config.xml \ --stats \ --nvargs X=$1 Y=$2 icpt=$i tol=0.0001 reg=0.01 maxiter=$5 model=${BASE}/b fmt="csv" @@ -38,14 +41,16 @@ for i in 0 1; do ttrain=$(echo "$(date +%s.%N) - $tstart - .4" | bc) echo "L2SVM train ict="$i" on "$1": "$ttrain >> results/times.txt - #predict - tstart=$(date +%s.%N) - #${CMD} -f ./algorithms/l2-svm-predict.dml \ - ${CMD} -f scripts/l2-svm-predict.dml \ - --config conf/SystemDS-config.xml \ - --stats \ - --nvargs X=$1_test Y=$2_test icpt=$i model=${BASE}/b fmt="csv" scores=${BASE}/scores + if [ $RUNPrediction = true ] + then + #predict + tstart=$(date +%s.%N) + ${CMD} -f scripts/l2-svm-predict.dml \ + --config conf/SystemDS-config.xml \ + --stats \ + --nvargs X=$1_test Y=$2_test icpt=$i model=${BASE}/b fmt="csv" scores=${BASE}/scores - tpredict=$(echo "$(date +%s.%N) - $tstart - .4" | bc) - echo "L2SVM predict ict="$i" on "$1": "$tpredict >> results/times.txt + tpredict=$(echo "$(date +%s.%N) - $tstart - .4" | bc) + echo "L2SVM predict ict="$i" on "$1": "$tpredict >> results/times.txt + fi done diff --git a/src/main/java/org/apache/sysds/api/DMLOptions.java b/src/main/java/org/apache/sysds/api/DMLOptions.java index fbdaa90..5e10d73 100644 --- a/src/main/java/org/apache/sysds/api/DMLOptions.java +++ b/src/main/java/org/apache/sysds/api/DMLOptions.java @@ -72,7 +72,8 @@ public class DMLOptions { public boolean fedWorker = false; public int fedWorkerPort = -1; public boolean checkPrivacy = false; // Check which privacy constraints are loaded and checked during federated execution - + public boolean federatedCompilation = false; // Compile federated instructions based on input federation state and privacy constraints. + public final static DMLOptions defaultOptions = new DMLOptions(null); public DMLOptions(Options opts) { @@ -100,6 +101,7 @@ public class DMLOptions { ", help=" + help + ", lineage=" + lineage + ", w=" + fedWorker + + ", federatedCompilation=" + federatedCompilation + '}'; } @@ -259,6 +261,10 @@ public class DMLOptions { } dmlOptions.checkPrivacy = line.hasOption("checkPrivacy"); + if (line.hasOption("federatedCompilation")){ + OptimizerUtils.FEDERATED_COMPILATION = true; + dmlOptions.federatedCompilation = true; + } return dmlOptions; } @@ -313,6 +319,9 @@ public class DMLOptions { Option checkPrivacy = OptionBuilder .withDescription("Check which privacy constraints are loaded and checked during federated execution") .create("checkPrivacy"); + Option federatedCompilation = OptionBuilder + .withDescription("Compile federated instructions based on input federation state and privacy constraints.") + .create("federatedCompilation"); options.addOption(configOpt); options.addOption(cleanOpt); @@ -327,6 +336,7 @@ public class DMLOptions { options.addOption(lineageOpt); options.addOption(fedOpt); options.addOption(checkPrivacy); + options.addOption(federatedCompilation); // Either a clean(-clean), a file(-f), a script(-s) or help(-help) needs to be specified OptionGroup fileOrScriptOpt = new OptionGroup() diff --git a/src/main/java/org/apache/sysds/api/DMLScript.java b/src/main/java/org/apache/sysds/api/DMLScript.java index 4564f05..834ede0 100644 --- a/src/main/java/org/apache/sysds/api/DMLScript.java +++ b/src/main/java/org/apache/sysds/api/DMLScript.java @@ -595,7 +595,7 @@ public class DMLScript final String ANSI_RESET = "\u001B[0m"; StringBuilder sb = new StringBuilder(); sb.append(ANSI_RED + "\n"); - sb.append("An Error Occured : "); + sb.append("An Error Occurred : "); sb.append("\n" ); sb.append(StringUtils.leftPad(e.getClass().getSimpleName(),25)); sb.append(" -- "); diff --git a/src/test/java/org/apache/sysds/test/usertest/UserInterfaceTest.java b/src/test/java/org/apache/sysds/test/usertest/UserInterfaceTest.java index 04db802..48fbcd8 100644 --- a/src/test/java/org/apache/sysds/test/usertest/UserInterfaceTest.java +++ b/src/test/java/org/apache/sysds/test/usertest/UserInterfaceTest.java @@ -38,7 +38,7 @@ public class UserInterfaceTest extends Base { public void testStop(){ Pair<String,String> res = runThread("Stop.dml"); assertEquals("",res.getRight()); - assertTrue(res.getLeft().contains("An Error Occured :")); + assertTrue(res.getLeft().contains("An Error Occurred :")); assertTrue(res.getLeft().contains("DMLScriptException -- Stop Message!")); } @@ -46,7 +46,7 @@ public class UserInterfaceTest extends Base { public void SyntaxError(){ Pair<String,String> res = runThread("SyntaxError.dml"); assertEquals("",res.getRight()); - assertTrue(res.getLeft().contains("An Error Occured :")); + assertTrue(res.getLeft().contains("An Error Occurred :")); assertTrue(res.getLeft().contains("[Syntax error]")); assertTrue(res.getLeft().contains("ParseException --")); }