modularml / max

A collection of sample programs, notebooks, and tools which highlight the power of the MAX Platform
https://www.modular.com
Other
330 stars 40 forks source link

[Bug]: Cannot locate modular 'max' #188

Closed craig-clifford closed 2 months ago

craig-clifford commented 3 months ago

Issue description

Examples do not work on Apple M1 16gb. Image 7-5-24 at 3 15 PM

Image 7-5-24 at 3 16 PM

Steps to reproduce

(base) ➜ ~ cd max/examples/graph-api/pipelines/llama3 (base) ➜ llama3 git:(main) mojo ../../run_pipeline.🔥 llama3 --prompt "I believe the meaning of life is" Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:16: /Users/clifford/max/examples/graph-api/pipelines/llama2/run.🔥:21:6: error: unable to locate module 'max' from max.graph.quantization import ( ^ Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:16: /Users/clifford/max/examples/graph-api/pipelines/llama2/run.🔥:21:10: error: 'graph' does not refer to a nested package from max.graph.quantization import ( ^ Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19: Included from /Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:19: /Users/clifford/max/examples/graph-api/pipelines/replit/model/replit.mojo:17:10: error: from max.graph import ops, Dim, TensorType, Symbol, Graph, Type ^ Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19: /Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:81:15: error: 'Replit[ReplitCheckpoint, float32]' value has no attribute 'build_graph' g = replit.build_graph(


Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:16:10: error: 
from max.engine import InferenceSession, Model, TensorMap
         ^
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:92:22: error: use of unknown declaration 'session'
    compiled_model = session.load(g)
                     ^~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:116:18: error: use of unknown declaration 'results'
        output = results.get[DType.float32]("output0")
                 ^~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:117:19: error: use of unknown declaration 'results'
        k_cache = results.get[DType.float32]("output1")
                  ^~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:118:19: error: use of unknown declaration 'results'
        v_cache = results.get[DType.float32]("output2")
                  ^~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:119:18: error: use of unknown declaration 'output'
        argmax = output.argmax(axis=-1).astype[DType.int64]()
                 ^~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:121:25: error: use of unknown declaration 'argmax'
        argmax_length = argmax.dim(1)
                        ^~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:122:22: error: use of unknown declaration 'argmax'
        next_token = argmax[0, argmax_length - 1]
                     ^~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:19:
/Users/clifford/max/examples/graph-api/pipelines/replit/run.mojo:123:41: error: use of unknown declaration 'next_token'
        if bpe_tokenizer.is_end_of_text(next_token):
                                        ^~~~~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:18:
Included from /Users/clifford/max/examples/graph-api/pipelines/quantize_tinystories/run.🔥:17:
/Users/clifford/max/examples/graph-api/pipelines/quantize_tinystories/quantize_tinystories.🔥:18:10: error: 'graph' does not refer to a nested package
from max.graph.checkpoint import save, TensorDict
         ^
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:18:
Included from /Users/clifford/max/examples/graph-api/pipelines/quantize_tinystories/run.🔥:17:
/Users/clifford/max/examples/graph-api/pipelines/quantize_tinystories/quantize_tinystories.🔥:239:26: error: 'TeenyTinyLlama' value has no attribute 'build'
    llama = llama_builder.build()
            ~~~~~~~~~~~~~^
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:18:
Included from /Users/clifford/max/examples/graph-api/pipelines/quantize_tinystories/run.🔥:18:
/Users/clifford/max/examples/graph-api/pipelines/quantize_tinystories/load_tinystories.🔥:205:26: error: 'TeenyTinyLlama' value has no attribute 'build'
    llama = llama_builder.build()
            ~~~~~~~~~~~~~^
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:16:
/Users/clifford/max/examples/graph-api/pipelines/llama2/run.🔥:255:20: error: use of unknown declaration 'hyperparams'
    params = model.hyperparams()
                   ^~~~~~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:16:
/Users/clifford/max/examples/graph-api/pipelines/llama2/run.🔥:256:19: error: use of unknown declaration 'build_graph'
    graph = model.build_graph("llama_model")
                  ^~~~~~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:17:
/Users/clifford/max/examples/graph-api/pipelines/llama3/run.🔥:196:20: error: use of unknown declaration 'hyperparams'
    params = model.hyperparams()
                   ^~~~~~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:17:
/Users/clifford/max/examples/graph-api/pipelines/llama3/run.🔥:200:20: error: module 'model' is not subscriptable
        model.model["tokenizer.ggml.tokens"]._value.unsafe_get[GGUFArray]()[]
                   ^
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:17:
/Users/clifford/max/examples/graph-api/pipelines/llama3/run.🔥:204:19: error: use of unknown declaration 'build_graph'
    graph = model.build_graph("llama_model")
                  ^~~~~~~~~~~
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:17:
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/run.🔥:34:
/Users/clifford/max/examples/graph-api/pipelines/llama3/tokenizer/regex.mojo:16:6: error: unable to locate module '_mlir'
from _mlir._c.ffi import MLIR_func
     ^
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/../../run_pipeline.🔥:17:
Included from /Users/clifford/max/examples/graph-api/pipelines/llama3/run.🔥:34:
/Users/clifford/max/examples/graph-api/pipelines/llama3/tokenizer/regex.mojo:16:12: error: '_c' does not refer to a nested package
from _mlir._c.ffi import MLIR_func
           ^
mojo: error: failed to parse the provided Mojo source module
(base) ➜  llama3 git:(main) 

### Version Info

```shell
- Provide Modular CLI version by pasting the output of `modular -v` modular 0.8.0 (39a426b5)
- What OS did you install modular CLI on ? Mac OS Sonoma - Latest
```
ehsanmok commented 3 months ago

It looks like some of the installation steps are missing. Please make sure to follow all the 6 steps here

iamtimdavis commented 2 months ago

@craig-clifford please let us know if this is still an issue and re-open after following our install steps for 24.4 🙇 Thanks!