Skip to content

Commit 01ac099

Browse files
committed
Clear cache between benchmark runs
1 parent 65050cb commit 01ac099

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Tests/Benchmarks/ModelLoadingBenchmarks.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import Hub
3+
import MLX
34
import MLXLLM
45
import MLXLMCommon
56
import MLXVLM
@@ -38,6 +39,9 @@ struct ModelLoadingBenchmarks {
3839
print("LLM load run \(i): \(String(format: "%.0f", elapsed))ms")
3940

4041
_ = modelContext // silence unused warning
42+
43+
// Clear GPU cache to ensure independent measurements
44+
GPU.clearCache()
4145
}
4246

4347
let avg = times.reduce(0, +) / Double(times.count)
@@ -72,6 +76,9 @@ struct ModelLoadingBenchmarks {
7276
print("VLM load run \(i): \(String(format: "%.0f", elapsed))ms")
7377

7478
_ = modelContext // silence unused warning
79+
80+
// Clear GPU cache to ensure independent measurements
81+
GPU.clearCache()
7582
}
7683

7784
let avg = times.reduce(0, +) / Double(times.count)

0 commit comments

Comments
 (0)