summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-05-06 11:49:19 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-05-06 22:13:43 +0200
commit183c29d907bc231c93ff5fe525040c931776b567 (patch)
tree260183318f47c6cce7b749c69c202786ca97dd42
parentdd280852800824748544444212842a322fe2e1dc (diff)
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.
-rw-r--r--opendc-experiments/opendc-experiments-tf20/build.gradle.kts5
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/Models.kt4
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt (renamed from opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/TensorFlowExperiment.kt)65
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt2
4 files changed, 56 insertions, 20 deletions
diff --git a/opendc-experiments/opendc-experiments-tf20/build.gradle.kts b/opendc-experiments/opendc-experiments-tf20/build.gradle.kts
index f61c8fef..7b3b084f 100644
--- a/opendc-experiments/opendc-experiments-tf20/build.gradle.kts
+++ b/opendc-experiments/opendc-experiments-tf20/build.gradle.kts
@@ -20,16 +20,15 @@
* SOFTWARE.
*/
-description = "Experiments with the OpenDC TensorFlow model"
+description = "TensorFlow application model in OpenDC"
/* Build configuration */
plugins {
- `experiment-conventions`
+ `kotlin-conventions`
`testing-conventions`
}
dependencies {
- api(projects.opendcHarness.opendcHarnessApi)
implementation(projects.opendcSimulator.opendcSimulatorCore)
implementation(projects.opendcSimulator.opendcSimulatorCompute)
implementation(projects.opendcCommon)
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/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt
index 19236029..7d72b48d 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/TensorFlowExperiment.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/TensorFlowTest.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 AtLarge Research
+ * Copyright (c) 2022 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
@@ -22,43 +22,76 @@
package org.opendc.experiments.tf20
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertAll
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.distribute.OneDeviceStrategy
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.
+ * Integration test suite for the TensorFlow application model in OpenDC.
*/
-public class TensorFlowExperiment : Experiment(name = "tf20") {
+class TensorFlowTest {
/**
- * The environment file to use.
+ * Smoke test that tests the capabilities of the TensorFlow application model in OpenDC.
*/
- private val environmentFile by anyOf("/kth.json")
+ @Test
+ fun testSmokeAlexNet() = runBlockingSimulation {
+ val envInput = checkNotNull(TensorFlowTest::class.java.getResourceAsStream("/kth.json"))
+ 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 batchSize = 32
+ val model = AlexNet(batchSize.toLong())
+ model.use {
+ it.compile(strategy)
+
+ it.fit(epochs = 9088 / batchSize, batchSize = batchSize)
+ }
+
+ device.close()
+
+ val stats = device.getDeviceStats()
+ assertAll(
+ { assertEquals(3309694252, clock.millis()) },
+ { assertEquals(8.2520933087E8, stats.energyUsage) }
+ )
+ }
/**
- * The batch size used.
+ * Smoke test that tests the capabilities of the TensorFlow application model in OpenDC.
*/
- private val batchSize by anyOf(16, 32, 64, 128)
-
- override fun doRun(repeat: Int): Unit = runBlockingSimulation {
- val envInput = checkNotNull(TensorFlowExperiment::class.java.getResourceAsStream(environmentFile))
+ @Test
+ fun testSmokeVGG() = runBlockingSimulation {
+ val envInput = checkNotNull(TensorFlowTest::class.java.getResourceAsStream("/kth.json"))
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())
+ val batchSize = 128
+ val model = VGG16(batchSize.toLong())
model.use {
it.compile(strategy)
it.fit(epochs = 9088 / batchSize, batchSize = batchSize)
}
+
+ device.close()
+
+ val stats = device.getDeviceStats()
+ assertAll(
+ { assertEquals(176230322904, clock.millis()) },
+ { assertEquals(4.296544914744E10, stats.energyUsage) }
+ )
}
}
diff --git a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt
index fd18a3a7..21d30250 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/test/kotlin/org/opendc/experiments/tf20/core/SimTFDeviceTest.kt
@@ -63,6 +63,8 @@ internal class SimTFDeviceTest {
launch { device.compute(2e6) }
}
+ device.close()
+
val stats = device.getDeviceStats()
assertAll(