Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML-84] Use Barrier Execution Mode to schedule oneCCL ranks together #344

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NaiveBayesDALImpl(val uid: String,

OneCCL.cleanup()
ret
}.collect()
}.barrier().mapPartitions(iter => iter).collect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get the meaning of mapPartitions(iter => iter) ?


// Make sure there is only one result from rank 0
assert(results.length == 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class RandomForestClassifierDALImpl(val uid: String,
}
OneCCL.cleanup()
ret
}.collect()
}.barrier().mapPartitions(iter => iter).collect()

rfcTimer.record("Training")
rfcTimer.print()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,18 @@ class KMeansDALImpl(var nClusters: Int,
}
OneCCL.cleanup()
ret
}.collect()
}
results.count()
val barrierRDD = results.barrier().mapPartitions(iter => iter).collect()

// Make sure there is only one result from rank 0
assert(results.length == 1)
assert(barrierRDD.length == 1)
kmeansTimer.record("Training")
kmeansTimer.print()

val centerVectors = results(0)._1
val totalCost = results(0)._2
val iterationNum = results(0)._3
val centerVectors = barrierRDD(0)._1
val totalCost = barrierRDD(0)._2
val iterationNum = barrierRDD(0)._3

if (iterationNum == maxIterations) {
logInfo(s"KMeans reached the max number of iterations: $maxIterations.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PCADALImpl(val k: Int,
def train(data: RDD[Vector]): PCADALModel = {
val pcaTimer = new Utils.AlgoTimeMetrics("PCA")
val normalizedData = normalizeData(data)

val sparkContext = normalizedData.sparkContext
val useDevice = sparkContext.getConf.get("spark.oap.mllib.device", Utils.DefaultComputeDevice)
val computeDevice = Common.ComputeDevice.getDeviceByName(useDevice)
Expand Down Expand Up @@ -104,7 +105,7 @@ class PCADALImpl(val k: Int,
}
OneCCL.cleanup()
ret
}.collect()
}.barrier().mapPartitions(iter => iter).collect()
pcaTimer.record("Training")
pcaTimer.print()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ALSDALImpl[@specialized(Int, Long) ID: ClassTag]( data: RDD[Rating[ID]],
result
)
Iterator(result)
}.cache()
}.cache().barrier().mapPartitions(iter => iter)

val usersFactorsRDD = results
.mapPartitionsWithIndex { (index: Int, partiton: Iterator[ALSResult]) =>
Expand All @@ -127,7 +127,7 @@ class ALSDALImpl[@specialized(Int, Long) ID: ClassTag]( data: RDD[Rating[ID]],
}.toIterator
}
ret
}.setName("userFactors").cache()
}.setName("userFactors").cache().barrier().mapPartitions(iter => iter)

val itemsFactorsRDD = results
.mapPartitionsWithIndex { (index: Int, partiton: Iterator[ALSResult]) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class LinearRegressionDALImpl( val fitIntercept: Boolean,
}
OneCCL.cleanup()
ret
}.collect()
}.barrier().mapPartitions(iter => iter).collect()

// Make sure there is only one result from rank 0
assert(results.length == 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class RandomForestRegressorDALImpl(val uid: String,
}

ret
}.collect()
}.barrier().mapPartitions(iter => iter).collect()
rfrTimer.record("Training")
rfrTimer.print()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class CorrelationDALImpl(
}
OneCCL.cleanup()
ret
}.collect()
}.barrier().mapPartitions(iter => iter).collect()
corTimer.record("Training")
corTimer.print()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class SummarizerDALImpl(val executorNum: Int,
}
OneCCL.cleanup()
ret
}.collect()
}.barrier().mapPartitions(iter => iter).collect()
sumTimer.record("Training")
sumTimer.print()

Expand Down
Loading