From dd280852800824748544444212842a322fe2e1dc Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 6 May 2022 11:45:35 +0200 Subject: fix(exp/tf20): Fix infinite loop due to invalid rounding This change fixes an issue with the `SimTFDevice` implementation where very small amounts of FLOPs would cause the device to enter an infinite loop. We now round the value up to ensure that the device always consumes FLOPs. --- .../src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'opendc-experiments/opendc-experiments-tf20/src/main') diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt index d2105196..90350142 100644 --- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt +++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt @@ -39,6 +39,7 @@ import java.util.* import kotlin.coroutines.Continuation import kotlin.coroutines.CoroutineContext import kotlin.coroutines.resume +import kotlin.math.ceil import kotlin.math.roundToLong /** @@ -137,7 +138,7 @@ public class SimTFDevice( if (activeWork.consume(consumedWork)) { this.activeWork = null } else { - val duration = (activeWork.flops / conn.capacity * 1000).roundToLong() + val duration = ceil(activeWork.flops / conn.capacity * 1000).toLong() conn.push(conn.capacity) return duration } -- cgit v1.2.3 From 183c29d907bc231c93ff5fe525040c931776b567 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 6 May 2022 11:49:19 +0200 Subject: refactor(exp/tf20): Convert experiment into integration test This change removes the `TensorFlowExperiment` in favour of an integration test that can be run during CI invocations. Given that the experiment was not very sophisticated (in terms of data collection), we believe it is better suited as an integration test. --- .../kotlin/org/opendc/experiments/tf20/Models.kt | 4 +- .../experiments/tf20/TensorFlowExperiment.kt | 64 ---------------------- 2 files changed, 3 insertions(+), 65 deletions(-) delete mode 100644 opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/TensorFlowExperiment.kt (limited to 'opendc-experiments/opendc-experiments-tf20/src/main') diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/Models.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/Models.kt index 9ef5b621..be166bd5 100644 --- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/Models.kt +++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/Models.kt @@ -20,8 +20,10 @@ * SOFTWARE. */ -package org.opendc.experiments.tf20.keras +package org.opendc.experiments.tf20 +import org.opendc.experiments.tf20.keras.Sequential +import org.opendc.experiments.tf20.keras.TrainableModel import org.opendc.experiments.tf20.keras.activations.Activation import org.opendc.experiments.tf20.keras.layer.conv.Conv2D import org.opendc.experiments.tf20.keras.layer.conv.ConvPadding diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/TensorFlowExperiment.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/TensorFlowExperiment.kt deleted file mode 100644 index 19236029..00000000 --- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/TensorFlowExperiment.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.experiments.tf20 - -import org.opendc.experiments.tf20.core.SimTFDevice -import org.opendc.experiments.tf20.distribute.* -import org.opendc.experiments.tf20.keras.AlexNet -import org.opendc.experiments.tf20.util.MLEnvironmentReader -import org.opendc.harness.dsl.Experiment -import org.opendc.harness.dsl.anyOf -import org.opendc.simulator.compute.power.LinearPowerModel -import org.opendc.simulator.core.runBlockingSimulation - -/** - * Experiments with the TensorFlow simulation model. - */ -public class TensorFlowExperiment : Experiment(name = "tf20") { - /** - * The environment file to use. - */ - private val environmentFile by anyOf("/kth.json") - - /** - * The batch size used. - */ - private val batchSize by anyOf(16, 32, 64, 128) - - override fun doRun(repeat: Int): Unit = runBlockingSimulation { - val envInput = checkNotNull(TensorFlowExperiment::class.java.getResourceAsStream(environmentFile)) - val def = MLEnvironmentReader().readEnvironment(envInput).first() - val device = SimTFDevice( - def.uid, def.meta["gpu"] as Boolean, coroutineContext, clock, def.model.cpus[0], def.model.memory[0], - LinearPowerModel(250.0, 60.0) - ) - val strategy = OneDeviceStrategy(device) - - val model = AlexNet(batchSize.toLong()) - model.use { - it.compile(strategy) - - it.fit(epochs = 9088 / batchSize, batchSize = batchSize) - } - } -} -- cgit v1.2.3