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

Traits with compile-time SIMD size

I can't seem to fulfill a trait that can return different length SIMDs ```mojo trait PRNGEngine(Movable): @staticmethod fn ndim() -> Int:...

Specialize on trait

As far as I can tell, the following will not compile: ``` trait T1: pass ...

software cost estimating

That article does not understand software economics. COCOMO is used as a very rough estimate for early development, when most of the work is cookie-cutter code. It is also generally disputed and not viewed as accurate for projecting real effort. For that matter, LOC is not a particularly good metric for assessing a code base: not for assessing concepts of "maintainability" or "cost" or "defect rate" or any other metric of code health. It is often used as a base starting point (i.e., given everything else being identical, a code base 2x as large will cost roughly 2x as much), but all the other factors are often considered more important. "All the other factors" include things like modularity, code complexity (many methods of measurement), token count (similar to line count, but not just measuring lines; i.e., some lines have a LOT of tokens, while other lines have only one token), and more. I used to work for a company that had many patents around concepts of code complexity. We were one of many companies with a "cost estimator" tool, too. And we all knew (and openly admitted) that our estimator (just like all others) was very, very, very rough. I.e., cost could easily be 50% of our estimate or 2x our estimate -- the statistical deviation was wide. Our statistical relevance was so-so at best. Same with other models. Finance people still loved the models because you have to assess cost projections somehow, even when you know the estimates are widely flawed. Side note: this is one of the many "holy grail" targets. If you can make an accurate (good luck) cost projection tool to help organizations identify "cost to complete a software project," then you have a product you can sell for $$. Just don't step into the ring assuming that nobody has tried. There are literally dozens of companies shilling various models, and they all sorta suck. Very wide margins-of-error (statistical deviations). As of a couple years ago, there was not a product in existence that is substantially more accurate than quality engineering managers giving a "guestimate" based on decades of experience. Some companies sell massive reports that combine all of the current estimation methods (we sold our estimates to a couple prominent report-generation companies, like Black Duck), but there is no single "this number is pretty good" solution. At least not as of ~2 years ago; last time I was working in that field....

Mojo SDK API-KEY?

Where do I generate the API-KEY required by the MOJO-SDK (account at developer.modular.com seams not to provide key generation)?

Seeking Clarification on Current and Future Tensor Library Support in Mojo

I wonder if someone can clarify the current state and future direction of a Tensor library for Mojo. I understand that Tensor won't stay in the standard library and i think to understand the rationale behind it. We have also NuMojo, which looks very promising. It is currently based on Tensor but aims to have "Native array types" as a long-term goal. Not clear about the situation, I implemented my own vectorized yet simple Vector and Matrix structs for my KAN experiments. They work, my KAN implementaton outperforms the Python implementation i ported to Mojo (which is numpy based). However, I just found out these are extremely slow compared to torch.matmul, etc. ...

Parameterized function definitions in traits

Is this possible? ``` trait X: fn x[Y: AnyType](self, y: Y) -> Y: pass...

How to declare a function type in a trait?

This is a simple class in Python ```python class MyPair: def init(first, second):...

About lifetimes

Hi, I'm playing with FFI and I need to know how to manage correctly some lifetimes. Let's take an example : ``` alias external_func = fn(UnsafePointer[JpegErrorMgr]) -> UInt...

Benchmarking code that raises

I am trying to use benchmark to time numpy code. However, numpy raises and it appears that benchmark.run cannot handle a function that raises. I am not a python programmer, so I am not familiar with the exception syntax. Is there a way to wrap numpy code such that the surrounding function does not raise?

FFI

Hi, I'm working on FFI and I've got two small questions : 1 - what is the equivalent of size_t in Mojo ? 2 - Dynamic linking is easy but I haven't found a way to proceed with a static library (.a file). Is there a clean and official way to do that ?...

example of python code calling a mojo lib and its mojo code

I would like to give a try mojo a nd create a library in can use in python code. I would like to check if anyone has examples of doing this. Guess the python part is easy as it is going to be as any other library but i am interested on how to process ffi in mojo(cstrings etc)

Google TPUs with Mojo language?

Sup, I'm creating a resource-intensive AI (at least 3-4x more resource-intensive than LLMs), so I'm considering a stack which would allow me fast computation cheap (while making dev relatively easy). Would using JAX and TPUs not work with Mojo? As far as I see, using TPUs is the absolute fastest we can get for deep learning. (or is it? Would MAX inference engine be faster?) ...

Importing package in test

Hey - not sure if I'm doing something wrong with my env setup but my tests in my test/ folder can't seem to import from package_name/. My folder structure is ``` repo/ package_name/...

How to understand Mojo's compiler optimization capabilities?

This is something that’s been bugging me for a while. I am afraid there’s no clear answer, but I’m curious how you guys handle it. How can I figure out what optimizations the compiler is doing anyway instead of implementing them myself (vectorize etc) ? Implementing them myself is often easy with Mojo, but still it’s prone to errors, makes the code harder to read, and things like choosing simd_width in the code might be less optimal than letting the compiler decide based on the machine the code is running on. ...

Can I use Mojo🔥 for web development and app development?

#general Can I use Mojo🔥 for web development and app development?

max modules import error while running bert python torch script

>>bash run.sh
+ INPUT_EXAMPLE='Paris is the [MASK] of France.' + MODEL_PATH=../../models/bert-mlm.torchscript ++ dirname run.sh...

error running bash run.sh after installing max

error running bash run.sh after installing max it says >>bash run.sh ...

UnsafePointer[T].initialize_pointee_copy error

Hi, I try to store multiple values in memory initialize by an UnsafePointer[T], like the official documentation states but I've got the error "invalid call to 'initialize_pointee_copy': argument #0 cannot be converted from 'UnsafePointer[T, 0]' to 'UnsafePointer[T, 0]'" ...

list of pre-implemented models?

I see there are examples that run Llama2, Llama3, TinyLlama, and Stable Diffusion. Is there a list of pre-implemented models that can be used? Or is it just these examples? https://github.com/modularml/max/tree/main/examples/graph-api/pipelines/quantize_tinystories

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:...