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

dynamic traits are not supported yet

Hello. Nooby question. I am working on some middleware for the lightbug project and want to build a chain-of-responsibility design pattern to handle the different aspects of processing a request / response: ``` Middleware is an interface for processing HTTP requests. Each middleware in the chain can modify the request and response. trait Middleware:...

Mandelbrot example equivalent python code

I was reading and following the code in the blog post https://www.modular.com/blog/how-mojo-gets-a-35-000x-speedup-over-python-part-1. I was trying to run the snippets provided but they don't compile by themselves because they are not complete. I found the source code in github https://github.com/modularml/mojo/blob/main/examples/mandelbrot.mojo. I ran this and it works with these results on my machine: Number of physical cores: 8 Vectorized: 14.634963190184047 ms Parallelized: 4.1496295025728989 ms Parallel speedup: 3.5268120156534257...

Best way to make a struct of CollectionElements to conform to CollectionElement.

I am still confused about best practices for __moveinit__ and __copyinit__. Let's say i have a struct with two variables, which are both structs which conform to the CollectionElement trait, how to define __moveinit__ and __copyinit__ for this struct. Will this do?...

Question about iterating a list of strings

Hi, I've got a background in Rust (10 years) and in Python (1 year) and I try to learn Mojo. I've try this : ```...

^ in mojo documentation?

Hello, sorry if this is an obvious question. I am new to programming and trying to pick my next language to learn for some more serious projects. I was reading through the documentation and I can't seem to understand what the ^ symbol does. I see it is a XOR in python but I am seeing it pop up in a few places where that doesn't make sense to me. For example here: https://docs.modular.com/mojo/manual/decorators/value specifically:
fn init(inout self, owned name: String, age: Int): self.name = name^ self.age = age...

equivalents of beartype and jaxytping? for runtime static type checking and shape checking

hi all! we are building local first large language models for health care based on work i did during my phd (http://arxiv.org/abs/1904.05342) and that we are now scaling through a non-profit (onefact.org). key blockers for us in porting this encoder-only and other encoder-decoder transformer-based models we have trained for health care use cases include runtime type checking and shape checking, given we work with XLA/TPU/GPU systems at various hospitals and health systems. happy to elaborate or discuss if needed, email is [email protected] and cv is jaan.io/cv 🙏 we were referred to you by core rust contributors....

Time taken in Inference session

This is my code: ``` var graph = Graph(in_types=List[Type](TensorType(DType.float32, (N * (H - K + 1) * (W - K + 1)),K * K * C_in), TensorType(DType.float32, K * K * C_in,C_out), TensorType(DType.float32, bias.shape()[0]))) var out = graph[0] @ graph[1] var out1 = out + graph[2]...

How to iterate through an array/list?

Hello, I'm coming from Java to Mojo. It seems there is no support for iterating with "for" through a list - at least in the present version of Mojo. Here's the code: ``` def createFreeformExtrusion(lines:((Int,Int),(Int,Int),Optional[(Int,Int)])[], height)->String: # currently without curves....

Stackdumps when using Python libraries such as scipy from mojo

Anybody else seeing random stackdumps happening when using eg scipy PythonObjects ? I'm using scipy.sparse.load_npz, csr_matrix() etc from Mojo. Quite frequently (but not always) I get stackdumps when running the code with mojo mymojo.mojo.

What features or libraries are you waiting for before you start using Mojo in your domain?

Just curious what the community is waiting for before they start using Mojo seriously in their domain. I'm in the Data Eng/Backend/DevOps space and I have a few I'm waiting for. Namely an HTTP client with SSL support and Database drivers to build data services/tooling. As for Mojo features, I'm excited to see file scope code support and better C FFI (for the above libraries). A clean way to call system...

Seeking Advice on Porting Python Classes to Mojo Structs

I still struggle with how to port Python classes to Mojo structs in the current state of Mojo and seek some help. Here I post a Python class and suggest four ways to port it to Mojo that I came up with. All of them work in this simple example but seem to have some major drawbacks when the class is more complex. It would be great to get feedback on how you handle this. Here an example Python class to port to Mojo...

Is it possible to store a list of References in Struct?

Calling all reference experts! I've seen some conversations lightly touching on the topic but I haven't seen anything concrete. I know I can do something like this: ```rust struct CLIis_mutable: Bool, lifetime: AnyLifetime[is_mutable].type: var commands: List[Reference[Command, is_mutable, lifetime]]...

LLVM Intrinsics

I'm trying to use llvm.matrix.transpose intrinsic like following: ```from sys.intrinsics import llvm_intrinsic fn main(): alias intrin: StringLiteral = "llvm.matrix.transpose" ...

deleted message by Mojo-Bot

Is it possible to recover a message that was blocked by mojo-bot. I shared a link in a long message posted in the general channel. I think the message was useful to the community. I would like to recover it, and remove the link.

Google Protobuf

Will mojo support with protbuf? or some network things can i use?

tqdm progress bar for Mojo?

I cant get tqdm to work via Python interface , so i am wondering if any of you managed to use it in Mojo or if we have something similar already implemented in Mojo. Thx.

Why are you using Mojo?

Just curious: why are you using Mojo? i will start with the obvious, lets see where this goes 😉...

math.atan funtion not working on compile time

is that okay that the atan funtion not working at compile time? when I try alias a = math.atan(Float32(3)) if fails with the error ...

What is the basis for Mojo's `async`?

As per the title, I'm wondering what the underlying mechanism for async libraries will be. In the community meeting, it was mentioned that async and coroutines would be areas of focus in Mojo's design for the next few months, so I think this is the right time to discuss their design. In C++, the underlying mechanism on which async libraries were built was initially chosen to be coroutines, but there's work going on right now to introduce a better alternative:
In a suite of generic async algorithms that are expected to be callable from hot code paths, the extra allocations and indirections are a deal-breaker. It is for these reasons that we consider coroutines a poor choice for a basis of all standard async....