Modular

M

Modular

This server is the home of the MAX and Mojo community. Join us to chat about all things Modular!

Join

questions

community-showcase

Type independent traits

Any ways to make the example code work? Would be nice to be able to implement custom traits for abstract classes ```typescript trait Container: fn contains(self, item: AnyType) -> Bool:...

MODULAR_AUTH key not found

why my MODULAR_AUTH key was gone in mojo install page?
No description

Mojo Dict: Store struct instances based on a common trait as CollectionElement.

I'm trying to use a Mojo Dict to store different instances of structs which conform to a common trait. I've created a 'playground' file to work out a solution, but I am stumped. Feels like I'm really close, but no joy yet. Any suggestions? GitHub: https://github.com/johnsoez4/dict The code snippet below uses the structs defined earlier in the file. The last line below causes the error:...

Numpy: Import from source dir error

I am trying to import Numpy in my mojo project using ``` from python import Python ...

Quick Question on Traits

Hi, Introducing myself to the language and I am wondering how I would get the functionality of being able to pass a conforming type to a function. I tried two ways, the first way is the following code....

can i use wsl for mojo?

i have wsl ubunto and arch, i can use it for using mojo?

GRAPH API MOTensor not working

Facing issues with graph API tutorial: https://docs.modular.com/engine/graph What is this MOTensor? ``` from max import graph...

unable to load package '/Users/hammad/.modular/pkg/packages.modular.com_mojo/lib/mojo/stdlib.mojopkg

I just started working on an educational physics engine when suddenly mojo interpreter got angry at me for no reason and started throwing this error:
unable to load package '/Users/hammad/.modular/pkg/packages.modular.com_mojo/lib/mojo/stdlib.mojopkg'mojo
unable to load package '/Users/hammad/.modular/pkg/packages.modular.com_mojo/lib/mojo/stdlib.mojopkg'mojo
Code: ```python struct System:...

Debugger not stopping

The Mojo debugger does not stop at a breakpoint in a Github Codespace instance. Does anybody else encounter this? What am I doing wrong?

Groq integration?

https://console.groq.com/playground https://pypi.org/project/groq/ Has anyone explored running groq's python API library with mojo? Seems like a great way to accelerate things even more. And currently groqcloud api is free! ...

A custom language front end

At the current level of maturity of this project, how easy would it be to write one's own language front end and hook into mojo's IR layer, potentially avoiding direct use of llvm altogether? I'm not a huge fan of pythonic front ends.

Defining A DynamicVector containing References

I am trying to create a vector that holds a list of object references so that I can manipulate the object's properties from the container but I don't understand how to define the "lifetime" of the Reference type. According to the Mojo docs, it requires three parameters (Reference[?, ?, ?]). I want the lifetime to last for the duration of the parent object's lifetime. Can I get some examples for proper lifetime values when specifying the Reference type parameters?
Reference[Snake, __mlir_attr.`true`, ImmLifetime.DType]
Reference[Snake, __mlir_attr.`true`, ImmLifetime.DType]
...

Need Opinion! Best Practices for Directory Structure and Unit Testing in Mojo Library?

Hello Mojo, I'm currently working on a library project in Mojo :mojo: and I'm seeking some advice to ensure that my project is well-organized and follows best practices. Directory Structure:...

Disambiguation of a call to an overloaded function when the argument satisfies multiple signatures?

I have a reader class that calls write_string() via reader.write_to() which is different depending on if the write implements a Writer or StringWriter trait. ```py fn write_string[W: Writer](inout writer: W, string: String) raises -> Int: return writer.write(string.as_bytes())...

Mojo and Max installation issue

when I am running the commands modular install mojo and modular install max, I am getting the following error as in the picture. WSL 2...
No description

In-place replacement of struct fields

Hey all, I was wondering if someone has a away of changing the underlying data of a tensor in a struct at run time. ```rust struct IOStream var source: Tensor fn init(inout self):...

Mojo for heterogeneous compute

Hello! Mojo talks about managing heterogeneous compute (from the LLVM dev con '23) slides. Does it mean that the runtime can distribute the load across heterogeneous compute elements? My question is not for AI/ML angle, so it's not just about GPUs but multi-core ASICs with variety of cores. Thank you in advance

auth

Where can I retrieve the auth_key for modular auth? Can I only auth via browser? I want to containerize the max engine

Call dynamic library functions

Hey everyone, does Mojo supports calling dynamic libraries function coded in C (.so)? If yes, is there any guide for that out there? Thanks!...

partially unbound parameters as return values?

```typescript struct Person[Age: UInt8, coder: Bool]: ... fn example(p: Person) -> Person[p.Age, *_]:...