Where are the random numbers? I like 42 but not always
I know I am probably being stupid, and you are all welcome to tell me I am being stupid or better yet, what I have done wrong.
I cannot seem to get the seed to randomize (-1). I see seed 42 in the terminal output every time. But it will dutifully generate the exact same picture every time I execute a prompt.
Here is the terminal output. Please someone let me know the error of my ways.
Thank you in advance for my education.
Operating System & Version
MacOS 26.5.1 , Server Active|DreamShaperXL_Lightning.safetensors, M1 Pro, Steps:10, Seed: -1
GGML backends
Metal
Command-line arguments used
./mac.sh
Steps to reproduce
give any prompt and you will always get the same generation with the same prompt.
What you expected to happen
Seed to be different every execution and give me a different picture
What actually happened
Seed was set to random but seems to be the same because every generations is the same picture with the same prompt.
Logs / error messages / stack trace
[api] Restart backend request: {
model: 'DreamShaperXL_Lightning.safetensors',
steps: 10,
cfgScale: 1.5,
sampler: 'euler_a',
threads: 5,
use_gpu: true,
backend_type: 'apple-npu',
width: 1024,
height: 1024,
vae_tiling: true,
vae_on_cpu: false,
flash_attn: true
}
[backend] exited with code null
[backend] Starting: sd --listen-port 8080 --model /Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors --steps 10 --cfg-scale 1.5 --sampling-method euler_a --threads 4 --rng cpu --sampler-rng cpu --vae-tiling --fa
[sd-err] ggml_metal_device_init: tensor API disabled for pre-M5 and pre-A19 devices
ggml_metal_library_init: using embedded metal library
[sd-err] ggml_metal_library_init: loaded in 0.027 sec
ggml_metal_rsets_init: creating a residency set collection (keep_alive = 180 s)
[sd-err] ggml_metal_device_init: GPU name: MTL0 (Apple M1 Pro)
ggml_metal_device_init: GPU family: MTLGPUFamilyApple7 (1007)
ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_device_init: GPU family: MTLGPUFamilyMetal4 (5002)
ggml_metal_device_init: simdgroup reduction = true
ggml_metal_device_init: simdgroup matrix mul. = true
ggml_metal_device_init: has unified memory = true
ggml_metal_device_init: has bfloat = true
ggml_metal_device_init: has tensor = false
ggml_metal_device_init: use residency sets = true
ggml_metal_device_init: use shared buffers = true
ggml_metal_device_init: recommendedMaxWorkingSetSize = 12713.12 MB
[sd] [INFO ] ggml_extend.hpp:64 - ggml_metal_init: allocating
[sd] [INFO ] ggml_extend.hpp:64 - ggml_metal_init: found device: Apple M1 Pro
[INFO ] ggml_extend.hpp:64 - ggml_metal_init: picking default device: Apple M1 Pro
[sd] [INFO ] ggml_extend.hpp:64 - ggml_metal_init: use fusion = true
[INFO ] ggml_extend.hpp:64 - ggml_metal_init: use concurrency = true
[INFO ] ggml_extend.hpp:64 - ggml_metal_init: use graph optimize = true
[sd] [INFO ] stable-diffusion.cpp:299 - loading model from '/Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors'
[sd] [INFO ] model_loader.cpp:219 - load /Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors using safetensors format
[sd] [INFO ] stable-diffusion.cpp:416 - Version: SDXL
[sd] [INFO ] stable-diffusion.cpp:444 - Weight type stat: f16: 2515
[INFO ] stable-diffusion.cpp:445 - Conditioner weight type stat: f16: 587
[INFO ] stable-diffusion.cpp:446 - Diffusion model weight type stat: f16: 1680
[INFO ] stable-diffusion.cpp:447 - VAE weight type stat: f16: 248
[sd] [INFO ] stable-diffusion.cpp:865 - using VAE for encoding / decoding
[sd] [INFO ] auto_encoder_kl.hpp:525 - vae decoder: ch = 128
[WARN ] stable-diffusion.cpp:845 - No valid VAE specified with --vae or --force-sdxl-vae-conv-scale flag set, using Conv2D scale 0.031
[INFO ] stable-diffusion.cpp:938 - Using flash attention
[INFO ] stable-diffusion.cpp:952 - Using flash attention in the diffusion model
[sd] [INFO ] model_loader.cpp:817 - NOT using mmap for '/Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors' (mmap disabled by caller)
[INFO ] model_loader.cpp:828 - model files processing completed in 0.00s
[sd] [INFO ] model_loader.cpp:1199 - unknown tensor 'cond_stage_model.text_projection | f16 | 2 [768, 768, 1, 1, 1]' in model file
[INFO ] model_loader.cpp:1199 - unknown tensor 'cond_stage_model.logit_scale | f16 | 1 [1, 1, 1, 1, 1]' in model file
|=> | 68/2515 - 254.60MB/s [sd |==> | 133/2515 - 251.57MB/s [s |===> | 194/2515 - 246.48MB/s [s |====> | 225/2515 - 322.82MB/s [s |====> | 244/2515 - 341.37MB/s [s |=====> | 267/2515 - 337.86MB/s [s |=====> | 289/2515 - 341.92MB/s [s |======> | 311/2515 - 331.57MB/s [s |======> | 333/2515 - 329.16MB/s [s |=======> | 357/2515 - 333.70MB/s [s |=======> | 383/2515 - 346.43MB/s [s |========> | 407/2515 - 348.09MB/s [s |========> | 431/2515 - 349.49MB/s [s |=========> | 453/2515 - 343.02MB/s [s |=========> | 472/2515 - 347.52MB/s [s |=========> | 491/2515 - 337.30MB/s [s |==========> | 515/2515 - 339.01MB/s [s |==========> | 540/2515 - 343.93MB/s [s |===========> | 564/2515 - 345.19MB/s [s |===========> | 587/2515 - 343.18MB/s [s |=============> | 685/2515 - 343.88MB/s [s |===============> | 763/2515 - 342.19MB/s [s |=================> | 856/2515 - 367.04MB/s [s |==================> | 940/2515 - 364.70MB/s [s |===================> | 994/2515 - 362.59MB/s [s |====================> | 1017/2515 - 363.13MB/s [ |====================> | 1041/2515 - 363.36MB/s [ |=====================> | 1059/2515 - 363.02MB/s [ |=====================> | 1085/2515 - 362.49MB/s [ |=====================> | 1104/2515 - 366.21MB/s [ |======================> | 1128/2515 - 366.34MB/s [ |======================> | 1155/2515 - 365.76MB/s [ |=======================> | 1178/2515 - 365.51MB/s [ |=======================> | 1199/2515 - 360.21MB/s [ |========================> | 1215/2515 - 360.38MB/s [ |========================> | 1238/2515 - 360.45MB/s [ |=========================> | 1261/2515 - 360.52MB/s [ |=========================> | 1281/2515 - 359.54MB/s [ |=========================> | 1301/2515 - 358.84MB/s [ |==========================> | 1322/2515 - 361.14MB/s [ |==========================> | 1344/2515 - 363.20MB/s [ |===========================> | 1373/2515 - 364.16MB/s [ |===========================> | 1395/2515 - 361.51MB/s [ |============================> | 1420/2515 - 363.49MB/s [ |============================> | 1438/2515 - 367.29MB/s [ |=============================> | 1463/2515 - 365.28MB/s [ |=============================> | 1484/2515 - 367.03MB/s [ |==============================> | 1512/2515 - 364.40MB/s [ |==============================> | 1530/2515 - 363.24MB/s [ |==============================> | 1553/2515 - 363.05MB/s [ |===============================> | 1575/2515 - 363.01MB/s [ |===============================> | 1598/2515 - 363.01MB/s [ |================================> | 1621/2515 - 363.01MB/s [ |================================> | 1639/2515 - 362.50MB/s [ |================================> | 1650/2515 - 360.90MB/s [ |=================================> | 1673/2515 - 365.08MB/s [ |=================================> | 1695/2515 - 365.42MB/s [ |==================================> | 1722/2515 - 366.80MB/s [ |==================================> | 1745/2515 - 366.74MB/s [ |===================================> | 1766/2515 - 365.31MB/s [ |===================================> | 1791/2515 - 365.02MB/s [ |====================================> | 1811/2515 - 364.43MB/s [ |====================================> | 1833/2515 - 364.28MB/s [ |====================================> | 1853/2515 - 363.64MB/s [ |=====================================> | 1882/2515 - 365.17MB/s [ |=====================================> | 1902/2515 - 364.67MB/s [ |======================================> | 1924/2515 - 364.51MB/s [ |======================================> | 1948/2515 - 364.71MB/s [ |=======================================> | 1970/2515 - 366.08MB/s [ |=======================================> | 1992/2515 - 365.95MB/s [ |========================================> | 2013/2515 - 365.34MB/s [ |========================================> | 2031/2515 - 363.13MB/s [ |========================================> | 2051/2515 - 362.58MB/s [ |=========================================> | 2073/2515 - 363.71MB/s [ |=========================================> | 2089/2515 - 362.62MB/s [ |=========================================> | 2111/2515 - 363.81MB/s [ |==========================================> | 2138/2515 - 364.08MB/s [ |==========================================> | 2162/2515 - 364.14MB/s [ |===========================================> | 2185/2515 - 364.15MB/s [ |===========================================> | 2205/2515 - 363.73MB/s [ |============================================> | 2226/2515 - 366.23MB/s [ |============================================> | 2246/2515 - 364.53MB/s [ |============================================> | 2263/2515 - 366.71MB/s [ |=============================================> | 2290/2515 - 367.24MB/s [ |=============================================> | 2310/2515 - 366.67MB/s [ |===============================================> | 2368/2515 - 366.08MB/s [ |================================================> | 2434/2515 - 367.77MB/s [ |==================================================| 2511/2515 - 367.98MB/s [ |==================================================| 2515/2515 - 364.43MB/s
[sd] [INFO ] model_loader.cpp:1172 - loading tensors completed, taking 18.16s (read: 17.82s, memcpy: 0.00s, convert: 0.00s, copy_to_backend: 0.11s)
[sd] [INFO ] stable-diffusion.cpp:1173 - total params memory size = 6624.11MB (VRAM 6624.11MB, RAM 0.00MB): text_encoders 1564.36MB(VRAM), diffusion_model 4900.07MB(VRAM), vae 159.68MB(VRAM), controlnet 0.00MB(N/A), extensions 0.00MB(N/A)
[INFO ] stable-diffusion.cpp:1248 - running in eps-prediction mode
[sd] [INFO ] main.cpp:148 - listening on: http://127.0.0.1:8080
[backend] READY on port 8080
[sd] [INFO ] stable-diffusion.cpp:4416 - generate_image 1024x1024
[INFO ] denoiser.hpp:579 - get_sigmas with discrete scheduler
[INFO ] stable-diffusion.cpp:3470 - sampling using Euler A method
[sd] [INFO ] stable-diffusion.cpp:4173 - get_learned_condition completed, taking 0.28s
[INFO ] stable-diffusion.cpp:4450 - generating image: 1/1 - seed 42
|==================================================| 10/10 - 6.95s/it
[sd] [INFO ] stable-diffusion.cpp:4482 - sampling completed, taking 69.48s
[INFO ] stable-diffusion.cpp:4502 - generating 1 latent images completed, taking 69.48s
[sd] [INFO ] stable-diffusion.cpp:4194 - decoding 1 latents
|==================================================| 49/49 - 1.03it/s
[sd] [INFO ] stable-diffusion.cpp:4210 - latent 1 decoded, taking 47.49s
[INFO ] stable-diffusion.cpp:4214 - decode_first_stage completed, taking 47.49s
[sd] [INFO ] stable-diffusion.cpp:4634 - generate_image completed in 117.27s
[api] Saved generated output: output-2026-06-23T20-57-48-817Z-400553.png
Additional context / environment details
No response
Where are the random numbers? I like 42 but not always
I know I am probably being stupid, and you are all welcome to tell me I am being stupid or better yet, what I have done wrong.
I cannot seem to get the seed to randomize (-1). I see seed 42 in the terminal output every time. But it will dutifully generate the exact same picture every time I execute a prompt.
Here is the terminal output. Please someone let me know the error of my ways.
Thank you in advance for my education.
Operating System & Version
MacOS 26.5.1 , Server Active|DreamShaperXL_Lightning.safetensors, M1 Pro, Steps:10, Seed: -1
GGML backends
Metal
Command-line arguments used
./mac.sh
Steps to reproduce
give any prompt and you will always get the same generation with the same prompt.
What you expected to happen
Seed to be different every execution and give me a different picture
What actually happened
Seed was set to random but seems to be the same because every generations is the same picture with the same prompt.
Logs / error messages / stack trace
[api] Restart backend request: {
model: 'DreamShaperXL_Lightning.safetensors',
steps: 10,
cfgScale: 1.5,
sampler: 'euler_a',
threads: 5,
use_gpu: true,
backend_type: 'apple-npu',
width: 1024,
height: 1024,
vae_tiling: true,
vae_on_cpu: false,
flash_attn: true
}
[backend] exited with code null
[backend] Starting: sd --listen-port 8080 --model /Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors --steps 10 --cfg-scale 1.5 --sampling-method euler_a --threads 4 --rng cpu --sampler-rng cpu --vae-tiling --fa
[sd-err] ggml_metal_device_init: tensor API disabled for pre-M5 and pre-A19 devices
ggml_metal_library_init: using embedded metal library
[sd-err] ggml_metal_library_init: loaded in 0.027 sec
ggml_metal_rsets_init: creating a residency set collection (keep_alive = 180 s)
[sd-err] ggml_metal_device_init: GPU name: MTL0 (Apple M1 Pro)
ggml_metal_device_init: GPU family: MTLGPUFamilyApple7 (1007)
ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_device_init: GPU family: MTLGPUFamilyMetal4 (5002)
ggml_metal_device_init: simdgroup reduction = true
ggml_metal_device_init: simdgroup matrix mul. = true
ggml_metal_device_init: has unified memory = true
ggml_metal_device_init: has bfloat = true
ggml_metal_device_init: has tensor = false
ggml_metal_device_init: use residency sets = true
ggml_metal_device_init: use shared buffers = true
ggml_metal_device_init: recommendedMaxWorkingSetSize = 12713.12 MB
[sd] [INFO ] ggml_extend.hpp:64 - ggml_metal_init: allocating
[sd] [INFO ] ggml_extend.hpp:64 - ggml_metal_init: found device: Apple M1 Pro
[INFO ] ggml_extend.hpp:64 - ggml_metal_init: picking default device: Apple M1 Pro
[sd] [INFO ] ggml_extend.hpp:64 - ggml_metal_init: use fusion = true
[INFO ] ggml_extend.hpp:64 - ggml_metal_init: use concurrency = true
[INFO ] ggml_extend.hpp:64 - ggml_metal_init: use graph optimize = true
[sd] [INFO ] stable-diffusion.cpp:299 - loading model from '/Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors'
[sd] [INFO ] model_loader.cpp:219 - load /Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors using safetensors format
[sd] [INFO ] stable-diffusion.cpp:416 - Version: SDXL
[sd] [INFO ] stable-diffusion.cpp:444 - Weight type stat: f16: 2515
[INFO ] stable-diffusion.cpp:445 - Conditioner weight type stat: f16: 587
[INFO ] stable-diffusion.cpp:446 - Diffusion model weight type stat: f16: 1680
[INFO ] stable-diffusion.cpp:447 - VAE weight type stat: f16: 248
[sd] [INFO ] stable-diffusion.cpp:865 - using VAE for encoding / decoding
[sd] [INFO ] auto_encoder_kl.hpp:525 - vae decoder: ch = 128
[WARN ] stable-diffusion.cpp:845 - No valid VAE specified with --vae or --force-sdxl-vae-conv-scale flag set, using Conv2D scale 0.031
[INFO ] stable-diffusion.cpp:938 - Using flash attention
[INFO ] stable-diffusion.cpp:952 - Using flash attention in the diffusion model
[sd] [INFO ] model_loader.cpp:817 - NOT using mmap for '/Volumes/SSK Drive/Portable-Diffusion-main/app/models/DreamShaperXL_Lightning.safetensors' (mmap disabled by caller)
[INFO ] model_loader.cpp:828 - model files processing completed in 0.00s
[sd] [INFO ] model_loader.cpp:1199 - unknown tensor 'cond_stage_model.text_projection | f16 | 2 [768, 768, 1, 1, 1]' in model file
[INFO ] model_loader.cpp:1199 - unknown tensor 'cond_stage_model.logit_scale | f16 | 1 [1, 1, 1, 1, 1]' in model file
|=> | 68/2515 - 254.60MB/s [sd |==> | 133/2515 - 251.57MB/s [s |===> | 194/2515 - 246.48MB/s [s |====> | 225/2515 - 322.82MB/s [s |====> | 244/2515 - 341.37MB/s [s |=====> | 267/2515 - 337.86MB/s [s |=====> | 289/2515 - 341.92MB/s [s |======> | 311/2515 - 331.57MB/s [s |======> | 333/2515 - 329.16MB/s [s |=======> | 357/2515 - 333.70MB/s [s |=======> | 383/2515 - 346.43MB/s [s |========> | 407/2515 - 348.09MB/s [s |========> | 431/2515 - 349.49MB/s [s |=========> | 453/2515 - 343.02MB/s [s |=========> | 472/2515 - 347.52MB/s [s |=========> | 491/2515 - 337.30MB/s [s |==========> | 515/2515 - 339.01MB/s [s |==========> | 540/2515 - 343.93MB/s [s |===========> | 564/2515 - 345.19MB/s [s |===========> | 587/2515 - 343.18MB/s [s |=============> | 685/2515 - 343.88MB/s [s |===============> | 763/2515 - 342.19MB/s [s |=================> | 856/2515 - 367.04MB/s [s |==================> | 940/2515 - 364.70MB/s [s |===================> | 994/2515 - 362.59MB/s [s |====================> | 1017/2515 - 363.13MB/s [ |====================> | 1041/2515 - 363.36MB/s [ |=====================> | 1059/2515 - 363.02MB/s [ |=====================> | 1085/2515 - 362.49MB/s [ |=====================> | 1104/2515 - 366.21MB/s [ |======================> | 1128/2515 - 366.34MB/s [ |======================> | 1155/2515 - 365.76MB/s [ |=======================> | 1178/2515 - 365.51MB/s [ |=======================> | 1199/2515 - 360.21MB/s [ |========================> | 1215/2515 - 360.38MB/s [ |========================> | 1238/2515 - 360.45MB/s [ |=========================> | 1261/2515 - 360.52MB/s [ |=========================> | 1281/2515 - 359.54MB/s [ |=========================> | 1301/2515 - 358.84MB/s [ |==========================> | 1322/2515 - 361.14MB/s [ |==========================> | 1344/2515 - 363.20MB/s [ |===========================> | 1373/2515 - 364.16MB/s [ |===========================> | 1395/2515 - 361.51MB/s [ |============================> | 1420/2515 - 363.49MB/s [ |============================> | 1438/2515 - 367.29MB/s [ |=============================> | 1463/2515 - 365.28MB/s [ |=============================> | 1484/2515 - 367.03MB/s [ |==============================> | 1512/2515 - 364.40MB/s [ |==============================> | 1530/2515 - 363.24MB/s [ |==============================> | 1553/2515 - 363.05MB/s [ |===============================> | 1575/2515 - 363.01MB/s [ |===============================> | 1598/2515 - 363.01MB/s [ |================================> | 1621/2515 - 363.01MB/s [ |================================> | 1639/2515 - 362.50MB/s [ |================================> | 1650/2515 - 360.90MB/s [ |=================================> | 1673/2515 - 365.08MB/s [ |=================================> | 1695/2515 - 365.42MB/s [ |==================================> | 1722/2515 - 366.80MB/s [ |==================================> | 1745/2515 - 366.74MB/s [ |===================================> | 1766/2515 - 365.31MB/s [ |===================================> | 1791/2515 - 365.02MB/s [ |====================================> | 1811/2515 - 364.43MB/s [ |====================================> | 1833/2515 - 364.28MB/s [ |====================================> | 1853/2515 - 363.64MB/s [ |=====================================> | 1882/2515 - 365.17MB/s [ |=====================================> | 1902/2515 - 364.67MB/s [ |======================================> | 1924/2515 - 364.51MB/s [ |======================================> | 1948/2515 - 364.71MB/s [ |=======================================> | 1970/2515 - 366.08MB/s [ |=======================================> | 1992/2515 - 365.95MB/s [ |========================================> | 2013/2515 - 365.34MB/s [ |========================================> | 2031/2515 - 363.13MB/s [ |========================================> | 2051/2515 - 362.58MB/s [ |=========================================> | 2073/2515 - 363.71MB/s [ |=========================================> | 2089/2515 - 362.62MB/s [ |=========================================> | 2111/2515 - 363.81MB/s [ |==========================================> | 2138/2515 - 364.08MB/s [ |==========================================> | 2162/2515 - 364.14MB/s [ |===========================================> | 2185/2515 - 364.15MB/s [ |===========================================> | 2205/2515 - 363.73MB/s [ |============================================> | 2226/2515 - 366.23MB/s [ |============================================> | 2246/2515 - 364.53MB/s [ |============================================> | 2263/2515 - 366.71MB/s [ |=============================================> | 2290/2515 - 367.24MB/s [ |=============================================> | 2310/2515 - 366.67MB/s [ |===============================================> | 2368/2515 - 366.08MB/s [ |================================================> | 2434/2515 - 367.77MB/s [ |==================================================| 2511/2515 - 367.98MB/s [ |==================================================| 2515/2515 - 364.43MB/s
[sd] [INFO ] model_loader.cpp:1172 - loading tensors completed, taking 18.16s (read: 17.82s, memcpy: 0.00s, convert: 0.00s, copy_to_backend: 0.11s)
[sd] [INFO ] stable-diffusion.cpp:1173 - total params memory size = 6624.11MB (VRAM 6624.11MB, RAM 0.00MB): text_encoders 1564.36MB(VRAM), diffusion_model 4900.07MB(VRAM), vae 159.68MB(VRAM), controlnet 0.00MB(N/A), extensions 0.00MB(N/A)
[INFO ] stable-diffusion.cpp:1248 - running in eps-prediction mode
[sd] [INFO ] main.cpp:148 - listening on: http://127.0.0.1:8080
[backend] READY on port 8080
[sd] [INFO ] stable-diffusion.cpp:4416 - generate_image 1024x1024
[INFO ] denoiser.hpp:579 - get_sigmas with discrete scheduler
[INFO ] stable-diffusion.cpp:3470 - sampling using Euler A method
[sd] [INFO ] stable-diffusion.cpp:4173 - get_learned_condition completed, taking 0.28s
[INFO ] stable-diffusion.cpp:4450 - generating image: 1/1 - seed 42
|==================================================| 10/10 - 6.95s/it
[sd] [INFO ] stable-diffusion.cpp:4482 - sampling completed, taking 69.48s
[INFO ] stable-diffusion.cpp:4502 - generating 1 latent images completed, taking 69.48s
[sd] [INFO ] stable-diffusion.cpp:4194 - decoding 1 latents
|==================================================| 49/49 - 1.03it/s
[sd] [INFO ] stable-diffusion.cpp:4210 - latent 1 decoded, taking 47.49s
[INFO ] stable-diffusion.cpp:4214 - decode_first_stage completed, taking 47.49s
[sd] [INFO ] stable-diffusion.cpp:4634 - generate_image completed in 117.27s
[api] Saved generated output: output-2026-06-23T20-57-48-817Z-400553.png
Additional context / environment details
No response