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

Improve error message when assigning real valued arrray with complex numbers #2341

Closed
roflmaostc opened this issue Apr 24, 2024 · 4 comments · Fixed by #2342
Closed

Improve error message when assigning real valued arrray with complex numbers #2341

roflmaostc opened this issue Apr 24, 2024 · 4 comments · Fixed by #2342

Comments

@roflmaostc
Copy link

Hi,

I noticed a very long and cryptic error message when I assign a Float32 array accidentally with an ComplexF32 value.

Is there a way to improve this?

julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × AMD Ryzen 9 5900X 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 24 default, 0 interactive, 12 GC (on 24 virtual cores)
Environment:
  JULIA_NUM_THREADS = 24

julia> CUDA.versioninfo()
CUDA runtime 12.4, artifact installation
CUDA driver 12.3
NVIDIA driver 545.23.8

CUDA libraries: 
- CUBLAS: 12.4.5
- CURAND: 10.3.5
- CUFFT: 11.2.1
- CUSOLVER: 11.6.1
- CUSPARSE: 12.3.1
- CUPTI: 22.0.0
- NVML: 12.0.0+545.23.8

Julia packages: 
- CUDA: 5.3.1
- CUDA_Driver_jll: 0.8.1+0
- CUDA_Runtime_jll: 0.12.1+0

Toolchain:
- Julia: 1.10.2
- LLVM: 15.0.7

1 device:
  0: NVIDIA GeForce RTX 3060 (sm_86, 8.138 GiB / 12.000 GiB available)
julia> x = rand(Float32, (10, 10))
10×10 Matrix{Float32}:
 0.00328857  0.357522   0.0818348   0.102852  0.912454   0.452064  0.785831  0.147913   0.637831   0.407046
 0.557196    0.406706   0.028018    0.915695  0.446944   0.184308  0.696019  0.641845   0.304365   0.745085
 0.299489    0.793863   0.226263    0.510958  0.351323   0.240982  0.936578  0.842835   0.789428   0.898463
 0.326403    0.0598818  0.561888    0.677146  0.331864   0.440977  0.890306  0.517638   0.645377   0.194501
 0.606426    0.969695   0.759343    0.693912  0.198744   0.263738  0.12469   0.441537   0.140016   0.000547588
 0.86417     0.737195   0.76853     0.252425  0.179289   0.482488  0.826532  0.0224549  0.891973   0.265956
 0.967191    0.23247    0.573174    0.561133  0.0208539  0.269013  0.657235  0.516238   0.360146   0.196037
 0.0525723   0.047767   0.00900018  0.693833  0.78264    0.439466  0.501658  0.465648   0.0283145  0.65083
 0.160489    0.01436    0.0113246   0.485876  0.766822   0.876929  0.970498  0.645838   0.0815061  0.00777107
 0.400186    0.296255   0.394792    0.381996  0.980746   0.476684  0.400207  0.174118   0.734479   0.484299

julia> x .= cis.(x)
ERROR: InexactError: Float32(0.9999946f0 + 0.0032885612f0im)
Stacktrace:
  [1] Real
    @ ./complex.jl:44 [inlined]
  [2] convert
    @ ./number.jl:7 [inlined]
  [3] setindex!
    @ ./array.jl:1024 [inlined]
  [4] setindex!
    @ ./multidimensional.jl:698 [inlined]
  [5] macro expansion
    @ ./broadcast.jl:1004 [inlined]
  [6] macro expansion
    @ ./simdloop.jl:77 [inlined]
  [7] copyto!
    @ ./broadcast.jl:1003 [inlined]
  [8] copyto!
    @ ./broadcast.jl:956 [inlined]
  [9] materialize!
    @ ./broadcast.jl:914 [inlined]
 [10] materialize!(dest::Matrix{Float32}, bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(cis), Tuple{Matrix{Float32}}})
    @ Base.Broadcast ./broadcast.jl:911
 [11] top-level scope
    @ REPL[11]:1
 [12] top-level scope
    @ ~/.julia/packages/CUDA/02Uw6/src/initialization.jl:206

julia> xc = CuArray(x);

julia> xc .= cis.(xc)
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: a exception was thrown during kernel execution.
For stacktrace reporting, run Julia on debug level 2 (by passing -g2 to the executable).
ERROR: KernelException: exception thrown during kernel execution on device NVIDIA GeForce RTX 3060
Stacktrace:
 [1] check_exceptions()
   @ CUDA ~/.julia/packages/CUDA/02Uw6/src/compiler/exceptions.jl:34
 [2] device_synchronize(; blocking::Bool, spin::Bool)
   @ CUDA ~/.julia/packages/CUDA/02Uw6/lib/cudadrv/synchronization.jl:191
 [3] device_synchronize
   @ ~/.julia/packages/CUDA/02Uw6/lib/cudadrv/synchronization.jl:180 [inlined]
 [4] maybe_synchronize_cuda()
   @ CUDA ~/.julia/packages/CUDA/02Uw6/src/initialization.jl:217
 [5] top-level scope
   @ ~/.julia/packages/CUDA/02Uw6/src/initialization.jl:208
@roflmaostc roflmaostc added the bug Something isn't working label Apr 24, 2024
@maleadt
Copy link
Member

maleadt commented Apr 24, 2024

Not really. This is exactly the same error message, just being rendered from the GPU. If you do what the error message suggests, running with -g2, you would see a similar stack trace:

ERROR: a exception was thrown during kernel execution.
Stacktrace:
 [1] Real at ./complex.jl:44
 [2] convert at ./number.jl:7
 [3] setindex! at /home/tim/Julia/pkg/CUDA/src/device/array.jl:166
 [4] setindex! at /home/tim/Julia/pkg/CUDA/src/device/array.jl:178
 [5] #35 at /home/tim/.julia/packages/GPUArrays/OKkAu/src/host/broadcast.jl:70

The only thing different here is that this is rendered as a plain Exception, which isn't easy to fix, and the fact that every thread reports an exception, which has already been reported in #1780. So I think we can close that in favour of the existing issue.

@maleadt maleadt closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
@maleadt maleadt removed the bug Something isn't working label Apr 24, 2024
@maleadt
Copy link
Member

maleadt commented Apr 24, 2024

And FWIW, it's not possible to detect and special case this before launching a GPU kernel, because the InexactError depends on the actual data:

julia> x .= 1+1im
ERROR: InexactError: Float32(1 + 1im)

julia> x .= 1+0im
1×1 Matrix{Float32}:
 1.0

@maleadt maleadt reopened this Apr 24, 2024
@maleadt
Copy link
Member

maleadt commented Apr 24, 2024

The only thing different here is that this is rendered as a plain Exception, which isn't easy to fix

I did the hard thing and improved reporting in #2342

@roflmaostc
Copy link
Author

Cool thanks!
I give it a shot later

@maleadt maleadt linked a pull request Apr 25, 2024 that will close this issue
@maleadt maleadt closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants