#5885·burn

Device::enumerate(DeviceType::Metal/Vulkan/WebGpu) and BURN_DEVICE don't pin the graphics API

Author: antimoraCreated Sep 28, 2026Updated Oct 1, 2026
Labelsbugwgpu

Device::enumerate(DeviceType::Metal) (and Vulkan, WebGpu) returns the same wgpu devices as DeviceType::Wgpu, with the graphics API left to auto-selection rather than pinned. The docs on Device::metal say "the same adapter on two APIs is two devices", and Device::metal(kind) does pin WgpuBackend::Metal, so enumerate is inconsistent with the constructors.

  • crates/burn-tensor/src/device.rs:998: DeviceType::Metal => push_cube(&mut devices, RuntimeId::Wgpu)
  • crates/burn-dispatch/src/device.rs:268: BURN_DEVICE=metal|vulkan|webgpu all map to CubeDevice::Wgpu(Default::default()), which is also unpinned.

On a Mac, auto-selection lands on Metal anyway, so this is mostly visible on hosts with more than one API (e.g. Vulkan and GL on Linux, or a build with both metal and vulkan). There, Device::enumerate(DeviceType::Vulkan) can hand back devices that end up on another API. DeviceType::Metal | DeviceType::Vulkan also collapses to a single list.

Suggested: map each pinned DeviceType (and the BURN_DEVICE names) to wgpu devices with .on(WgpuBackend::X), as Device::metal/vulkan/webgpu already do.