From 6b3e974e0b9632a159b179240a2401cfc62fa646 Mon Sep 17 00:00:00 2001 From: Carson Rodrigues Date: Thu, 2 Jul 2026 15:07:09 +0530 Subject: [PATCH] fix: avoid int32 overflow in random seed generation np.random.randint(0, 2**32 - 1) uses numpy's default integer dtype, which is int32 on some platforms (notably Windows). The high bound 2**32 - 1 exceeds int32's max, so numpy raises 'ValueError: high is out of bounds for int32' on every seed=-1 (auto-seed) generation. Line 36 already fixes this with dtype=np.uint32; apply the same fix to the two remaining occurrences (lines 198 and 468). Fixes #195 --- stable_audio_tools/inference/generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stable_audio_tools/inference/generation.py b/stable_audio_tools/inference/generation.py index 6be95d51..9de8c2ce 100644 --- a/stable_audio_tools/inference/generation.py +++ b/stable_audio_tools/inference/generation.py @@ -195,7 +195,7 @@ def generate_diffusion_cond( # Seed # The user can explicitly set the seed to deterministically generate the same output. Otherwise, use a random seed. - seed = seed if seed != -1 else np.random.randint(0, 2**32 - 1) + seed = seed if seed != -1 else np.random.randint(0, 2**32 - 1, dtype=np.uint32) torch.manual_seed(seed) # Define the initial noise immediately after setting the seed noise = torch.randn([batch_size, model.io_channels, latent_sample_size], device=device) @@ -465,7 +465,7 @@ def generate_diffusion_cond_inpaint( # Seed # The user can explicitly set the seed to deterministically generate the same output. Otherwise, use a random seed. - seed = seed if seed != -1 else np.random.randint(0, 2**32 - 1) + seed = seed if seed != -1 else np.random.randint(0, 2**32 - 1, dtype=np.uint32) torch.manual_seed(seed) # Define the initial noise immediately after setting the seed noise = torch.randn([batch_size, model.io_channels, sample_size], device=device)