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

[BUG]: bfloat16 cast fails #1297

Closed
jon-chuang opened this issue Nov 15, 2023 · 12 comments
Closed

[BUG]: bfloat16 cast fails #1297

jon-chuang opened this issue Nov 15, 2023 · 12 comments
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.

Comments

@jon-chuang
Copy link
Contributor

Bug description

[User] error: Couldn't lookup symbols:
  __truncsfbf2

Steps to reproduce

Repro

from random import rand
let image = rand[DType.float32](10)
a = image.data().simd_load[1]().cast[DType.bfloat16]()

System information

- What OS did you do install Mojo on ? Ubuntu 22.04
- Provide version information for Mojo by pasting the output of `mojo -v` mojo 0.5.0 (6e50a738)
- Provide Modular CLI version by pasting the output of `modular -v` modular 0.2.1 (5144fffe)
@jon-chuang jon-chuang added bug Something isn't working mojo Issues that are related to mojo labels Nov 15, 2023
@jon-chuang jon-chuang changed the title [BUG]: bfloat16 SIMD load fails [BUG]: bfloat16 cast fails Nov 15, 2023
@ematejska ematejska added the mojo-stdlib Tag for issues related to standard library label Nov 15, 2023
@willghatch
Copy link
Contributor

I failed to reproduce this on MacOS. I'll try again later on Ubuntu.

@jon-chuang
Copy link
Contributor Author

__truncsfbf2 is an x86 symbol. Are you using ARM Mac?

@jon-chuang
Copy link
Contributor Author

jon-chuang commented Nov 21, 2023

Possibly related: JuliaLang/julia#52067

My device is an Intel on an ASUS machine.

@Sharktheone
Copy link

Sharktheone commented Nov 21, 2023

I also can't reproduce this. In the repl I get this:

(SIMD[bf16, 1]) a = {
  (scalar<bf16>) value = {
    (bf16) [0] = 1.5068
  }
}
(Tensor[f32]) image = {
  (TensorSpec) _spec = {
    (TensorShape) shape = {
      (_TensorShapeStorage) _rep = {
        (DTypePointer[invalid]) ptr = {
          (pointer<scalar<invalid>>) address = 0x000000000000000a
        }
        (SIMD[si64, 1]) idx = {
          (scalar<si64>) value = {
            (si64) [0] = 4756083780991582208
          }
        }
      }
    }
  }
  (DTypePointer[f32]) _ptr = {
    (pointer<scalar<f32>>) address = 0x000055c49a85f830
  }
}

and when i run it in a file, i also doesn't give me an error.
Note, that i've added let before a

@jon-chuang
Copy link
Contributor Author

I get the error regardless of let

Expressions are delimited by a blank line.
Type `:quit` to exit the REPL and `:mojo help` for further assistance.

  1> from random import rand 
  2. let image = rand[DType.float32](10) 
  3. let a = image.data().simd_load[1]().cast[DType.bfloat16]()
[User] error: Couldn't lookup symbols:
  __truncsfbf2

@jon-chuang
Copy link
Contributor Author

jon-chuang commented Nov 21, 2023

Maybe it's the clang/LLVM version on my machine?

Regardless, it's bad that it happens.

@Sharktheone
Copy link

Hmm, it seems like, you don't have the newest version of modular installed. Can you update it and reinstall mojo? I don't really think that is fixing that, but it was at leased tried then.

@willghatch
Copy link
Contributor

OK, I spun up an Intel Ubuntu VM and was able to reproduce this in the repl but not in a file. We'll look into this.

@willghatch willghatch added mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension. and removed mojo-stdlib Tag for issues related to standard library labels Nov 21, 2023
@Sharktheone
Copy link

Interesting though I couldn't reproduce this. This might be for the same reason it also doesn't fail on MacOS. Might be depending on some CPU features

@jon-chuang
Copy link
Contributor Author

Hmm, weird, when I run on file, it prints nothing.

def main():
    from random import rand
    let image = rand[DType.float32](10)
    let a = image.data().simd_load[1]().cast[DType.bfloat16]()
    print(a, "something")  # prints ' something'

@HJLebbink
Copy link

HJLebbink commented Jan 28, 2024

On mojo 0.7.0 (af002202) I get the same error:

from random import rand

fn main():
    let image = rand[DType.float32](10)
    let a = image.data().simd_load[1]().cast[DType.bfloat16]()
    let b = a.cast[DType.float32]()
    print(str(b))

gives:

JIT session error: Symbols not found: [ __truncsfbf2 ]
mojo: error: Failed to materialize symbols: { (exec, { main }) }

This is on a Intel(R) Xeon(R) w5-2455X

@River707
Copy link
Contributor

This should be fixed in the next release!

@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.
Projects
None yet
Development

No branches or pull requests

6 participants