ac75faa0cc
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
55 lines
2.8 KiB
Swift
55 lines
2.8 KiB
Swift
import XCTest
|
|
@testable import MarkBase
|
|
|
|
final class VisionQuickTest: XCTestCase {
|
|
|
|
func test12BVisionQuickLoad() throws {
|
|
print("\n═══════════════════════════════════════")
|
|
print(" 12B Vision QUICK Load Test")
|
|
print("═══════════════════════════════════════\n")
|
|
|
|
let modelDir = "/Users/accusys/.cache/huggingface/hub/models--mlx-community--gemma-4-12B-it-4bit/snapshots/73bcf09092aa277861d5a191b989b666f7f32e8f"
|
|
|
|
print("Step 1: Create engine...")
|
|
let engine = try MarkBaseEngine(autoCompile: true)
|
|
print(" ✓ Engine created")
|
|
|
|
print("\nStep 2: Load VisionTower12B...")
|
|
let loadStart = Date()
|
|
let visionTower = try VisionTower12B.load(modelDir: modelDir, engine: engine)
|
|
let loadTime = Date().timeIntervalSince(loadStart) * 1000
|
|
|
|
print(" ✓ Vision tower loaded in \(loadTime) ms")
|
|
print(" Config: hiddenDim=\(visionTower.hiddenDim), patchDim=\(visionTower.patchDim)")
|
|
|
|
print("\nStep 3: Generate synthetic patches...")
|
|
let numPatches = 256
|
|
var patches: [Float] = []
|
|
for _ in 0..<numPatches * visionTower.patchDim {
|
|
patches.append(Float.random(in: -0.5...0.5))
|
|
}
|
|
|
|
print("\nStep 4: Process vision forward pass...")
|
|
let patchBuffer = engine.device.makeBuffer(bytes: patches, length: patches.count * 4)!
|
|
let outputBuffer = engine.device.makeBuffer(length: numPatches * visionTower.outputDim * 4)!
|
|
|
|
let forwardStart = Date()
|
|
try visionTower.forward(patchEmbeddings: patchBuffer, numPatches: numPatches, outputBuffer: outputBuffer)
|
|
let forwardTime = Date().timeIntervalSince(forwardStart) * 1000
|
|
|
|
let ptr = outputBuffer.contents().assumingMemoryBound(to: Float.self)
|
|
let output = Array(UnsafeBufferPointer(start: ptr, count: numPatches * visionTower.outputDim))
|
|
|
|
print(" ✓ Forward pass completed in \(forwardTime) ms")
|
|
print(" Output shape: [\(numPatches), \(visionTower.outputDim)]")
|
|
print(" Range: [\(output.min() ?? 0), \(output.max() ?? 0)]")
|
|
print(" NaN count: \(output.filter { $0.isNaN }.count)")
|
|
|
|
XCTAssertFalse(output.contains { $0.isNaN }, "Vision output should not have NaN")
|
|
|
|
print("\n═══════════════════════════════════════")
|
|
print("✓ Full vision test passed - no TEXT model")
|
|
print(" Load: \(loadTime) ms, Forward: \(forwardTime) ms")
|
|
print("═══════════════════════════════════════\n")
|
|
}
|
|
} |