Open hyperswine opened 1 year ago
The issue is np.append()
quietly converts the float32 array to float64...
Here's how I managed to run with MPS.
diff --git a/point_e/diffusion/gaussian_diffusion.py b/point_e/diffusion/gaussian_diffusion.py
index 8dc4dc3..15ebfed 100644
--- a/point_e/diffusion/gaussian_diffusion.py
+++ b/point_e/diffusion/gaussian_diffusion.py
@@ -16,7 +16,7 @@ def get_beta_schedule(beta_schedule, *, beta_start, beta_end, num_diffusion_time
See get_named_beta_schedule() for the new library of schedules.
"""
if beta_schedule == "linear":
- betas = np.linspace(beta_start, beta_end, num_diffusion_timesteps, dtype=np.float64)
+ betas = np.linspace(beta_start, beta_end, num_diffusion_timesteps, dtype=np.float32)
else:
raise NotImplementedError(beta_schedule)
assert betas.shape == (num_diffusion_timesteps,)
@@ -68,7 +68,7 @@ def betas_for_alpha_bar(num_diffusion_timesteps, alpha_bar, max_beta=0.999):
t1 = i / num_diffusion_timesteps
t2 = (i + 1) / num_diffusion_timesteps
betas.append(min(1 - alpha_bar(t2) / alpha_bar(t1), max_beta))
- return np.array(betas)
+ return np.array(betas, dtype=np.float32)
def space_timesteps(num_timesteps, section_counts):
@@ -159,8 +159,8 @@ class GaussianDiffusion:
self.channel_scales = channel_scales
self.channel_biases = channel_biases
- # Use float64 for accuracy.
- betas = np.array(betas, dtype=np.float64)
+ # Use float32 for accuracy.
+ betas = np.array(betas, dtype=np.float32)
self.betas = betas
assert len(betas.shape) == 1, "betas must be 1-D"
assert (betas > 0).all() and (betas <= 1).all()
@@ -169,8 +169,8 @@ class GaussianDiffusion:
alphas = 1.0 - betas
self.alphas_cumprod = np.cumprod(alphas, axis=0)
- self.alphas_cumprod_prev = np.append(1.0, self.alphas_cumprod[:-1])
- self.alphas_cumprod_next = np.append(self.alphas_cumprod[1:], 0.0)
+ self.alphas_cumprod_prev = np.append(np.float32(1.0), self.alphas_cumprod[:-1])
+ self.alphas_cumprod_next = np.append(self.alphas_cumprod[1:], np.float32(0.0))
assert self.alphas_cumprod_prev.shape == (self.num_timesteps,)
# calculations for diffusion q(x_t | x_{t-1}) and others
Hello
Im on an M2 apple system version 12.3.1 and Im getting the following error when I try to run
texttopointcloud.ipynb
withdevice = torch.device("mps")
. Ive tried changing some of the float64 (mostly in gaussian it seems) to float32 but to no effect. Im guessing its probably one of the dependencies