Initial commit: E4B-MarkBase model integration with passing tests
CI / build-and-test (push) Has been cancelled
CI / build-and-test (push) Has been cancelled
- E4B-MarkBase model (42 layers, 4.4GB) loaded successfully - All Phase 1-6 tests passed (model loading, forward pass, vision/audio towers, token generation, performance) - All stress tests passed (5/5 in 127.6s) - Concurrent inference - Memory stress (67.5 tok/s, 0 NaN) - Continuous generation - Batch processing - Long-running stability - Swift Metal inference engine with multimodal support
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
import Foundation
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Cross-Device Communication Protocol
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
/// Device node in the cluster
|
||||
public struct DeviceNode: Codable, Sendable {
|
||||
public let id: String
|
||||
public let host: String
|
||||
public let port: Int
|
||||
public let capabilities: DeviceCapabilities
|
||||
public var status: DeviceStatus
|
||||
public var load: Double // 0.0 to 1.0
|
||||
|
||||
public init(
|
||||
id: String,
|
||||
host: String,
|
||||
port: Int,
|
||||
capabilities: DeviceCapabilities,
|
||||
status: DeviceStatus = .healthy,
|
||||
load: Double = 0.0
|
||||
) {
|
||||
self.id = id
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.capabilities = capabilities
|
||||
self.status = status
|
||||
self.load = load
|
||||
}
|
||||
|
||||
public var baseURL: String {
|
||||
"http://\(host):\(port)"
|
||||
}
|
||||
}
|
||||
|
||||
/// Device capabilities
|
||||
public struct DeviceCapabilities: Codable, Sendable {
|
||||
public let maxConcurrency: Int
|
||||
public let supportedModels: [String]
|
||||
public let hasGPU: Bool
|
||||
public let memoryGB: Int
|
||||
|
||||
public init(
|
||||
maxConcurrency: Int = 4,
|
||||
supportedModels: [String] = [],
|
||||
hasGPU: Bool = true,
|
||||
memoryGB: Int = 16
|
||||
) {
|
||||
self.maxConcurrency = maxConcurrency
|
||||
self.supportedModels = supportedModels
|
||||
self.hasGPU = hasGPU
|
||||
self.memoryGB = memoryGB
|
||||
}
|
||||
}
|
||||
|
||||
/// Device status
|
||||
public enum DeviceStatus: String, Codable, Sendable {
|
||||
case healthy
|
||||
case degraded
|
||||
case unhealthy
|
||||
case offline
|
||||
}
|
||||
|
||||
/// Cross-device request
|
||||
public struct CrossDeviceRequest: Codable, Sendable {
|
||||
public let id: String
|
||||
public let endpoint: String
|
||||
public let method: String
|
||||
public let body: Data?
|
||||
public let timeout: TimeInterval
|
||||
|
||||
public init(
|
||||
id: String = UUID().uuidString,
|
||||
endpoint: String,
|
||||
method: String = "POST",
|
||||
body: Data? = nil,
|
||||
timeout: TimeInterval = 30
|
||||
) {
|
||||
self.id = id
|
||||
self.endpoint = endpoint
|
||||
self.method = method
|
||||
self.body = body
|
||||
self.timeout = timeout
|
||||
}
|
||||
}
|
||||
|
||||
/// Cross-device response
|
||||
public struct CrossDeviceResponse: Codable, Sendable {
|
||||
public let requestId: String
|
||||
public let statusCode: Int
|
||||
public let body: Data?
|
||||
public let latency: TimeInterval
|
||||
public let nodeId: String
|
||||
|
||||
public init(
|
||||
requestId: String,
|
||||
statusCode: Int,
|
||||
body: Data? = nil,
|
||||
latency: TimeInterval,
|
||||
nodeId: String
|
||||
) {
|
||||
self.requestId = requestId
|
||||
self.statusCode = statusCode
|
||||
self.body = body
|
||||
self.latency = latency
|
||||
self.nodeId = nodeId
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user