Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My TODO List #47

Open
23 of 61 tasks
hikettei opened this issue Jul 29, 2023 · 1 comment
Open
23 of 61 tasks

My TODO List #47

hikettei opened this issue Jul 29, 2023 · 1 comment
Assignees

Comments

@hikettei
Copy link
Owner

hikettei commented Jul 29, 2023

今取り組んでることとか課題とかのTODO List

  • Docgen周りのリファクタリング (気が向いたら)
  • metal backend
  • cl-waffe2/nn -> generic
  • Stable Diffusion Inference

Environments / Backends

  • Testing on CCL/SBCL/LispWorks/Allegro (Modern Mode Support?)
  • SIMD Extension [Add] SSE/AVX512/Neon Support.
  • [Add] CUDATensor Backend
  • [Add] MetalBackend
  • 最適化レベルの設定とVMでのRuntime Error Handling
  • build receiving multiple inputs (LazyCons)
  • defmodelの多重ディスパッチ (バックエンドの名前で)

cl-waffe2/base-impl

  • UnfoldをC++で自作してvectorize or oneDNN interop
  • Row-majorのGemm
  • Sparse Gemm, Sparse Matrix Support
  • LazyCons/Permute/Reshape/View/Setqとかのbackend=tのノード: Loadで置き換える (A* = B*;)

cl-waffe2/vm.nodes

  • ネットワーク構築のAPI(defnode/define-impl/define-impl-op/defmodel/defmodel-as)の構築/テスト (Implemented Fairly well)
  • ただのNumpy-likeな行列演算ライブラリとして、cl-waffe2から分離したプロジェクトとして、コンパイルされたcl-waffe2のプログラムの集合をライブラリとして提供することができる (e.g.: topi in TVM)
  • RNNの実装に関して
    • Control FlowをVMに実装するか defmodel-asで部分的にコンパイルしたネットワークをdefine-by-runっぽく繋げて動作する二つの方法のどっちかがある 多分後者でRNN実装
  • defmodel-asの最適化:
    -AOT Compiler, AbstractNodeにコンパイルするときはメモリの割り当てだけ後から変更して再利用できるように!
  • define-by-runモードの実装で一番の課題はコンパイル時間である。
    • (メソッド割り当てが重い) 1. AbstractNodeネットワークの構築 2. ネットワークのコンパイル この二つに分けて最適化。
  • Conv2DのSubscript DSLのバグ
  • forward -> compiler-macro使ってインライン化できない?

cl-waffe2/vm.generic-tensor

  • :cache-when-compiled=nilのdefine-implは、build時に(compile nil body)を実行する原因となるのでWarningを出す

    • Instead, define-impl-opでλ関数として命令を作ってほしい
    • その場合、call-with-viewの関数版のAPIを用いる必要がある。apply-ranked-op的な
  • forwardメソッドの形状検査

  • Memory Pool

    • コンパイル時にTensorに三つの様相を付与して、学習時allocationの回数を最小化するような最適化問題を解けるはず
    • Dynamically Shapingの不安定さを治す
    • forwardの結果がdynamically shapingである時、strideが新しくならないのでmake-inputしないとErrorになるの治す
    • 実装する: make-inputは要素が0で埋められている保証がない。なぜならcacheされるから (Shapeの形状Traceして事前にAllocate?)
    • tensor-displace-toを用いなくてもview関数でbatchの調整を without copying
  • retain-gradオプションを追加する by setting tensor-grad-n=1

  • 逆伝播の時 toplevelにあるMoveをInlining + In-place mutationの最適化は、optimizerの副作用の行方がわからなくなるのでやらない。

  • call-with-view: 大規模な行列に対するlparallel並列化の性能の評価とそれらを有効にする

  • データ型(Dtype)関連

    • Casting
    • ユーザー定義のdtypeをサポート
    • String型が実装できるかやってみる

cl-waffe2/vm

  • defpathマクロによる検索ベースのFusionOpでデバイス特化の最適化を追加する
    • 例えば!sumはBroadcastingとAddNodeベースだが、総和専用のKernelを書いた方が速度精度高い。
  • (log (1+ x))の微分のFusionOPは数値的安定性からMUSTである。これからFusionOPで実装する
  • 最適化 -> (EXP X) -> A, B これを検出して最適化できる箇所がたくさんある。ソートをTensorじゃなくてAbstractNodeのIDベースでやればできそう
  • 最適化: sin(x, out) <- outでcopy(x)するの無駄 allocする計算ノードにする

cl-waffe2

  • deftrainerを廃止する。defoptimizerの使い方と合わせてもっとelegantなAPIにする。
  • ちゃんと頭が回っているときに書きたい

その他

  • AOTのShapeError
  • out-scalar-p忘れのCheck
  • 公平な条件でNumpy+Numba/Theano/Petalispあたりと比較したベンチマークをとってReadme.mdに乗せたい
  • GPT2 Inferenceの安定化
  • ここのTODOリストが99%くらい実現できたらQuicklispにでも登録する。
  • step-by-step
  • 公式ドキュメントのチュートリアルを消すか書き直す
  • Slideかく
  • Optimizer: Add RAdam
  • model-compilerを介して作られたモデルを保存してるハッシュテーブルをgc reachableにして(trivial garbage)、使わなくなったらallocationをFreeする
  • 数学関数のoutパラメーター -> Moveじゃなくてmake-tensorでおk
  • sumでoutリセットする時のScalarMul -> Fillで置き換える
  • モデルのパラメーター保存
  • defpath -> Fusion Pattern ~~ (Replaced with Symbolic Diff)~~
  • Fix: Lazy Stride with do-compiled-loop
  • Fix: !reshape with lazy tensors
  • mgl-pax
  • Im2Col Node for CPUTensor
  • JITLispTensor
  • RepeatNと同じノリのIfNode LoopNode (defmodel-as into :nodeの修正も兼ねて
  • zero cost forward zero cost tensor creation
  • build differentiable
  • Add: OpenMP batch_sizeが小さいときはPyTorchと大きな差をつけているが大きくなるにつれてcl-waffe2が遅くなる

Reading List📕

Lens

https://arxiv.org/pdf/1810.07951.pdf

https://arxiv.org/abs/1809.00738

https://github.com/JuliaDiff/Diffractor.jl

Existing approaches of Deep Learning Compilers

https://arxiv.org/pdf/2002.03794.pdf

https://tvm.apache.org/docs/arch/index.html

https://web.ist.utl.pt/nuno.lopes/pubs/torchy-cc23-extended.pdf

https://towardsdatascience.com/how-pytorch-2-0-accelerates-deep-learning-with-operator-fusion-and-cpu-gpu-code-generation-35132a85bd26

Etc.

https://arxiv.org/pdf/2307.12187.pdf

https://arxiv.org/pdf/1611.06945.pdf

@hikettei hikettei pinned this issue Jul 29, 2023
@hikettei hikettei changed the title TODO My TODO List Aug 20, 2023
@hikettei hikettei self-assigned this Oct 11, 2023
@hikettei
Copy link
Owner Author

hikettei commented Oct 11, 2023

Developing Roadmap

  • Implementing State_Dict
  • Full Supports for Dynamic Shaping
  • Refactor: Device条件無しのCompile -> Later, デバイス割り当てしてコンパイル
  • Adding these Control Flow IRs: IfNode, MapNode
  • Enhacements: OpenMP, FusionOP, JITCPUTensor for Mathematical Operations, AVX512 Intrinsics, Polyhedral Compiler.
  • Refactoring whole system
    • Rethinking these packages: cl-waffe2/vm cl-waffe2/vm.generic-tensor cl-waffe2/vm.node
      • should be integrated to one... or splitted into smaller one to keep modularity
      • -> cl-waffe2.tensor cl-waffe2.core cl-waffe2.networks cl-waffe2.polyhedral
    • our docstring system should be improved
    • concrete API specifications
  • 🎉 Release as v0.1(beta)
  • ONNX <-> AbstractNode Translator
  • FP16 Support, nbit Quantization
  • Polyhedral Compiler For Deep Learning
  • OP Fusion
  • framework-level support for OpenMP
  • CUDA/MPS Backend
  • 100% No dependency mode: Export to C mode.
  • Quantization Support
  • let's get llama3 worked using Export2C mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant