Skip to content

Commit

Permalink
Bugfix 20241228 (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
atzmueller authored Dec 28, 2024
1 parent 94a1620 commit 41c7058
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
7 changes: 4 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ Though our focus is still on the inference, we will support training models. (St

## Getting Started

1. Install [Roswell](https://github.com/roswell/roswell) and suitable IDE. (If unsure, Emacs or [Lem](https://github.com/lem-project/lem) is recommended)
1. Install [Roswell](https://github.com/roswell/roswell) and a suitable IDE. (If unsure, Emacs or [Lem](https://github.com/lem-project/lem) is recommended)
2. Install [ISL (Integer Set Library)](https://github.com/Meinersbur/isl) for the fast kernel generation.
3. Install [Qlot](https://github.com/fukamachi/qlot)
4. Check out [getting-started.lisp](./docs/getting-started.lisp)
3. If not already installed, then install [libyaml](https://github.com/yaml/libyaml) for YAML parsing and emitting.
4. Install [Qlot](https://github.com/fukamachi/qlot)
5. Check out [getting-started.lisp](./docs/getting-started.lisp)

```sh
$ git clone [email protected]:hikettei/Caten.git
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
object)

(defun try-codegen! (graph outputs)
"Util for visualzing the process of compiling the `graph`."
"Utility for visualizing the process of compiling the `graph`."
(optimize-aasm graph)
(let ((vm (make-avm graph :main nil outputs nil)))
(fresh-line)
Expand All @@ -180,7 +180,7 @@
(setf (avm-graph vm) (schedule-graph->avm-graph (avm-graph vm) schedule-graph))
(avm-reset vm))))

;; Example 1. Lowering two matries addition into the C kernel.
;; Example 1. Lowering two matrices' addition into the C kernel.
(let* ((graph
;; This is a graph to compile: Z(3 3) = X(3 3) + Y(3 3)
(with-context
Expand Down
6 changes: 3 additions & 3 deletions source/air/viz.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Visualizes the graph using graphviz(requirement). Set open=t to open the resulti
(butlast (loop for n in list
append (list (format nil "~a" n) ", ")))))

(defmethod ->dot ((graph Graph) &key (pathname "/tmp/graph.dot") (open t) (title "node"))
(defmethod ->dot ((graph Graph) &key (pathname "~/tmp/graph.dot") (open t) (title "node"))
(with-open-file (stream pathname :direction :output :if-exists :supersede :if-does-not-exist :create)
(format stream "digraph computation_node {
node[charset=\"UTF-8\"
Expand Down Expand Up @@ -142,11 +142,11 @@ Visualizes the graph using graphviz(requirement). Set open=t to open the resulti
(format stream "}"))
(format t "(DOT=1) ->dot: Saving the graph \"~a\" at ~a, ~a.png, ~a.html.~%" title pathname pathname pathname)
(when open
(uiop:launch-program (list "dot" "-Tpng" pathname "-o" (format nil "~a.png" pathname)) :output t)
(uiop:launch-program (format nil "dot -Tpng ~a -o ~a" pathname (format nil "~a.png" pathname)))
(let ((htmlpath (format nil "~a.html" pathname)))
(with-open-file (stream htmlpath :direction :output :if-exists :supersede :if-does-not-exist :create)
(format stream "<html><p><b><font size=\"5\">~a</b></p><body><img src=\"~a.png\"></body></html>" title pathname)
(uiop:launch-program (list "open" htmlpath) :output t)))))
(uiop:launch-program (list "open" htmlpath))))))

(defun compute-n-children (graph id &aux (seen nil) (count 0))
(labels ((explore (id)
Expand Down
1 change: 1 addition & 0 deletions source/test-suite/external/test-tokenizer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def tiktoken_decode(list):
(import-function "tiktoken_tokenize")
(import-function "tiktoken_decode")

;; assuming M-x slime-cd to be the root of the project.
(defun make-bpe-gpt2 ()
(make-bpe-tokenizer
(uiop:read-file-string "./source/test-suite/external/assets/gpt2_tokenizer/tokens.txt")
Expand Down
4 changes: 4 additions & 0 deletions source/test-suite/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@

(in-package :caten/test-suite)

;; running the tests requires something like "pip install torch", "pip install gguf"
;; and of course a runnable python ...

(python-exec "import torch
import struct
import gguf
import torch.nn.functional as f
import numpy as np")

(import-module "numpy" :as "np" :reload t)
(import-module "struct" :reload t)
(import-module "gguf" :as "gguf" :reload t)
Expand Down

0 comments on commit 41c7058

Please sign in to comment.