mimiquate / candlex Goto Github PK
View Code? Open in Web Editor NEWAn Nx backend for candle machine learning framework
Home Page: https://hex.pm/packages/candlex
License: Apache License 2.0
An Nx backend for candle machine learning framework
Home Page: https://hex.pm/packages/candlex
License: Apache License 2.0
Depends on #75
https://hexdocs.pm/nx/Nx.html#fft/2
Example failure:
[error] Task #PID<0.516.0> started from SpeechToText.Serving terminating
** (RuntimeError) unsupported Candlex.Backend.fft function
(candlex 0.1.5) lib/candlex/backend.ex:926: Candlex.Backend.fft/3
Hi, thanks so much for making this package so quickly!
I'm trying to use candlex in an elixir livebook on a host with an A100 and cuda installed (and working via EXLA backend).
The livebook looks like this
# setup cell
Mix.install(
[
{:kino_bumblebee, "~> 0.4.0"},
{:exla, ">= 0.0.0"},
{:candlex, "~> 0.1.4"}
],
config: [nx: [default_backend: Candlex.Backend]]
)
# subsequent cell
repo =
{:hf, "codellama/CodeLlama-7b-hf"}
{:ok, model_info} = Bumblebee.load_model(repo, backend: {Candlex.Backend, device: :cuda})
{:ok, tokenizer} = Bumblebee.load_tokenizer(repo)
{:ok, generation_config} = Bumblebee.load_generation_config(repo)
generation_config = Bumblebee.configure(generation_config, max_new_tokens: 100)
serving =
Bumblebee.Text.generation(model_info, tokenizer, generation_config,
compile: [batch_size: 1, sequence_length: 1028],
stream: false,
defn_options: [compiler: EXLA, lazy_transfers: :never],
preallocate_params: true
)
Kino.start_child({Nx.Serving, name: Codellama, serving: serving})
prompt = "<PRE> #fibonnaci in elixir <SUF>Fibby.fib(5) <MID>\n"
Nx.Serving.batched_run(CodeLlama, prompt)
I get the error Candle Error: the candle crate has not been built with cuda support
when calling Bumblebee.load_model. How would I go about installing the correct crate? Sorry, I'm a total rust and rustler newbie.
Any help is much appreciated <3
Other than that, would you expect the above to work and with performance on-par with the EXLA backend?
Example of currently unsupported shapes:
** (RuntimeError) Unsupported put_slice shapes, tensor={1, 3001, 400} and slice={1, 1, 400}. All-but-last dimensions in slice need to be equal to corresponding dimension in tensor.
(candlex 0.1.5) lib/candlex/backend.ex:423: Candlex.Backend.put_slice/4
See commented test cases in
Lines 1855 to 1923 in fd21e30
Lines 2203 to 2218 in 9e133fe
Follow up on #9
cholesky/2
eigh/3
lu/3
qr/3
triangular_solve/4
Returns the dot product of two tensors.
Given a and b, computes the dot product according to the following rules:
- If both a and b are scalars, it is equivalent to a * b.
- If a is a scalar and b is a tensor, it is equivalent to Nx.multiply(a, b).
- If a is a tensor and b is a scalar, it is equivalent to Nx.multiply(a, b).
- If both a and b are 1-D tensors (vectors), it is the sum of the element-wise product between a and b. The lengths of a and b must be equal.
- If both a and b are 2-D tensors (matrices), it is equivalent to matrix-multiplication.
- If either a or b is a 1-D tensor, and the other is an n-D tensor, it is the sum of the element-wise product along the last axis of a or b. The length of the 1-D tensor must match the last dimension of the n-D tensor.
- If a is an n-D tensor and b is an m-D tensor, it is the sum of the element-wise product along the last axis of a and the second-to-last axis of b. The last dimension of a must match the second-to-last dimension of b.
Cases:
Right now is partially implemented given the limitation of having only matmul
in candle-core
.
See partial test coverage we have in
Lines 500 to 655 in b55a50b
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.