Gemma 4 26B-A4B inference in ~2 GB of RAM on any M-series MacBook
Swift apple-silicongemmagemma4gemma4-26b-a4bgpgpullmllm-inferencelocal-aimacosmetalon-device-aion-device-llmswift
Fix download ETA countdown updates (#17)
Andrey Mikhaylove8f4eae9283d
diff --git a/Sources/TurboFieldfareApp/Core/Installation/DownloadETAEstimator.swift b/Sources/TurboFieldfareApp/Core/Installation/DownloadETAEstimator.swiftindex 388e48a6..6a3db301 100644--- a/Sources/TurboFieldfareApp/Core/Installation/DownloadETAEstimator.swift+++ b/Sources/TurboFieldfareApp/Core/Installation/DownloadETAEstimator.swift@@ -77,10 +77,6 @@ public struct DownloadETAEstimator: Sendable {let estimate = Double(observation.totalBytes - completed) / rateguard estimate.isFinite, estimate >= 0 else { return .estimating }- if let lastETA,- abs(estimate - lastETA) <= max(60, lastETA * 0.2) {- return .remaining(seconds: lastETA)- }lastETA = estimatelastUpdateTime = timestampreturn .remaining(seconds: estimate)diff --git a/Tests/TurboFieldfareApp/Core/Installation/DownloadETAEstimatorTests.swift b/Tests/TurboFieldfareApp/Core/Installation/DownloadETAEstimatorTests.swiftindex d26fcdbb..55331294 100644--- a/Tests/TurboFieldfareApp/Core/Installation/DownloadETAEstimatorTests.swift+++ b/Tests/TurboFieldfareApp/Core/Installation/DownloadETAEstimatorTests.swift@@ -23,7 +23,7 @@ struct DownloadETAEstimatorTests {#expect(seconds > 9 && seconds < 11)}- @Test func smallChangesKeepTheVisibleEstimateStable() {+ @Test func holdsVisibleEstimateWithinUpdateInterval() {var estimator = DownloadETAEstimator()let mib = UInt64(1024 * 1024)_ = estimator.update(@@ -33,11 +33,87 @@ struct DownloadETAEstimatorTests {.init(reusedBytes: 0, downloadedThisRunBytes: 100 * mib, totalBytes: 600 * mib),timestamp: 10)let second = estimator.update(- .init(reusedBytes: 0, downloadedThisRunBytes: 210 * mib, totalBytes: 600 * mib),- timestamp: 41)+ .init(reusedBytes: 0, downloadedThisRunBytes: 200 * mib, totalBytes: 600 * mib),+ timestamp: 39)#expect(first == second)}+ @Test func publishesUpdatedEstimateAfterUpdateInterval() {+ var estimator = DownloadETAEstimator()+ let mib = UInt64(1024 * 1024)+ _ = estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 0, totalBytes: 600 * mib),+ timestamp: 0)+ let first = estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 100 * mib, totalBytes: 600 * mib),+ timestamp: 10)+ let second = estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 200 * mib, totalBytes: 600 * mib),+ timestamp: 40)++ #expect(first == .remaining(seconds: 50))+ #expect(second == .remaining(seconds: 80))+ }++ @Test func steadyDownloadAdvancesVisibleMinuteCountdown() {+ var estimator = DownloadETAEstimator()+ let mib = UInt64(1024 * 1024)+ let total = UInt64(3_640) * mib++ _ = estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 0, totalBytes: total),+ timestamp: 0)+ let presentations = [+ estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 40 * mib, totalBytes: total),+ timestamp: 10),+ estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 280 * mib, totalBytes: total),+ timestamp: 70),+ estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 520 * mib, totalBytes: total),+ timestamp: 130),+ estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 760 * mib, totalBytes: total),+ timestamp: 190),+ ]++ #expect(presentations.compactMap(DownloadETAFormatter.string) == [+ "About 15 min remaining",+ "About 14 min remaining",+ "About 13 min remaining",+ "About 12 min remaining",+ ])+ }++ @Test func byteCounterRegressionRestartsWarmup() {+ var estimator = DownloadETAEstimator()+ let mib = UInt64(1024 * 1024)+ let total = UInt64(600) * mib+ _ = estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 0, totalBytes: total),+ timestamp: 0)+ #expect(estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 40 * mib, totalBytes: total),+ timestamp: 10) != .estimating)++ #expect(estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 10 * mib, totalBytes: total),+ timestamp: 20) == .estimating)+ }++ @Test func completionHidesETA() {+ var estimator = DownloadETAEstimator()+ let mib = UInt64(1024 * 1024)+ _ = estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 0, totalBytes: 40 * mib),+ timestamp: 0)++ #expect(estimator.update(+ .init(reusedBytes: 0, downloadedThisRunBytes: 40 * mib, totalBytes: 40 * mib),+ timestamp: 10) == .hidden)+ }+@Test func formatterUsesCoarseMinuteBuckets() {#expect(DownloadETAFormatter.remainingString(390) == "About 7 min remaining")#expect(DownloadETAFormatter.remainingString(410) == "About 7 min remaining")