issue on macos with stochastic_samples and torch_compile

#5
by facehuggerpandora - opened

Issue 1: Using stocashtic sampler like euler_ancestral give an error

[ERROR] !!! Exception during processing !!! Attempted to set the storage of a tensor on device "cpu" to a storage on different device "mps:0". This is no longer allowed; the devices must match.

Gemini Hydrogen suggests the issue is in brownian.py around line 45 and to change _to_device as follows

def _to_device(host: Tensor, device: torch.device) -> Tensor:
    """Copy a host tensor to ``device`` through pinned memory without a sync."""

    if device.type == "cpu":
        return host
    if device.type == "mps":
        return host.to(device=device)
    return host.pin_memory().to(device=device, non_blocking=True)

Applying this makes stochastic samplers work too

Issue 2: Putting the compile flag to on gives error

with program_source:1:10: fatal error: 'c10/metal/reduction_utils.h' file not found
#include <c10/metal/reduction_utils.h>

However, this might be due to way comfy installation by comfy desktop.

System Details:
Apple M1 Pro , 16 GB, ComfyUI v0.46.4

I can't reproduce, I suspect your pytorch version is old, can you try updating your venv and show which version you have installed ?

I can see it now, it's a pytorch 2.10 issue. It's not only broken on mac but much slower when it does work, please upgrade to 2.14 or above.
I will change the package requirements to reflect this on mac.

Indeed after updating to pytorch v2.15.1 the compile flag works. It also feels significantly faster than before.

facehuggerpandora changed discussion status to closed

Sign up or log in to comment