Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metal.rand with Int8 and Int16 are only generating positive numbers #526

Open
christiangnrd opened this issue Mar 30, 2024 · 2 comments
Open
Labels

Comments

@christiangnrd
Copy link
Contributor

On main branch. Noticed while working on JuliaGPU/Metal.jl#321. Will still be relevant once JuliaGPU/Metal.jl#321 is merged as the MPSMatrixRandom generation is not always used. Unsigned integers and 32/64 bit variants seem unaffected.

Histograms:
Int8metalrng

Int16metalrng

Code:

using Metal, Plots, Random, Statistics

N=100000;

T = Int16;
a = rand(T, N);

ma = Metal.rand(T,N)

meana = mean(a)
meanma = mean(ma)

hist = plot()
histogram!(a;label="Array{$T}: $(mean(a))",α=0.2)
histogram!(hist, collect(ma);label="MtlArray{$T}: $(meanma)",α=0.2)
@christiangnrd christiangnrd changed the title Int8 and Int16 RNG are only generating positive numbers Metal.rand with Int8 and Int16 are only generating positive numbers Mar 30, 2024
@maleadt
Copy link
Member

maleadt commented Mar 30, 2024

Will still be relevant once JuliaGPU/Metal.jl#321 is merged as the MPSMatrixRandom generation is not always used.

So this is a bug with the GPUArrays RNG?

@christiangnrd
Copy link
Contributor Author

I initially posted it here because I hadn't checked if it also happened with JLArrays yet but it does so yes this is a bug with GPUArrays RNG and this issue should probably be transferred.

@maleadt maleadt transferred this issue from JuliaGPU/Metal.jl Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants