mirror of
https://github.com/deepseek-ai/DeepSeek-V3.git
synced 2025-07-05 07:51:38 -04:00
✅ Implemented initial Apple Silicon detection using sysctl system calls ✅ Added proper M1/M2/M3/M4 generation detection via CPU brand string ✅ Fixed memory leaks that occured during dev with proper allocator cleanup ✅ Enhanced Metal backend foundation with device capabilities ✅ Added `test_m_series.zig` for hardware verification 🔧 Key Technical Improvements: - Real hardware detection via `hw.model` (eg; `MacBookPro17,1`) - CPU brand string parsing for accurate M-series identification - Unified memory strategy detection (even under Rosetta) - Apple Neural Engine capability detection - Memory-safe device info structures 🧪 Verified on Apple Silicon: - M1 correctly detected (generation 1, no variant) - 16GB unified memory properly identified - Builds cleanly with Zig `0.15.0-dev.703+597dd328e` - No false positives for M1 Pro/Max/Ultra variants 📋 Updated README status to reflect experimental draft implementation ⚠️ Clearly marked as research/development foundation, not production ready
40 lines
1.5 KiB
Zig
40 lines
1.5 KiB
Zig
// Test program for M series detection
|
|
const std = @import("std");
|
|
const metal_device = @import("backends/metal/device.zig");
|
|
|
|
pub fn main() !void {
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
defer _ = gpa.deinit();
|
|
|
|
const allocator = gpa.allocator();
|
|
|
|
std.log.info("Testing M series detection...", .{});
|
|
|
|
// Detect Apple Silicon and M-series capabilities
|
|
const device_info = try metal_device.detectAppleSilicon(allocator);
|
|
defer {
|
|
allocator.free(device_info.device_name);
|
|
allocator.free(device_info.variant);
|
|
}
|
|
|
|
std.log.info("Device Info:", .{});
|
|
std.log.info(" Device Name: {s}", .{device_info.device_name});
|
|
std.log.info(" Is Apple Silicon: {}", .{device_info.is_apple_silicon});
|
|
std.log.info(" Is M Series: {}", .{device_info.is_m_series});
|
|
|
|
if (device_info.is_m_series) {
|
|
std.log.info(" M Series Generation: {}", .{device_info.series_generation});
|
|
std.log.info(" Variant: {s}", .{device_info.variant});
|
|
}
|
|
|
|
std.log.info(" Unified Memory: {} GB", .{device_info.unified_memory_size / (1024 * 1024 * 1024)});
|
|
std.log.info(" Has Apple Neural Engine: {}", .{device_info.has_anc});
|
|
|
|
// Test other utility functions
|
|
std.log.info("Optimal Work Group Size: {}", .{metal_device.getOptimalWorkGroupSize()});
|
|
std.log.info("Memory Strategy: {s}", .{@tagName(metal_device.getMemoryStrategy())});
|
|
std.log.info("Optimal Tensor Block Size: {}", .{metal_device.getOptimalTensorBlockSize()});
|
|
|
|
std.log.info("Test complete!", .{});
|
|
}
|