Open
Description
I'm running candle with metal acceleration on iOS via uniffi, specifically:
candle-core = { version = "0.6.0", features = ["metal"] }
candle-nn = { version = "0.6.0", features = ["metal"] }
candle-transformers = { version = "0.6.0", features = ["metal"] }
But the call to Device::new_metal
panics with:
-[MTLDebugDevice newBufferWithBytes:length:options:]:670: failed assertion `Buffer Validation
Illegal MTLStorageMode 0x10'
After some debugging, I figured this happens on this line due to iOS rejecting the metal::MTLResourceOptions::StorageModeManaged
option.
I could replicate with this simple test:
#[uniffi::export]
pub fn test_metal() {
let device = metal::Device::all().swap_remove(0);
println!("device: {:?}", &device);
println!(
"MTLResourceOptions::StorageModeManaged = 0x{:x}",
metal::MTLResourceOptions::StorageModeManaged
);
// it panics here
let seed = device.new_buffer_with_data(
[299792458].as_ptr() as *const std::ffi::c_void,
4,
metal::MTLResourceOptions::StorageModeManaged, // <-- 0x10
);
println!("seed: {:?}", &seed);
}
Which prints and then panics:
device: <CaptureMTLDevice: 0x105207820> -> <MTLDebugDevice: 0x105207580> -> <AGXG16Device: 0x10800f400>
name = Apple A17 Pro GPU
MTLResourceOptions::StorageModeManaged = 0x10
-[MTLDebugDevice newBufferWithBytes:length:options:]:670: failed assertion `Buffer Validation
Illegal MTLStorageMode 0x10
'
Other values such as StorageModeShared do not panic, but i'm not sure of the implications also because StorageModeManaged is used in several other places in the metal implementation.
Metadata
Metadata
Assignees
Labels
No labels