Modular

M

Modular

Join the community to ask questions about Modular and get answers from other members.

Join

questions

community-showcase

Autodiff For Mojo

Is there some kind of way to autodiff through functions in Mojo? This is very convenient in my line of work.

What type is the Mojo Parser? PEG?

Hello, I was curious about the parser of Mojo. Is it a PEG parser like Python? how was it built?

Error while importing local python file

Hi I was doing some experiements with python and mojo but when I tried to import the local file I got the following error:
Unhandled exception caught during execution: No module named 'python_curl'
mojo: error: execution exited with a non-zero result: 1
Unhandled exception caught during execution: No module named 'python_curl'
mojo: error: execution exited with a non-zero result: 1
Here is the code: ```python...

Its possible to create SIMD vector at runtime

I am currently working on a vector implementation using SIMD and I am encountering a challenge. Specifically, I am unable to locate an example demonstrating how to initialize an SIMD vector at runtime. Here is the relevant code snippet I am working with: ```cpp...

MLIR Docs

I've tried checking out the official MLIR website as well as the OurBool notebook but can't seem to find any info on certain bits of MLIR used in Mojo. e.g. lit and kgen are dialects used in the Mojo compiler if I understand correctly but they aren't documented anywhere I can find. Am I missing something or does Modular have some in house dialects that aren't publicly documented? Any plans to document them if so?

Is there a (N-D) contiguous data structure for non-trivial structs?

I need a data strucuture that is a 2-dimensional array of (inline) lists of pairs. That is, if subdata = data[i][j], then subdata is a dynamic data structure that contains tuples of size 2. My take on solving this was to use a Tensor for the 2-D data structure, an InlinedFixedVector for the flexible part, and a StaticTuple for the pair. ```mojo...

Difficult Trait Conformance

I have been using mojo nightly mojo 2024.8.305 (f99b2e40). I need someone's help on why this doesn't work: ```mojo trait IterDataPipable: fn next[T: CollectionElement](ref[_] self) -> Optional[T]: pass ...

Interfaces or Abstract Classes

I am learning the language, coming from .NET and Python. I am trying to implement a feature that is only aware of the of signature of another feature, and isn't concerned with its implementation details. Naturally, I reached for the traits system, but hit a brick wall because I found out you can't specify the return type of a function to be a trait, and I don't think you can specify a variable's type to be a trait either. I got partly around this writing a function that takes in the trait......

How can I write asynchronous code?

How can I implement asynchroneous code in mojo (using async etc.)? In the Changelog, I find the following example (slightly adjusted): ```mojo...

How to overload methods of generic structs to target particular types

Consider the snippet below: ``` struct Wrapper[T: CollectionElement]: var value: T...

Any way to work around that capturing closures cannot be materialized as runtime values?

I'm trying to implement converting data from an existing, possibly nested data structure into native Mojo collections like List, Dict etc. in a generic way. Here's an example for lists with one approach i've been trying: ``` @value struct Column[T: CollectionElement]:...

Hey All! I'm trying to convert an existing python code into mojo which uses jpype for java interop

I ran the code and it said "Java integration is not available in Mojo. Please run the Java part separately." does anyone have experience running code in another language from mojo with low latency?

Working LinkedList using pointers

https://github.com/MVPavan/mojos/blob/master/learn/dsa/my_linked_list.mojo I have created linked list in Mojo, it runs fine with all the methods and deletions. However debug is failing, any idea why ? Also any feedback on deletion, memory leaks is also appreciated....

How to delete/uninitialize a variable in mojo when running through notebooks

When i declare a variable, I am unable to free the memory used by it in jupyter/vscode notebooks. Setting the
variable = None
variable = None
or
del variable
del variable
works in python. Same case with structs, which can't be deleted unless i manually implement
__del__
__del__
. Is there any way to free the memory casually when experimenting with large memory consuming variables in the notebook ?

Why doesn't this work for creating lists?

fn main() -> None:
var any_list = List[Int](range(1, 10_000_000))
fn main() -> None:
var any_list = List[Int](range(1, 10_000_000))
...

max engine leaking?

Apple M2 Max 96G Was trying to run a text2text onnx model, but ram usage just keeps rising (see video). I am using https://github.com/bloomberg/memray as a profiler. Seems like it is the engine specifically...

Bug or optimisation

The following code: ``` struct A: fn init(inout self): ......

Matrix Multiplication (matmul): `numpy` hard to beat? even by mojo?

Super interested in mojo and wanted to try out some of the documentation/blog examples. 🤓 🔥 https://docs.modular.com/mojo/notebooks/Matmul Great explanations and the step by step speed improvements are amazing to see! 👍 ...

Is Mojo suited for developing optimization algorithms like genetic algorithms?

The major purpose of Mojo is for AI, is it suited for developing computational optimization algorithms?

Mojo extension in Vscodium

Hey everyone! Is there a way to get the Mojo extension in vscodium? I am not able to find it, is it by any reason only available in vscode?...