AirLLM 2.8T LLM inference with single 4GB GPU
Python chinese-llmchinese-nlpfinetunegenerative-aiinstruct-gptinstruction-setllamallmloraopen-modelsopen-sourceopen-source-modelsqlora
add macos support
Yu Li44ef329d4199
diff --git a/air_llm/README.md b/air_llm/README.mdindex d8c8a2c..f0903d9 100644--- a/air_llm/README.md+++ b/air_llm/README.md@@ -6,6 +6,10 @@ AirLLM优化inference内存,4GB单卡GPU可以运行70B大语言模型推理## Updates+[2023/12/25] v2.8: Support MacOS running 70B large language models.++支持苹果系统运行70B大模型!+[2023/12/20] v2.7: Support AirLLMMixtral.[2023/12/20] v2.6: Added AutoModel, automatically detect model type, no need to provide model class to initialize model.@@ -30,7 +34,16 @@ airllm2.0。支持模型压缩,速度提升3倍。airllm发布。+## Table of Contents+* [Quick start](#quickstart)+* [Model Compression](#3-model-compression---3x-inference-speed-up)+* [Configurations](#configurations)+* [Run on MacOS](#macos)+* [Example notebooks](#example-python-notebook)+* [Supported Models](#supported-models)+* [Acknowledgement](#acknowledgement)+* [FAQ](#faq)## Quickstart@@ -99,7 +112,7 @@ Note: During inference, the original model will first be decomposed and saved la注意:推理过程会首先将原始模型按层分拆,转存。请保证huggingface cache目录有足够的磁盘空间。-### 3. Model Compression - 3x Inference Speed Up!+## Model Compression - 3x Inference Speed Up!We just added model compression based on block-wise quantization based model compression. Which can further **speed up the inference speed** for up to **3x** , with **almost ignorable accuracy loss!** (see more performance evaluation and why we use block-wise quantization in [this paper](https://arxiv.org/abs/2212.09720))@@ -125,7 +138,7 @@ Quantization normally needs to quantize both weights and activations to really sWhile in our case the bottleneck is mainly at the disk loading, we only need to make the model loading size smaller. So we get to only quantize the weights part, which is easier to ensure the accuracy.-### 4. Configurations+## ConfigurationsWhen initialize the model, we support the following configurations:@@ -137,7 +150,18 @@ When initialize the model, we support the following configurations:* **hf_token**: huggingface token can be provided here if downloading gated models like: *meta-llama/Llama-2-7b-hf** **prefetching**: prefetching to overlap the model loading and compute. By default turned on. For now only AirLLMLlama2 supports this.-### 5. Example Python Notebook+## MacOS++Just install airllm and run the code the same as on linux. See more in [Quick Start](#uickstart).++* make sure you installed [mlx](https://github.com/ml-explore/mlx?tab=readme-ov-file#installation) and torch+* you probabaly need to install python native see more [here](https://stackoverflow.com/a/65432861/21230266)+* only [Apple silicon](https://support.apple.com/en-us/HT211814) is supported++Example [python notebook](https://github.com/lyogavin/Anima/blob/main/air_llm/examples/run_on_macos.ipynb)+++## Example Python NotebookExample colabs here:@@ -145,7 +169,7 @@ Example colabs here:<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>-### 6. Supported Models+## Supported Models#### [HF open llm leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) top models@@ -267,7 +291,7 @@ model.tokenizer.decode(generation_output.sequences[0])-## 7. Acknowledgement+## AcknowledgementA lot of the code are based on SimJeg's great work in the Kaggle exam competition. Big shoutout to SimJeg:@@ -276,7 +300,7 @@ A lot of the code are based on SimJeg's great work in the Kaggle exam competitio[the associated discussion](https://www.kaggle.com/competitions/kaggle-llm-science-exam/discussion/446414).-## 8. FAQ+## FAQ### 8.1. MetadataIncompleteBufferdiff --git a/air_llm/airllm/__init__.py b/air_llm/airllm/__init__.pyindex 66c5b3a..a1d20c4 100644--- a/air_llm/airllm/__init__.py+++ b/air_llm/airllm/__init__.py@@ -1,11 +1,22 @@-from .airllm import AirLLMLlama2-from .airllm_chatglm import AirLLMChatGLM-from .airllm_qwen import AirLLMQWen-from .airllm_baichuan import AirLLMBaichuan-from .airllm_internlm import AirLLMInternLM-from .airllm_mistral import AirLLMMistral-from .airllm_mixtral import AirLLMMixtral-from .airllm_base import AirLLMBaseModel-from .auto_model import AutoModel-from .utils import split_and_save_layers-from .utils import NotEnoughSpaceException+from sys import platform++is_on_mac_os = False++if platform == "darwin":+ is_on_mac_os = True++if is_on_mac_os:+ from .airllm_llama_mlx import AirLLMLlamaMlx+else:+ from .airllm import AirLLMLlama2+ from .airllm_chatglm import AirLLMChatGLM+ from .airllm_qwen import AirLLMQWen+ from .airllm_baichuan import AirLLMBaichuan+ from .airllm_internlm import AirLLMInternLM+ from .airllm_mistral import AirLLMMistral+ from .airllm_mixtral import AirLLMMixtral+ from .airllm_base import AirLLMBaseModel+ from .auto_model import AutoModel+ from .utils import split_and_save_layers+ from .utils import NotEnoughSpaceException+diff --git a/air_llm/airllm/airllm_base.py b/air_llm/airllm/airllm_base.pyindex a38da00..4fb919c 100644--- a/air_llm/airllm/airllm_base.py+++ b/air_llm/airllm/airllm_base.py@@ -155,7 +155,12 @@ class AirLLMBaseModel(GenerationMixin):# if derived class needs to create generation config differently, like Mistrial, this function can be overriddendef get_generation_config(self):- return GenerationConfig.from_pretrained(self.model_local_path)+ # protective on generation config++ try:+ return GenerationConfig.from_pretrained(self.model_local_path)+ except Exception as e:+ return GenerationConfig()# a chance to customize tokenizerdef get_tokenizer(self, hf_token=None):@@ -414,6 +419,7 @@ class AirLLMBaseModel(GenerationMixin):for i, (layer_name, layer) in tqdm(enumerate(zip(self.layer_names, self.layers)), desc=self.running_device,+ desc='running layers:',total=len(self.layers)):if self.prefetching:diff --git a/air_llm/airllm/airllm_llama_mlx.py b/air_llm/airllm/airllm_llama_mlx.pynew file mode 100644index 0000000..be1098d--- /dev/null+++ b/air_llm/airllm/airllm_llama_mlx.py@@ -0,0 +1,431 @@++import argparse+import json+import time+import gc+from tqdm import tqdm+from dataclasses import dataclass+from pathlib import Path+from typing import Optional, Tuple++import mlx.core as mx+import mlx.nn as nn+from sentencepiece import SentencePieceProcessor+from .persist import ModelPersister+import psutil+from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, AutoModel, GenerationMixin, LlamaForCausalLM, GenerationConfig+from .utils import clean_memory, load_layer, \+ find_or_create_local_splitted_path++++@dataclass+class ModelArgs:+ dim: int+ n_layers: int+ head_dim: int+ hidden_dim: int+ n_heads: int+ n_kv_heads: int+ norm_eps: float+ vocab_size: int+ rope_theta: float+ rope_traditional: bool = True++def sanitize_config(config, weights=None):+ config.pop("model_type", None)+ n_heads = config["n_heads"] if 'n_heads' in config else config['num_attention_heads']+ if "n_kv_heads" not in config:+ config["n_kv_heads"] = n_heads+ if "head_dim" not in config:+ config["head_dim"] = config["dim"] // n_heads+ #if "hidden_dim" not in config:+ # config["hidden_dim"] = weights["layers.0.feed_forward.w1.weight"].shape[0]+ #if config.get("vocab_size", -1) < 0:+ # config["vocab_size"] = weights["output.weight"].shape[-1]+ if "rope_theta" not in config:+ config["rope_theta"] = 10000+ unused = ["multiple_of", "ffn_dim_multiplier"]+ for k in unused:+ config.pop(k, None)+ return config++def get_model_args_from_config(config):+ params = {}+ params["dim"] = config.hidden_size+ params["hidden_dim"] = config.intermediate_size+ params["n_heads"] = config.num_attention_heads+ if hasattr(config, "num_key_value_heads"):+ params["n_kv_heads"] = config.num_key_value_heads+ params["n_layers"] = config.num_hidden_layers+ params["vocab_size"] = config.vocab_size+ params["norm_eps"] = config.rms_norm_eps+ params["rope_traditional"] = False++ sconfig = sanitize_config(params)++ # quantization = config.pop("quantization", None)+ model_args = ModelArgs(**sconfig)+ return model_args++class RMSNorm(nn.Module):+ def __init__(self, dims: int, eps: float = 1e-5):+ super().__init__()+ self.weight = mx.ones((dims,))+ self.eps = eps++ def _norm(self, x):+ return x * mx.rsqrt(x.square().mean(-1, keepdims=True) + self.eps)++ def __call__(self, x):+ output = self._norm(x.astype(mx.float32)).astype(x.dtype)+ return self.weight * output+++class Attention(nn.Module):+ def __init__(self, args: ModelArgs):+ super().__init__()+ self.args = args++ self.n_heads: int = args.n_heads+ self.n_kv_heads: int = args.n_kv_heads++ self.repeats = self.n_heads // self.n_kv_heads++ self.scale = self.args.head_dim**-0.5++ self.wq = nn.Linear(args.dim, args.n_heads * args.head_dim, bias=False)+ self.wk = nn.Linear(args.dim, args.n_kv_heads * args.head_dim, bias=False)+ self.wv = nn.Linear(args.dim, args.n_kv_heads * args.head_dim, bias=False)+ self.wo = nn.Linear(args.n_heads * args.head_dim, args.dim, bias=False)+ self.rope = nn.RoPE(+ args.head_dim, traditional=args.rope_traditional, base=args.rope_theta+ )++ def __call__(+ self,+ x: mx.array,+ mask: Optional[mx.array] = None,+ cache: Optional[Tuple[mx.array, mx.array]] = None,+ ) -> mx.array:+ B, L, D = x.shape++ queries, keys, values = self.wq(x), self.wk(x), self.wv(x)++ # Prepare the queries, keys and values for the attention computation+ queries = queries.reshape(B, L, self.n_heads, -1).transpose(0, 2, 1, 3)+ keys = keys.reshape(B, L, self.n_kv_heads, -1).transpose(0, 2, 1, 3)+ values = values.reshape(B, L, self.n_kv_heads, -1).transpose(0, 2, 1, 3)++ def repeat(a):+ a = mx.concatenate([mx.expand_dims(a, 2)] * self.repeats, axis=2)+ return a.reshape([B, self.n_heads, L, -1])++ keys, values = map(repeat, (keys, values))++ if cache is not None:+ key_cache, value_cache = cache+ queries = self.rope(queries, offset=key_cache.shape[2])+ keys = self.rope(keys, offset=key_cache.shape[2])+ keys = mx.concatenate([key_cache, keys], axis=2)+ values = mx.concatenate([value_cache, values], axis=2)+ else:+ queries = self.rope(queries)+ keys = self.rope(keys)++ scores = (queries * self.scale) @ keys.transpose(0, 1, 3, 2)+ if mask is not None:+ scores += mask+ scores = mx.softmax(scores.astype(mx.float32), axis=-1).astype(scores.dtype)+ output = (scores @ values).transpose(0, 2, 1, 3).reshape(B, L, -1)+ return self.wo(output), (keys, values)+++class FeedForward(nn.Module):+ def __init__(self, args: ModelArgs):+ super().__init__()++ self.w1 = nn.Linear(args.dim, args.hidden_dim, bias=False)+ self.w2 = nn.Linear(args.hidden_dim, args.dim, bias=False)+ self.w3 = nn.Linear(args.dim, args.hidden_dim, bias=False)++ def __call__(self, x) -> mx.array:+ return self.w2(nn.silu(self.w1(x)) * self.w3(x))+++class TransformerBlock(nn.Module):+ def __init__(self, args: ModelArgs):+ super().__init__()+ self.n_heads = args.n_heads+ self.dim = args.dim+ self.attention = Attention(args)+ self.feed_forward = FeedForward(args=args)+ self.attention_norm = RMSNorm(args.dim, eps=args.norm_eps)+ self.ffn_norm = RMSNorm(args.dim, eps=args.norm_eps)+ self.args = args++ def __call__(+ self,+ x: mx.array,+ mask: Optional[mx.array] = None,+ cache: Optional[Tuple[mx.array, mx.array]] = None,+ ) -> mx.array:+ r, cache = self.attention(self.attention_norm(x), mask, cache)+ h = x + r+ r = self.feed_forward(self.ffn_norm(h))+ out = h + r+ return out, cache++def sample(logits, temperature=0):+ if temperature == 0:+ return mx.argmax(logits, axis=-1)+ else:+ return mx.random.categorical(logits * (1 / temperature))++class AirLLMLlamaMlx:++ # customize layer names here+ def set_layer_names_dict(self):+ self.layer_names_dict = {'embed': 'model.embed_tokens',+ 'layer_prefix': 'model.layers',+ 'norm': 'model.norm',+ 'lm_head': 'lm_head',}+++ def record_memory(self, msg=None):+ if not self.show_memory_util:+ return++ available = psutil.virtual_memory().available / 1024 / 1024+ if self.least_available is None:+ self.least_available = available+ else:+ self.least_available = min(available, self.least_available)++ print(f"[{msg}] - available mem: {available:.02}mb, least available:{available:.02}mb")++ def __init__(self, model_local_path_or_repo_id, device="cuda:0", dtype=None, max_seq_len=512,+ layer_shards_saving_path=None, profiling_mode=False, compression=None,+ hf_token=None, prefetching=True, test_nonlayered=False, show_memory_util=False):++ self.hf_token = hf_token+ self.set_layer_names_dict()+ self.test_nonlayered = test_nonlayered+ self.show_memory_util = show_memory_util+ self.least_available = None++++ self.model_local_path, self.checkpoint_path = find_or_create_local_splitted_path(model_local_path_or_repo_id,+ layer_shards_saving_path,+ compression=compression,+ layer_names=self.layer_names_dict,+ hf_token=hf_token)+ if hf_token is not None:+ self.config = AutoConfig.from_pretrained(self.model_local_path, token=hf_token, trust_remote_code=True)+ else:+ self.config = AutoConfig.from_pretrained(self.model_local_path, trust_remote_code=True)+++ self.model_args = get_model_args_from_config(self.config)++ self.layer_names = [self.layer_names_dict['embed']] + \+ [f'{self.layer_names_dict["layer_prefix"]}.{i}' for i in range(self.model_args.n_layers)] + \+ [self.layer_names_dict['norm'], self.layer_names_dict['lm_head']]++ self.tokenizer = self.get_tokenizer(hf_token=hf_token)+++ def get_tokenizer(self, hf_token=None):+ if hf_token is not None:+ return AutoTokenizer.from_pretrained(self.model_local_path, token=hf_token, trust_remote_code=True)+ else:+ return AutoTokenizer.from_pretrained(self.model_local_path, trust_remote_code=True)+++ def generate(self, x, temperature=0, max_new_tokens=None, **kwargs):+ tokens = []+ for token in self.model_generate(x, temperature=temperature):+ tokens.append(token)+++ if len(tokens) >= max_new_tokens:+ break+++ s = self.tokenizer.decode([t.item() for t in tokens])+ return s++ def model_generate(self, x, temperature=0, max_new_tokens=None):+ cache = []+ TEST_NO_LAYERED = True++ # Make an additive causal mask. We will need that to process the prompt.+ mask = nn.MultiHeadAttention.create_additive_causal_mask(x.shape[1])++ # First we process the prompt x the same was as in __call__ but+ # save the caches in cache++ self.record_memory('before_tok_embeddings')+ self.tok_embeddings = nn.Embedding(self.model_args.vocab_size, self.model_args.dim)+ #w0 = self.tok_embeddings.weight[0][0]+ mask = mask.astype(self.tok_embeddings.weight.dtype)++ self.record_memory('before_loading_tok')+ update_weights = ModelPersister.get_model_persister().load_model(self.layer_names_dict['embed'], self.checkpoint_path)++ self.record_memory('after_loading_tok')+ self.tok_embeddings.update(update_weights['tok_embeddings'])+ #w1 = self.tok_embeddings.weight[0][0]++ #assert w0 != w1, f"weight should change after updates, weights: {update_weights}"++ x = self.tok_embeddings(x)+ # force execution+ mx.eval(x)++ if not self.test_nonlayered:++ del self.tok_embeddings+ gc.collect()+ else:+ print(f"self.test_nonlayered:{self.test_nonlayered}, save layers")+ self.layers = []++ self.record_memory('after_tok_embeddings')+ #for l in self.layers:++ for il in tqdm(range(self.model_args.n_layers), desc='running layers:'):+ self.record_memory(f'before layer {il}')+ l = TransformerBlock(args=self.model_args)+ l.update(+ ModelPersister.get_model_persister().load_model(f'{self.layer_names_dict["layer_prefix"]}.{il}',+ self.checkpoint_path)['layers'][il]+ )++ x, c = l(x, mask=mask)+ # force execution+ mx.eval(x)+ # We store the per layer cache in a simple python list+ cache.append(c)++ if not self.test_nonlayered:+ del l+ gc.collect()+ else:+ self.layers.append(l)+ self.record_memory(f'after layer {il}')++ self.record_memory('before_norm')+ self.norm = RMSNorm(self.model_args.dim, eps=self.model_args.norm_eps)+ self.norm.update(+ ModelPersister.get_model_persister().load_model(self.layer_names_dict['norm'], self.checkpoint_path)['norm']+ )+ x = self.norm(x)+ # force execution+ mx.eval(x)+ if not self.test_nonlayered:+ del self.norm+ gc.collect()+ self.record_memory('after_norm')++ # We only care about the last logits that generate the next token+ self.record_memory('before_lmhead')+ self.output = nn.Linear(self.model_args.dim, self.model_args.vocab_size, bias=False)+ self.output.update(+ ModelPersister.get_model_persister().load_model(self.layer_names_dict['lm_head'], self.checkpoint_path)['output']+ )+ y = self.output(x[:, -1])+ # force execution+ mx.eval(y)++ if not self.test_nonlayered:+ del self.output+ gc.collect()+ self.record_memory('after_lmhead')+ y = sample(y)+++ # y now has size [1]+ # Since MLX is lazily evaluated nothing is computed yet.+ # Calling y.item() would force the computation to happen at+ # this point but we can also choose not to do that and let the+ # user choose when to start the computation.+ yield y++++ # Now we parsed the prompt and generated the first token we+ # need to feed it back into the model and loop to generate the+ # rest.+ while True:+ # Unsqueezing the last dimension to add a sequence length+ # dimension of 1+ x = y[:, None]++ if not self.test_nonlayered:+ self.record_memory('before_tok_embeddings')+ self.tok_embeddings = nn.Embedding(self.model_args.vocab_size, self.model_args.dim)+ #w0 = self.tok_embeddings.weight[0][0]+ self.tok_embeddings.update(+ ModelPersister.get_model_persister().load_model(self.layer_names_dict['embed'], self.checkpoint_path)['tok_embeddings'])+ #w1 = self.tok_embeddings.weight[0][0]++ #assert w0 != w1, f"weight should change after updates."+ x = self.tok_embeddings(x)++ # force execution+ mx.eval(x)+ if not self.test_nonlayered:+ del self.tok_embeddings+ gc.collect()+ self.record_memory('after_tok_embeddings')++ for i in tqdm(range(len(cache)), desc='running layers:'):+ self.record_memory(f'before layer {il}')+ # We are overwriting the arrays in the cache list. When+ # the computation will happen, MLX will be discarding the+ # old cache the moment it is not needed anymore.++ if not self.test_nonlayered:+ l = TransformerBlock(args=self.model_args)+ l.update(ModelPersister.get_model_persister().load_model(f'{self.layer_names_dict["layer_prefix"]}.{i}',+ self.checkpoint_path)['layers'][i])+ else:+ l = self.layers[i]++ x, cache[i] = l(x, mask=None, cache=cache[i])+ # force execution+ mx.eval(x)+ if not self.test_nonlayered:+ del l+ gc.collect()+ self.record_memory(f'after layer {il}')++ self.record_memory('before_norm')+ if not self.test_nonlayered:+ self.norm = RMSNorm(self.model_args.dim, eps=self.model_args.norm_eps)+ self.norm.update(ModelPersister.get_model_persister().load_model(self.layer_names_dict['norm'], self.checkpoint_path)['norm'])+ x = self.norm(x)+ # force execution+ mx.eval(x)++ if not self.test_nonlayered:+ del self.norm+ gc.collect()++ self.record_memory('after_norm')++ if not self.test_nonlayered:+ self.output = nn.Linear(self.model_args.dim, self.model_args.vocab_size, bias=False)+ self.output.update(ModelPersister.get_model_persister().load_model(self.layer_names_dict['lm_head'], self.checkpoint_path)['output'])+ y = sample(self.output(x[:, -1]))++ # force execution+ mx.eval(y)+ if not self.test_nonlayered:+ del self.output+ gc.collect()++ self.record_memory('after_lmhead')+ yield y\ No newline at end of filediff --git a/air_llm/airllm/persist/__init__.py b/air_llm/airllm/persist/__init__.pynew file mode 100644index 0000000..794772c--- /dev/null+++ b/air_llm/airllm/persist/__init__.py@@ -0,0 +1 @@+from .model_persister import ModelPersisterdiff --git a/air_llm/airllm/persist/mlx_model_persister.py b/air_llm/airllm/persist/mlx_model_persister.pynew file mode 100644index 0000000..1eaa2fd--- /dev/null+++ b/air_llm/airllm/persist/mlx_model_persister.py@@ -0,0 +1,113 @@+++import os+from pathlib import Path+import mlx.core as mx+from .model_persister import ModelPersister+from mlx.utils import tree_unflatten+import torch++import psutil+import numpy as np+from itertools import starmap++++def map_torch_to_mlx(model):++ # things to change+ # 1. there's no "model." in the weight names+ model = {k.replace("model.", ""): v for k, v in model.items()}++ # 2. mlp is called feed_forward+ model = {k.replace("mlp", "feed_forward"): v for k, v in model.items()}++ # 3. up_proj, down_proj, gate_proj+ model = {k.replace("down_proj", "w2"): v for k, v in model.items()}+ model = {k.replace("up_proj", "w3"): v for k, v in model.items()}+ model = {k.replace("gate_proj", "w1"): v for k, v in model.items()}++ # 4. layernorms+ model = {+ k.replace("input_layernorm", "attention_norm"): v for k, v in model.items()+ }+ model = {+ k.replace("post_attention_layernorm", "ffn_norm"): v for k, v in model.items()+ }++ # 5. lm head+ model = {k.replace("lm_head", "output"): v for k, v in model.items()}++ # 6. token emb+ model = {k.replace("embed_tokens", "tok_embeddings"): v for k, v in model.items()}++ # 7. attention+ model = {k.replace("self_attn", "attention"): v for k, v in model.items()}+ model = {k.replace("q_proj", "wq"): v for k, v in model.items()}+ model = {k.replace("k_proj", "wk"): v for k, v in model.items()}+ model = {k.replace("v_proj", "wv"): v for k, v in model.items()}+ model = {k.replace("o_proj", "wo"): v for k, v in model.items()}+++ #weights = {k: v.to(torch.float16).numpy() for k, v in model.items()}+++ return model++class MlxModelPersister(ModelPersister):+++ def __init__(self, *args, **kwargs):+++ super(MlxModelPersister, self).__init__(*args, **kwargs)+++ def model_persist_exist(self, layer_name, saving_path):++++ safetensor_exists = os.path.exists(str(saving_path / (layer_name + 'mlx.npz')))+ done_marker_exists = os.path.exists(str(saving_path / (layer_name + 'mlx.done')))++ #print(f"checking {layer_name}, {saving_path} - {safetensor_exists},{done_marker_exists}")++ return safetensor_exists and done_marker_exists++ def persist_model(self, state_dict, layer_name, saving_path):+ #save_file(state_dict, saving_path / (layer_name + 'safetensors'))+ weights = {k: v.to(torch.float16).numpy() for k, v in state_dict.items()}+ np.savez(+ saving_path / (layer_name + 'mlx'),+ **weights#map_torch_to_mlx(state_dict)+ )++ print(f"saved as: {saving_path / (layer_name + 'mlx')}")++ # set done marker+ (saving_path / (layer_name + 'mlx.done')).touch()+++ def load_model(self, layer_name, path):+ try:+ to_load_path = Path(path) / (layer_name + ".mlx.npz")+ #available = psutil.virtual_memory().available / 1024 / 1024+ #print(f"start loading: {to_load_path}, before loading: {available:.02f}")+ layer_state_dict = mx.load(to_load_path)+ #available = psutil.virtual_memory().available / 1024 / 1024+ #print(f"loaded {layer_name}, available mem: {available:.02f}")++ layer_state_dict = map_torch_to_mlx(layer_state_dict)++ weights = tree_unflatten(list(layer_state_dict.items()))++ #for el in layer_name.split("."):+ # if len(el) > 0:+ # if el.isdigit():+ # el = int(el)+ # weights = weights[el]++ return weights+ except Exception as ex:+ print(f"error: {layer_name}, {path}")+ raise ex\ No newline at end of filediff --git a/air_llm/airllm/persist/model_persister.py b/air_llm/airllm/persist/model_persister.pynew file mode 100644index 0000000..963a6f6--- /dev/null+++ b/air_llm/airllm/persist/model_persister.py@@ -0,0 +1,39 @@++++model_persister = None++class ModelPersister:+ def __init__(self):+ pass++ @classmethod+ def get_model_persister(cls):+ global model_persister+ if model_persister is not None:+ return model_persister+++ from sys import platform+ is_on_mac_os = False++ if platform == "darwin":+ is_on_mac_os = True+++ if is_on_mac_os:+ from .mlx_model_persister import MlxModelPersister+ model_persister = MlxModelPersister()+ else:+ from .safetensor_model_persister import SafetensorModelPersister+ model_persister = SafetensorModelPersister()+ return model_persister++ def model_persist_exist(self, layer_name, saving_path):+ pass++ def persist_model(self, state_dict, layer_name, path):+ pass++ def load_model(self, layer_name, path):+ pass\ No newline at end of filediff --git a/air_llm/airllm/persist/safetensor_model_persister.py b/air_llm/airllm/persist/safetensor_model_persister.pynew file mode 100644index 0000000..23f5cc7--- /dev/null+++ b/air_llm/airllm/persist/safetensor_model_persister.py@@ -0,0 +1,38 @@+++import os+from pathlib import Path+from .model_persister import ModelPersister+from safetensors.torch import load_file, save_file+++++class SafetensorModelPersister(ModelPersister):+++ def __init__(self, *args, **kwargs):+++ super(SafetensorModelPersister, self).__init__(*args, **kwargs)+++ def model_persist_exist(self, layer_name, saving_path):++ safetensor_exists = os.path.exists(str(saving_path / (layer_name + 'safetensors')))+ done_marker_exists = os.path.exists(str(saving_path / (layer_name + 'safetensors.done')))++ return safetensor_exists and done_marker_exists++ def persist_model(self, state_dict, layer_name, saving_path):+ save_file(state_dict, saving_path / (layer_name + 'safetensors'))++ print(f"saved as: {saving_path / (layer_name + 'safetensors')}")++ # set done marker+ (saving_path / (layer_name + 'safetensors.done')).touch()+++ def load_model(self, layer_name, path):+ layer_state_dict = load_file(Path(path) / (layer_name + ".safetensors"), device="cpu")+ return layer_state_dict\ No newline at end of filediff --git a/air_llm/airllm/utils.py b/air_llm/airllm/utils.pyindex 0440b0f..0f8b9ba 100644--- a/air_llm/airllm/utils.py+++ b/air_llm/airllm/utils.py@@ -10,11 +10,20 @@ import timefrom collections import OrderedDict, defaultdictfrom typing import Dict, List, Optional, Tuple, Union+from sys import platform++is_on_mac_os = False++if platform == "darwin":+ is_on_mac_os = True+import torchimport torch.nn as nnfrom safetensors.torch import load_file, save_file+from .persist import ModelPersister+try:import bitsandbytes as bnb@@ -27,7 +36,6 @@ except ImportError:import huggingface_hub-# replacement for bnb quantstat.as_dict(True), until the bug is fixed....def save_quant_state_to_dict(self, packed=True):"""@@ -105,7 +113,8 @@ def uncompress_layer_state_dict(layer_state_dict):return layer_state_dict if uncompressed_layer_state_dict is None else uncompressed_layer_state_dictdef load_layer(local_path, layer_name, profiling=False):- layer_state_dict = load_file(Path(local_path) / (layer_name + ".safetensors"), device="cpu")+ #layer_state_dict = load_file(Path(local_path) / (layer_name + ".safetensors"), device="cpu")+ layer_state_dict = ModelPersister.get_model_persister().load_model(layer_name, local_path)if profiling:t = time.process_time()@@ -216,22 +225,10 @@ def split_and_save_layers(checkpoint_path, layer_shards_saving_path=None, splitt#print(f"checking exists: {saving_path}")if os.path.exists(saving_path):# dir already exists, check if all layer files are there- files_in_saving_path = glob(str(saving_path / "*.safetensors"))- done_files_in_saving_path = glob(str(saving_path / "*.safetensors.done"))found_layers = {}for layer in layers:-- found_safetensor_file = [layer+'safetensors' in file_in_saving_path for file_in_saving_path in files_in_saving_path]- #print(layer)- #print(found_safetensor_file)- found_safetensor_file = any(found_safetensor_file)-- found_done_file = [layer+'safetensors.done' in file_in_saving_path for file_in_saving_path in done_files_in_saving_path]- #print(found_done_file)- found_done_file = any(found_done_file)-- found_layers[layer] = found_safetensor_file and found_done_file+ found_layers[layer] = ModelPersister.get_model_persister().model_persist_exist(layer, saving_path)if all(found_layers.values()):@@ -278,15 +275,11 @@ def split_and_save_layers(checkpoint_path, layer_shards_saving_path=None, splitt# Save layer state dict as using safetensors- safetensor_exists = os.path.exists(str(saving_path / (layer + 'safetensors')))- done_marker_exists = os.path.exists(str(saving_path / (layer + 'safetensors.done')))- if (not safetensor_exists) or (not done_marker_exists):- save_file(layer_state_dict, saving_path / (layer + 'safetensors'))- print(f"saved as: {saving_path / (layer + 'safetensors')}")+ marker_exists = ModelPersister.get_model_persister().model_persist_exist(layer, saving_path)+ if not marker_exists:+ ModelPersister.get_model_persister().persist_model(layer_state_dict, layer, saving_path)- # set done marker- (saving_path / (layer + 'safetensors.done')).touch()# Free memoryfor k in layer_state_dict.keys():@@ -332,10 +325,19 @@ def find_or_create_local_splitted_path(model_local_path_or_repo_id, layer_shardsf"Found local directory in {model_local_path_or_repo_id}, but didn't find downloaded model. Try using {model_local_path_or_repo_id} as a HF repo...")# it should be a repo id at this point...- if hf_token is not None:- hf_cache_path = huggingface_hub.snapshot_download(model_local_path_or_repo_id, token=hf_token)++ # check if there's safetensors saved, if so, exclude torch saves+ hf_cache_path = huggingface_hub.snapshot_download(model_local_path_or_repo_id, token=hf_token, allow_patterns="model.safetensors.index.json")++ if len(glob(str(Path(hf_cache_path) / "model.safetensors.index.json"))) > 0:+ # there's safe tensor version, exclude torch version+ hf_cache_path = huggingface_hub.snapshot_download(model_local_path_or_repo_id, token=hf_token,+ ignore_patterns=['pytorch_model.bin.index.json', '*.bin'])+else:- hf_cache_path = huggingface_hub.snapshot_download(model_local_path_or_repo_id)+ hf_cache_path = huggingface_hub.snapshot_download(model_local_path_or_repo_id,+ token=hf_token)+assert os.path.exists(Path(hf_cache_path) / 'pytorch_model.bin.index.json') or \os.path.exists(Path(hf_cache_path) / 'model.safetensors.index.json'), \f"{hf_cache_path}/pytorch_model.bin.index.json or {hf_cache_path}/model.safetensors.index.json should exists."diff --git a/air_llm/examples/run_on_macos.ipynb b/air_llm/examples/run_on_macos.ipynbnew file mode 100644index 0000000..a348417--- /dev/null+++ b/air_llm/examples/run_on_macos.ipynb@@ -0,0 +1,2091 @@+{+ "cells": [+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# example of airllm on mac os"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "from sys import platform\n",+ "\n",+ "assert platform == \"darwin\", \"this example is supposed to be run on mac os\"\n"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# install airllm"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 1,+ "metadata": {+ "collapsed": true,+ "jupyter": {+ "outputs_hidden": true+ }+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Collecting airllm\n",+ " Using cached airllm-2.7-py3-none-any.whl.metadata (13 kB)\n",+ "Collecting tqdm (from airllm)\n",+ " Using cached tqdm-4.66.1-py3-none-any.whl.metadata (57 kB)\n",+ "Requirement already satisfied: torch in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from airllm) (2.1.0)\n",+ "Collecting transformers (from airllm)\n",+ " Using cached transformers-4.36.2-py3-none-any.whl.metadata (126 kB)\n",+ "Collecting accelerate (from airllm)\n",+ " Downloading accelerate-0.25.0-py3-none-any.whl.metadata (18 kB)\n",+ "Collecting safetensors (from airllm)\n",+ " Downloading safetensors-0.4.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (3.8 kB)\n",+ "Collecting optimum (from airllm)\n",+ " Downloading optimum-1.16.1-py3-none-any.whl.metadata (17 kB)\n",+ "Collecting huggingface-hub (from airllm)\n",+ " Using cached huggingface_hub-0.20.1-py3-none-any.whl.metadata (12 kB)\n",+ "Collecting scipy (from airllm)\n",+ " Downloading scipy-1.11.4-cp311-cp311-macosx_12_0_arm64.whl.metadata (165 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m165.4/165.4 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hRequirement already satisfied: numpy>=1.17 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (1.26.2)\n",+ "Requirement already satisfied: packaging>=20.0 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (23.2)\n",+ "Requirement already satisfied: psutil in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (5.9.0)\n",+ "Requirement already satisfied: pyyaml in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (6.0.1)\n",+ "Requirement already satisfied: filelock in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (3.13.1)\n",+ "Requirement already satisfied: typing-extensions in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (4.7.1)\n",+ "Requirement already satisfied: sympy in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (1.12)\n",+ "Requirement already satisfied: networkx in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (3.1)\n",+ "Requirement already satisfied: jinja2 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (3.1.2)\n",+ "Requirement already satisfied: fsspec in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (2023.10.0)\n",+ "Requirement already satisfied: requests in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from huggingface-hub->airllm) (2.31.0)\n",+ "Collecting coloredlogs (from optimum->airllm)\n",+ " Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hCollecting datasets (from optimum->airllm)\n",+ " Downloading datasets-2.16.0-py3-none-any.whl.metadata (20 kB)\n",+ "Collecting regex!=2019.12.17 (from transformers->airllm)\n",+ " Downloading regex-2023.12.25-cp311-cp311-macosx_11_0_arm64.whl.metadata (40 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m40.9/40.9 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hCollecting tokenizers<0.19,>=0.14 (from transformers->airllm)\n",+ " Downloading tokenizers-0.15.0-cp311-cp311-macosx_11_0_arm64.whl.metadata (6.7 kB)\n",+ "Collecting sentencepiece!=0.1.92,>=0.1.91 (from transformers[sentencepiece]>=4.26.0->optimum->airllm)\n",+ " Downloading sentencepiece-0.1.99-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hCollecting protobuf (from transformers[sentencepiece]>=4.26.0->optimum->airllm)\n",+ " Downloading protobuf-4.25.1-cp37-abi3-macosx_10_9_universal2.whl.metadata (541 bytes)\n",+ "Collecting humanfriendly>=9.1 (from coloredlogs->optimum->airllm)\n",+ " Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hCollecting pyarrow>=8.0.0 (from datasets->optimum->airllm)\n",+ " Downloading pyarrow-14.0.2-cp311-cp311-macosx_11_0_arm64.whl.metadata (3.0 kB)\n",+ "Collecting pyarrow-hotfix (from datasets->optimum->airllm)\n",+ " Downloading pyarrow_hotfix-0.6-py3-none-any.whl.metadata (3.6 kB)\n",+ "Collecting dill<0.3.8,>=0.3.0 (from datasets->optimum->airllm)\n",+ " Downloading dill-0.3.7-py3-none-any.whl.metadata (9.9 kB)\n",+ "Collecting pandas (from datasets->optimum->airllm)\n",+ " Downloading pandas-2.1.4-cp311-cp311-macosx_11_0_arm64.whl.metadata (18 kB)\n",+ "Collecting xxhash (from datasets->optimum->airllm)\n",+ " Downloading xxhash-3.4.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (12 kB)\n",+ "Collecting multiprocess (from datasets->optimum->airllm)\n",+ " Downloading multiprocess-0.70.15-py311-none-any.whl.metadata (7.2 kB)\n",+ "Collecting aiohttp (from datasets->optimum->airllm)\n",+ " Downloading aiohttp-3.9.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (7.4 kB)\n",+ "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (3.3.2)\n",+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (3.6)\n",+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (2.1.0)\n",+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (2023.11.17)\n",+ "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from jinja2->torch->airllm) (2.1.1)\n",+ "Requirement already satisfied: mpmath>=0.19 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from sympy->torch->airllm) (1.3.0)\n",+ "Requirement already satisfied: attrs>=17.3.0 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from aiohttp->datasets->optimum->airllm) (23.1.0)\n",+ "Collecting multidict<7.0,>=4.5 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading multidict-6.0.4-cp311-cp311-macosx_11_0_arm64.whl (29 kB)\n",+ "Collecting yarl<2.0,>=1.0 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading yarl-1.9.4-cp311-cp311-macosx_11_0_arm64.whl.metadata (31 kB)\n",+ "Collecting frozenlist>=1.1.1 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading frozenlist-1.4.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (12 kB)\n",+ "Collecting aiosignal>=1.1.2 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)\n",+ "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from pandas->datasets->optimum->airllm) (2.8.2)\n",+ "Requirement already satisfied: pytz>=2020.1 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from pandas->datasets->optimum->airllm) (2023.3.post1)\n",+ "Collecting tzdata>=2022.1 (from pandas->datasets->optimum->airllm)\n",+ " Using cached tzdata-2023.3-py2.py3-none-any.whl (341 kB)\n",+ "Requirement already satisfied: six>=1.5 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas->datasets->optimum->airllm) (1.16.0)\n",+ "Using cached airllm-2.7-py3-none-any.whl (34 kB)\n",+ "Downloading accelerate-0.25.0-py3-none-any.whl (265 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m265.7/265.7 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading safetensors-0.4.1-cp311-cp311-macosx_11_0_arm64.whl (426 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m426.3/426.3 kB\u001b[0m \u001b[31m9.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hUsing cached huggingface_hub-0.20.1-py3-none-any.whl (330 kB)\n",+ "Using cached tqdm-4.66.1-py3-none-any.whl (78 kB)\n",+ "Downloading optimum-1.16.1-py3-none-any.whl (403 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m403.3/403.3 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hUsing cached transformers-4.36.2-py3-none-any.whl (8.2 MB)\n",+ "Downloading scipy-1.11.4-cp311-cp311-macosx_12_0_arm64.whl (29.7 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m29.7/29.7 MB\u001b[0m \u001b[31m13.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading regex-2023.12.25-cp311-cp311-macosx_11_0_arm64.whl (291 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m291.0/291.0 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading tokenizers-0.15.0-cp311-cp311-macosx_11_0_arm64.whl (2.5 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.5/2.5 MB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hDownloading datasets-2.16.0-py3-none-any.whl (507 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m507.1/507.1 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hDownloading dill-0.3.7-py3-none-any.whl (115 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m115.3/115.3 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading aiohttp-3.9.1-cp311-cp311-macosx_11_0_arm64.whl (386 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m386.8/386.8 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading pyarrow-14.0.2-cp311-cp311-macosx_11_0_arm64.whl (24.0 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.0/24.0 MB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading multiprocess-0.70.15-py311-none-any.whl (135 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m135.4/135.4 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading pandas-2.1.4-cp311-cp311-macosx_11_0_arm64.whl (10.8 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.8/10.8 MB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading protobuf-4.25.1-cp37-abi3-macosx_10_9_universal2.whl (394 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m394.2/394.2 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading pyarrow_hotfix-0.6-py3-none-any.whl (7.9 kB)\n",+ "Downloading xxhash-3.4.1-cp311-cp311-macosx_11_0_arm64.whl (30 kB)\n",+ "Downloading frozenlist-1.4.1-cp311-cp311-macosx_11_0_arm64.whl (53 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.4/53.4 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading yarl-1.9.4-cp311-cp311-macosx_11_0_arm64.whl (81 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m81.2/81.2 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hInstalling collected packages: sentencepiece, xxhash, tzdata, tqdm, scipy, safetensors, regex, pyarrow-hotfix, pyarrow, protobuf, multidict, humanfriendly, frozenlist, dill, yarl, pandas, multiprocess, huggingface-hub, coloredlogs, aiosignal, tokenizers, aiohttp, accelerate, transformers, datasets, optimum, airllm\n",+ "Successfully installed accelerate-0.25.0 aiohttp-3.9.1 aiosignal-1.3.1 airllm-2.7 coloredlogs-15.0.1 datasets-2.16.0 dill-0.3.7 frozenlist-1.4.1 huggingface-hub-0.20.1 humanfriendly-10.0 multidict-6.0.4 multiprocess-0.70.15 optimum-1.16.1 pandas-2.1.4 protobuf-4.25.1 pyarrow-14.0.2 pyarrow-hotfix-0.6 regex-2023.12.25 safetensors-0.4.1 scipy-1.11.4 sentencepiece-0.1.99 tokenizers-0.15.0 tqdm-4.66.1 transformers-4.36.2 tzdata-2023.3 xxhash-3.4.1 yarl-1.9.4\n"+ ]+ }+ ],+ "source": [+ "!pip install -U airllm"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "!pip install transformers"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "!conda install pytorch -c pytorch\n"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "!conda install -y sentencepiece"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 1,+ "metadata": {},+ "outputs": [],+ "source": [+ "# copy local code to test\n",+ "!cp -r /Users/l_y_o/Work/Anima/air_llm/airllm/* /usr/local/anaconda3/envs/native/lib/python3.11/site-packages/airllm/"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# test airllm mlx"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 2,+ "metadata": {},+ "outputs": [],+ "source": [+ "from airllm import AirLLMLlamaMlx"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 3,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "bc02b05b26854198b6bd124287f74bf7",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 1 files: 0%| | 0/1 [00:00<?, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "945203eb3eb34d48aa80fbf9bff634dd",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 18 files: 0%| | 0/18 [00:00<?, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "667380fd90e74fde8e17a69d7f97a012",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.json: 0%| | 0.00/3.56M [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "f193778a98354093993a4fea300c5f82",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer_config.json: 0%| | 0.00/320 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "91ed61f306cb4b84a10d32f92235800a",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "model-00003-of-00007.safetensors: 0%| | 0.00/9.75G [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "601451d9a6484f9795ef93ea1d07ccc7",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.model: 0%| | 0.00/1.03M [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 0%| | 0/63 [00:00<?, ?it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Loading shard 1/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 2%|██▉ | 1/63 [00:01<02:00, 1.94s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.embed_tokens.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 3%|█████▊ | 2/63 [00:04<02:04, 2.04s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.0.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 5%|████████▋ | 3/63 [00:06<02:05, 2.09s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.1.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 6%|███████████▌ | 4/63 [00:08<02:01, 2.06s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.2.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 8%|██████████████▌ | 5/63 [00:10<01:55, 2.00s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.3.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 10%|█████████████████▍ | 6/63 [00:12<02:01, 2.13s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.4.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 11%|████████████████████▎ | 7/63 [00:15<02:08, 2.30s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.5.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 13%|███████████████████████▏ | 8/63 [00:17<02:10, 2.38s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.6.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 14%|██████████████████████████▏ | 9/63 [00:20<02:12, 2.45s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.7.mlx\n",+ "Loading shard 2/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 16%|████████████████████████████▉ | 10/63 [00:22<02:05, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.8.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 17%|███████████████████████████████▊ | 11/63 [00:24<02:02, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.9.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 19%|██████████████████████████████████▋ | 12/63 [00:27<01:59, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.10.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 21%|█████████████████████████████████████▌ | 13/63 [00:29<01:55, 2.32s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.11.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 22%|████████████████████████████████████████▍ | 14/63 [00:31<01:51, 2.28s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.12.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 24%|███████████████████████████████████████████▎ | 15/63 [00:34<01:53, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.13.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 25%|██████████████████████████████████████████████▏ | 16/63 [00:36<01:52, 2.40s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.14.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 27%|█████████████████████████████████████████████████ | 17/63 [00:39<01:50, 2.41s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.15.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 29%|████████████████████████████████████████████████████ | 18/63 [00:41<01:51, 2.47s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.16.mlx\n",+ "Loading shard 3/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 30%|██████████████████████████████████████████████████████▉ | 19/63 [00:43<01:46, 2.42s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.17.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 32%|█████████████████████████████████████████████████████████▊ | 20/63 [00:46<01:41, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.18.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 33%|████████████████████████████████████████████████████████████▋ | 21/63 [00:48<01:35, 2.27s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.19.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 35%|███████████████████████████████████████████████████████████████▌ | 22/63 [00:50<01:33, 2.29s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.20.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 37%|██████████████████████████████████████████████████████████████████▍ | 23/63 [00:52<01:29, 2.25s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.21.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 38%|█████████████████████████████████████████████████████████████████████▎ | 24/63 [00:54<01:25, 2.20s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.22.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 40%|████████████████████████████████████████████████████████████████████████▏ | 25/63 [00:57<01:24, 2.21s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.23.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 41%|███████████████████████████████████████████████████████████████████████████ | 26/63 [00:59<01:20, 2.18s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.24.mlx\n",+ "Loading shard 4/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 43%|██████████████████████████████████████████████████████████████████████████████ | 27/63 [01:01<01:22, 2.28s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.25.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 44%|████████████████████████████████████████████████████████████████████████████████▉ | 28/63 [01:04<01:20, 2.29s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.26.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 46%|███████████████████████████████████████████████████████████████████████████████████▊ | 29/63 [01:06<01:15, 2.23s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.27.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 48%|██████████████████████████████████████████████████████████████████████████████████████▋ | 30/63 [01:08<01:14, 2.26s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.28.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 49%|█████████████████████████████████████████████████████████████████████████████████████████▌ | 31/63 [01:10<01:11, 2.25s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.29.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 51%|████████████████████████████████████████████████████████████████████████████████████████████▍ | 32/63 [01:12<01:08, 2.21s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.30.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 52%|███████████████████████████████████████████████████████████████████████████████████████████████▎ | 33/63 [01:15<01:07, 2.24s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.31.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 54%|██████████████████████████████████████████████████████████████████████████████████████████████████▏ | 34/63 [01:17<01:08, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.32.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 56%|█████████████████████████████████████████████████████████████████████████████████████████████████████ | 35/63 [01:20<01:09, 2.48s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.33.mlx\n",+ "Loading shard 5/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 57%|████████████████████████████████████████████████████████████████████████████████████████████████████████ | 36/63 [01:22<01:03, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.34.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 59%|██████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 37/63 [01:24<00:59, 2.28s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.35.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 60%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 38/63 [01:27<00:57, 2.31s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.36.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 62%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 39/63 [01:29<00:56, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.37.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 63%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 40/63 [01:32<00:55, 2.42s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.38.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 65%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 41/63 [01:34<00:53, 2.45s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.39.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 67%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎ | 42/63 [01:36<00:50, 2.38s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.40.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 68%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 43/63 [01:39<00:48, 2.41s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.41.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 70%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 44/63 [01:41<00:46, 2.45s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.42.mlx\n",+ "Loading shard 6/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 71%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 45/63 [01:44<00:44, 2.48s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.43.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 73%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 46/63 [01:46<00:41, 2.46s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.44.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 75%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 47/63 [01:49<00:39, 2.47s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.45.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 76%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 48/63 [01:51<00:35, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.46.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 78%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 49/63 [01:53<00:32, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.47.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 79%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 50/63 [01:56<00:30, 2.38s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.48.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 81%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎ | 51/63 [01:58<00:29, 2.42s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.49.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 83%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 52/63 [02:01<00:27, 2.51s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.50.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 84%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 53/63 [02:04<00:25, 2.56s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.51.mlx\n",+ "Loading shard 7/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 86%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 54/63 [02:06<00:22, 2.50s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.52.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 87%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 55/63 [02:08<00:19, 2.43s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.53.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 89%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 56/63 [02:11<00:17, 2.44s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.54.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 90%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 57/63 [02:13<00:15, 2.51s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.55.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 92%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 58/63 [02:16<00:13, 2.61s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.56.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 94%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 59/63 [02:19<00:10, 2.72s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.57.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 95%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎ | 60/63 [02:23<00:09, 3.17s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.58.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 97%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 61/63 [02:41<00:15, 7.60s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.59.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.norm.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 63/63 [02:45<00:00, 2.62s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/lm_head.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "\n"+ ]+ }+ ],+ "source": [+ "model = AirLLMLlamaMlx(\"01-ai/Yi-34B\")#\"garage-bAInd/Platypus2-7B\")"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 4,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "text/plain": [+ "{'input_ids': array([[59597, 947]])}"+ ]+ },+ "execution_count": 4,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],+ "source": [+ "input_text = [\n",+ " #'What is the capital of United States?',\n",+ " 'I like',\n",+ " ]\n",+ "\n",+ "MAX_LENGTH = 128\n",+ "input_tokens = model.tokenizer(input_text,\n",+ " return_tensors=\"np\", \n",+ " return_attention_mask=False, \n",+ " truncation=True, \n",+ " max_length=MAX_LENGTH, \n",+ " padding=False)\n",+ "\n",+ "input_tokens"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 5,+ "metadata": {},+ "outputs": [+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:53<00:00, 1.12it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:55<00:00, 1.09it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:53<00:00, 1.12it/s]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ " to think that\n"+ ]+ }+ ],+ "source": [+ "\n",+ "import mlx.core as mx\n",+ "generation_output = model.generate(\n",+ " mx.array(input_tokens['input_ids']), \n",+ " max_new_tokens=3,\n",+ " use_cache=True,\n",+ " return_dict_in_generate=True)\n",+ "\n",+ "print(generation_output)"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# test Platypus2 7b"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 1,+ "metadata": {},+ "outputs": [],+ "source": [+ "from airllm import AirLLMLlamaMlx"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 2,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "ac9bc7f5f7cb4e98b8913cc533bf6d5c",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 0 files: 0it [00:00, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "474ae14c2f7b4c759f53393d13daa86f",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 12 files: 0%| | 0/12 [00:00<?, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "26ef8712234d42498ffbdee1ed17514a",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ ".gitattributes: 0%| | 0.00/1.52k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "2e48bcc168514e01a320e4f200390cf5",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "pytorch_model.bin.index.json: 0%| | 0.00/26.8k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "bf6bc64a7441489a90501915a8b910c2",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Best_Platty_small.jpeg: 0%| | 0.00/7.35k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "88bc6a86ebff4c1a8031411a1465abb8",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "generation_config.json: 0%| | 0.00/132 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "6281737965004d0698a80bfaac8c518e",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "config.json: 0%| | 0.00/625 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "3dd2a5971b664179911aecf465bc5181",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "README.md: 0%| | 0.00/5.23k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "f334509f6e83496587b4b79319c07795",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer_config.json: 0%| | 0.00/725 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "e2066e8b954d4611bef220a5c61fe0d3",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.json: 0%| | 0.00/1.84M [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "3e63b3ef1601494e8fd537613119bf3e",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "special_tokens_map.json: 0%| | 0.00/414 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "84f6ff70472946e5828a6376dd60cdbe",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "pytorch_model-00002-of-00002.bin: 0%| | 0.00/3.50G [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "a5ded99432254e8781d2e3ebef09c597",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "pytorch_model-00001-of-00002.bin: 0%| | 0.00/9.98G [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "4f65c2c1cc094b4f80dace069698503f",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.model: 0%| | 0.00/500k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 0%| | 0/35 [00:00<?, ?it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Loading shard 1/2\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.embed_tokens.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 6%|██████████▍ | 2/35 [00:10<02:27, 4.46s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.0.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 9%|███████████████▋ | 3/35 [00:12<01:47, 3.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.1.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 11%|████████████████████▉ | 4/35 [00:13<01:23, 2.71s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.2.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 14%|██████████████████████████▏ | 5/35 [00:15<01:09, 2.31s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.3.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 17%|███████████████████████████████▎ | 6/35 [00:17<01:02, 2.14s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.4.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 20%|████████████████████████████████████▌ | 7/35 [00:17<00:42, 1.52s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.5.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 23%|█████████████████████████████████████████▊ | 8/35 [00:17<00:30, 1.12s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.6.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 26%|███████████████████████████████████████████████ | 9/35 [00:17<00:21, 1.19it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.7.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 29%|████████████████████████████████████████████████████ | 10/35 [00:18<00:16, 1.51it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.8.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 31%|█████████████████████████████████████████████████████████▏ | 11/35 [00:18<00:13, 1.80it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.9.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 34%|██████████████████████████████████████████████████████████████▍ | 12/35 [00:18<00:11, 2.00it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.10.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 37%|███████████████████████████████████████████████████████████████████▌ | 13/35 [00:19<00:09, 2.23it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.11.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 40%|████████████████████████████████████████████████████████████████████████▊ | 14/35 [00:19<00:08, 2.50it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.12.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 43%|██████████████████████████████████████████████████████████████████████████████ | 15/35 [00:19<00:07, 2.80it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.13.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 46%|███████████████████████████████████████████████████████████████████████████████████▏ | 16/35 [00:20<00:06, 3.00it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.14.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 49%|████████████████████████████████████████████████████████████████████████████████████████▍ | 17/35 [00:20<00:06, 2.76it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.15.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 51%|█████████████████████████████████████████████████████████████████████████████████████████████▌ | 18/35 [00:20<00:06, 2.65it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.16.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 54%|██████████████████████████████████████████████████████████████████████████████████████████████████▊ | 19/35 [00:21<00:06, 2.61it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.17.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 57%|████████████████████████████████████████████████████████████████████████████████████████████████████████ | 20/35 [00:21<00:05, 2.60it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.18.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 60%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 21/35 [00:22<00:05, 2.63it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.19.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 63%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 22/35 [00:22<00:04, 2.71it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.20.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 66%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 23/35 [00:22<00:04, 2.73it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.21.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 69%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 24/35 [00:23<00:03, 2.79it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.22.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 71%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 25/35 [00:23<00:03, 2.83it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.23.mlx\n",+ "Loading shard 2/2\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 74%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 26/35 [00:24<00:05, 1.68it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.24.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 77%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 27/35 [00:24<00:04, 2.00it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.25.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 28/35 [00:25<00:02, 2.34it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.26.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.27.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 86%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 30/35 [00:25<00:01, 3.36it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.28.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.29.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 91%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 32/35 [00:25<00:00, 4.12it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.30.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 94%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 33/35 [00:26<00:00, 4.33it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.31.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.norm.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 35/35 [00:26<00:00, 1.33it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/lm_head.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "\n"+ ]+ }+ ],+ "source": [+ "model = AirLLMLlamaMlx(\"garage-bAInd/Platypus2-7B\")"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "code",+ "execution_count": 3,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "text/plain": [+ "{'input_ids': array([[ 1, 306, 763]])}"+ ]+ },+ "execution_count": 3,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],+ "source": [+ "input_text = [\n",+ " #'What is the capital of United States?',\n",+ " 'I like',\n",+ " ]\n",+ "\n",+ "MAX_LENGTH = 128\n",+ "input_tokens = model.tokenizer(input_text,\n",+ " return_tensors=\"np\", \n",+ " return_attention_mask=False, \n",+ " truncation=True, \n",+ " max_length=MAX_LENGTH, \n",+ " padding=False)\n",+ "\n",+ "input_tokens"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 4,+ "metadata": {},+ "outputs": [+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:07<00:00, 4.43it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:06<00:00, 4.77it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:07<00:00, 4.50it/s]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "to think of\n"+ ]+ }+ ],+ "source": [+ "\n",+ "import mlx.core as mx\n",+ "generation_output = model.generate(\n",+ " mx.array(input_tokens['input_ids']), \n",+ " max_new_tokens=3,\n",+ " use_cache=True,\n",+ " return_dict_in_generate=True)\n",+ "\n",+ "print(generation_output)"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "Python 3 (ipykernel)",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.11.5"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 4+}diff --git a/air_llm/setup.py b/air_llm/setup.pyindex 9d846f1..329cfe6 100644--- a/air_llm/setup.py+++ b/air_llm/setup.py@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:setuptools.setup(name="airllm",- version="2.7",+ version="2.8",author="Gavin Li",author_email="[email protected]",description="AirLLM allows single 4GB GPU card to run 70B large language models without quantization, distillation or pruning.",diff --git a/air_llm/tests/test_notebooks/test_mlx.ipynb b/air_llm/tests/test_notebooks/test_mlx.ipynbnew file mode 100644index 0000000..a348417--- /dev/null+++ b/air_llm/tests/test_notebooks/test_mlx.ipynb@@ -0,0 +1,2091 @@+{+ "cells": [+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# example of airllm on mac os"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "from sys import platform\n",+ "\n",+ "assert platform == \"darwin\", \"this example is supposed to be run on mac os\"\n"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# install airllm"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 1,+ "metadata": {+ "collapsed": true,+ "jupyter": {+ "outputs_hidden": true+ }+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Collecting airllm\n",+ " Using cached airllm-2.7-py3-none-any.whl.metadata (13 kB)\n",+ "Collecting tqdm (from airllm)\n",+ " Using cached tqdm-4.66.1-py3-none-any.whl.metadata (57 kB)\n",+ "Requirement already satisfied: torch in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from airllm) (2.1.0)\n",+ "Collecting transformers (from airllm)\n",+ " Using cached transformers-4.36.2-py3-none-any.whl.metadata (126 kB)\n",+ "Collecting accelerate (from airllm)\n",+ " Downloading accelerate-0.25.0-py3-none-any.whl.metadata (18 kB)\n",+ "Collecting safetensors (from airllm)\n",+ " Downloading safetensors-0.4.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (3.8 kB)\n",+ "Collecting optimum (from airllm)\n",+ " Downloading optimum-1.16.1-py3-none-any.whl.metadata (17 kB)\n",+ "Collecting huggingface-hub (from airllm)\n",+ " Using cached huggingface_hub-0.20.1-py3-none-any.whl.metadata (12 kB)\n",+ "Collecting scipy (from airllm)\n",+ " Downloading scipy-1.11.4-cp311-cp311-macosx_12_0_arm64.whl.metadata (165 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m165.4/165.4 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hRequirement already satisfied: numpy>=1.17 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (1.26.2)\n",+ "Requirement already satisfied: packaging>=20.0 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (23.2)\n",+ "Requirement already satisfied: psutil in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (5.9.0)\n",+ "Requirement already satisfied: pyyaml in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from accelerate->airllm) (6.0.1)\n",+ "Requirement already satisfied: filelock in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (3.13.1)\n",+ "Requirement already satisfied: typing-extensions in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (4.7.1)\n",+ "Requirement already satisfied: sympy in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (1.12)\n",+ "Requirement already satisfied: networkx in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (3.1)\n",+ "Requirement already satisfied: jinja2 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (3.1.2)\n",+ "Requirement already satisfied: fsspec in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from torch->airllm) (2023.10.0)\n",+ "Requirement already satisfied: requests in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from huggingface-hub->airllm) (2.31.0)\n",+ "Collecting coloredlogs (from optimum->airllm)\n",+ " Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hCollecting datasets (from optimum->airllm)\n",+ " Downloading datasets-2.16.0-py3-none-any.whl.metadata (20 kB)\n",+ "Collecting regex!=2019.12.17 (from transformers->airllm)\n",+ " Downloading regex-2023.12.25-cp311-cp311-macosx_11_0_arm64.whl.metadata (40 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m40.9/40.9 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hCollecting tokenizers<0.19,>=0.14 (from transformers->airllm)\n",+ " Downloading tokenizers-0.15.0-cp311-cp311-macosx_11_0_arm64.whl.metadata (6.7 kB)\n",+ "Collecting sentencepiece!=0.1.92,>=0.1.91 (from transformers[sentencepiece]>=4.26.0->optimum->airllm)\n",+ " Downloading sentencepiece-0.1.99-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hCollecting protobuf (from transformers[sentencepiece]>=4.26.0->optimum->airllm)\n",+ " Downloading protobuf-4.25.1-cp37-abi3-macosx_10_9_universal2.whl.metadata (541 bytes)\n",+ "Collecting humanfriendly>=9.1 (from coloredlogs->optimum->airllm)\n",+ " Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hCollecting pyarrow>=8.0.0 (from datasets->optimum->airllm)\n",+ " Downloading pyarrow-14.0.2-cp311-cp311-macosx_11_0_arm64.whl.metadata (3.0 kB)\n",+ "Collecting pyarrow-hotfix (from datasets->optimum->airllm)\n",+ " Downloading pyarrow_hotfix-0.6-py3-none-any.whl.metadata (3.6 kB)\n",+ "Collecting dill<0.3.8,>=0.3.0 (from datasets->optimum->airllm)\n",+ " Downloading dill-0.3.7-py3-none-any.whl.metadata (9.9 kB)\n",+ "Collecting pandas (from datasets->optimum->airllm)\n",+ " Downloading pandas-2.1.4-cp311-cp311-macosx_11_0_arm64.whl.metadata (18 kB)\n",+ "Collecting xxhash (from datasets->optimum->airllm)\n",+ " Downloading xxhash-3.4.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (12 kB)\n",+ "Collecting multiprocess (from datasets->optimum->airllm)\n",+ " Downloading multiprocess-0.70.15-py311-none-any.whl.metadata (7.2 kB)\n",+ "Collecting aiohttp (from datasets->optimum->airllm)\n",+ " Downloading aiohttp-3.9.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (7.4 kB)\n",+ "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (3.3.2)\n",+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (3.6)\n",+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (2.1.0)\n",+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from requests->huggingface-hub->airllm) (2023.11.17)\n",+ "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from jinja2->torch->airllm) (2.1.1)\n",+ "Requirement already satisfied: mpmath>=0.19 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from sympy->torch->airllm) (1.3.0)\n",+ "Requirement already satisfied: attrs>=17.3.0 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from aiohttp->datasets->optimum->airllm) (23.1.0)\n",+ "Collecting multidict<7.0,>=4.5 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading multidict-6.0.4-cp311-cp311-macosx_11_0_arm64.whl (29 kB)\n",+ "Collecting yarl<2.0,>=1.0 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading yarl-1.9.4-cp311-cp311-macosx_11_0_arm64.whl.metadata (31 kB)\n",+ "Collecting frozenlist>=1.1.1 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading frozenlist-1.4.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (12 kB)\n",+ "Collecting aiosignal>=1.1.2 (from aiohttp->datasets->optimum->airllm)\n",+ " Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)\n",+ "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from pandas->datasets->optimum->airllm) (2.8.2)\n",+ "Requirement already satisfied: pytz>=2020.1 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from pandas->datasets->optimum->airllm) (2023.3.post1)\n",+ "Collecting tzdata>=2022.1 (from pandas->datasets->optimum->airllm)\n",+ " Using cached tzdata-2023.3-py2.py3-none-any.whl (341 kB)\n",+ "Requirement already satisfied: six>=1.5 in /usr/local/anaconda3/envs/native/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas->datasets->optimum->airllm) (1.16.0)\n",+ "Using cached airllm-2.7-py3-none-any.whl (34 kB)\n",+ "Downloading accelerate-0.25.0-py3-none-any.whl (265 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m265.7/265.7 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading safetensors-0.4.1-cp311-cp311-macosx_11_0_arm64.whl (426 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m426.3/426.3 kB\u001b[0m \u001b[31m9.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hUsing cached huggingface_hub-0.20.1-py3-none-any.whl (330 kB)\n",+ "Using cached tqdm-4.66.1-py3-none-any.whl (78 kB)\n",+ "Downloading optimum-1.16.1-py3-none-any.whl (403 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m403.3/403.3 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hUsing cached transformers-4.36.2-py3-none-any.whl (8.2 MB)\n",+ "Downloading scipy-1.11.4-cp311-cp311-macosx_12_0_arm64.whl (29.7 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m29.7/29.7 MB\u001b[0m \u001b[31m13.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading regex-2023.12.25-cp311-cp311-macosx_11_0_arm64.whl (291 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m291.0/291.0 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading tokenizers-0.15.0-cp311-cp311-macosx_11_0_arm64.whl (2.5 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.5/2.5 MB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hDownloading datasets-2.16.0-py3-none-any.whl (507 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m507.1/507.1 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mta \u001b[36m0:00:01\u001b[0m\n",+ "\u001b[?25hDownloading dill-0.3.7-py3-none-any.whl (115 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m115.3/115.3 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading aiohttp-3.9.1-cp311-cp311-macosx_11_0_arm64.whl (386 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m386.8/386.8 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading pyarrow-14.0.2-cp311-cp311-macosx_11_0_arm64.whl (24.0 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.0/24.0 MB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading multiprocess-0.70.15-py311-none-any.whl (135 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m135.4/135.4 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading pandas-2.1.4-cp311-cp311-macosx_11_0_arm64.whl (10.8 MB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.8/10.8 MB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading protobuf-4.25.1-cp37-abi3-macosx_10_9_universal2.whl (394 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m394.2/394.2 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",+ "\u001b[?25hDownloading pyarrow_hotfix-0.6-py3-none-any.whl (7.9 kB)\n",+ "Downloading xxhash-3.4.1-cp311-cp311-macosx_11_0_arm64.whl (30 kB)\n",+ "Downloading frozenlist-1.4.1-cp311-cp311-macosx_11_0_arm64.whl (53 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.4/53.4 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hDownloading yarl-1.9.4-cp311-cp311-macosx_11_0_arm64.whl (81 kB)\n",+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m81.2/81.2 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",+ "\u001b[?25hInstalling collected packages: sentencepiece, xxhash, tzdata, tqdm, scipy, safetensors, regex, pyarrow-hotfix, pyarrow, protobuf, multidict, humanfriendly, frozenlist, dill, yarl, pandas, multiprocess, huggingface-hub, coloredlogs, aiosignal, tokenizers, aiohttp, accelerate, transformers, datasets, optimum, airllm\n",+ "Successfully installed accelerate-0.25.0 aiohttp-3.9.1 aiosignal-1.3.1 airllm-2.7 coloredlogs-15.0.1 datasets-2.16.0 dill-0.3.7 frozenlist-1.4.1 huggingface-hub-0.20.1 humanfriendly-10.0 multidict-6.0.4 multiprocess-0.70.15 optimum-1.16.1 pandas-2.1.4 protobuf-4.25.1 pyarrow-14.0.2 pyarrow-hotfix-0.6 regex-2023.12.25 safetensors-0.4.1 scipy-1.11.4 sentencepiece-0.1.99 tokenizers-0.15.0 tqdm-4.66.1 transformers-4.36.2 tzdata-2023.3 xxhash-3.4.1 yarl-1.9.4\n"+ ]+ }+ ],+ "source": [+ "!pip install -U airllm"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "!pip install transformers"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "!conda install pytorch -c pytorch\n"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "!conda install -y sentencepiece"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 1,+ "metadata": {},+ "outputs": [],+ "source": [+ "# copy local code to test\n",+ "!cp -r /Users/l_y_o/Work/Anima/air_llm/airllm/* /usr/local/anaconda3/envs/native/lib/python3.11/site-packages/airllm/"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# test airllm mlx"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 2,+ "metadata": {},+ "outputs": [],+ "source": [+ "from airllm import AirLLMLlamaMlx"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 3,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "bc02b05b26854198b6bd124287f74bf7",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 1 files: 0%| | 0/1 [00:00<?, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "945203eb3eb34d48aa80fbf9bff634dd",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 18 files: 0%| | 0/18 [00:00<?, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "667380fd90e74fde8e17a69d7f97a012",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.json: 0%| | 0.00/3.56M [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "f193778a98354093993a4fea300c5f82",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer_config.json: 0%| | 0.00/320 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "91ed61f306cb4b84a10d32f92235800a",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "model-00003-of-00007.safetensors: 0%| | 0.00/9.75G [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "601451d9a6484f9795ef93ea1d07ccc7",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.model: 0%| | 0.00/1.03M [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 0%| | 0/63 [00:00<?, ?it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Loading shard 1/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 2%|██▉ | 1/63 [00:01<02:00, 1.94s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.embed_tokens.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 3%|█████▊ | 2/63 [00:04<02:04, 2.04s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.0.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 5%|████████▋ | 3/63 [00:06<02:05, 2.09s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.1.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 6%|███████████▌ | 4/63 [00:08<02:01, 2.06s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.2.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 8%|██████████████▌ | 5/63 [00:10<01:55, 2.00s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.3.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 10%|█████████████████▍ | 6/63 [00:12<02:01, 2.13s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.4.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 11%|████████████████████▎ | 7/63 [00:15<02:08, 2.30s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.5.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 13%|███████████████████████▏ | 8/63 [00:17<02:10, 2.38s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.6.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 14%|██████████████████████████▏ | 9/63 [00:20<02:12, 2.45s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.7.mlx\n",+ "Loading shard 2/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 16%|████████████████████████████▉ | 10/63 [00:22<02:05, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.8.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 17%|███████████████████████████████▊ | 11/63 [00:24<02:02, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.9.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 19%|██████████████████████████████████▋ | 12/63 [00:27<01:59, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.10.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 21%|█████████████████████████████████████▌ | 13/63 [00:29<01:55, 2.32s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.11.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 22%|████████████████████████████████████████▍ | 14/63 [00:31<01:51, 2.28s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.12.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 24%|███████████████████████████████████████████▎ | 15/63 [00:34<01:53, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.13.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 25%|██████████████████████████████████████████████▏ | 16/63 [00:36<01:52, 2.40s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.14.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 27%|█████████████████████████████████████████████████ | 17/63 [00:39<01:50, 2.41s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.15.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 29%|████████████████████████████████████████████████████ | 18/63 [00:41<01:51, 2.47s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.16.mlx\n",+ "Loading shard 3/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 30%|██████████████████████████████████████████████████████▉ | 19/63 [00:43<01:46, 2.42s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.17.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 32%|█████████████████████████████████████████████████████████▊ | 20/63 [00:46<01:41, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.18.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 33%|████████████████████████████████████████████████████████████▋ | 21/63 [00:48<01:35, 2.27s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.19.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 35%|███████████████████████████████████████████████████████████████▌ | 22/63 [00:50<01:33, 2.29s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.20.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 37%|██████████████████████████████████████████████████████████████████▍ | 23/63 [00:52<01:29, 2.25s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.21.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 38%|█████████████████████████████████████████████████████████████████████▎ | 24/63 [00:54<01:25, 2.20s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.22.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 40%|████████████████████████████████████████████████████████████████████████▏ | 25/63 [00:57<01:24, 2.21s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.23.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 41%|███████████████████████████████████████████████████████████████████████████ | 26/63 [00:59<01:20, 2.18s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.24.mlx\n",+ "Loading shard 4/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 43%|██████████████████████████████████████████████████████████████████████████████ | 27/63 [01:01<01:22, 2.28s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.25.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 44%|████████████████████████████████████████████████████████████████████████████████▉ | 28/63 [01:04<01:20, 2.29s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.26.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 46%|███████████████████████████████████████████████████████████████████████████████████▊ | 29/63 [01:06<01:15, 2.23s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.27.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 48%|██████████████████████████████████████████████████████████████████████████████████████▋ | 30/63 [01:08<01:14, 2.26s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.28.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 49%|█████████████████████████████████████████████████████████████████████████████████████████▌ | 31/63 [01:10<01:11, 2.25s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.29.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 51%|████████████████████████████████████████████████████████████████████████████████████████████▍ | 32/63 [01:12<01:08, 2.21s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.30.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 52%|███████████████████████████████████████████████████████████████████████████████████████████████▎ | 33/63 [01:15<01:07, 2.24s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.31.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 54%|██████████████████████████████████████████████████████████████████████████████████████████████████▏ | 34/63 [01:17<01:08, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.32.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 56%|█████████████████████████████████████████████████████████████████████████████████████████████████████ | 35/63 [01:20<01:09, 2.48s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.33.mlx\n",+ "Loading shard 5/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 57%|████████████████████████████████████████████████████████████████████████████████████████████████████████ | 36/63 [01:22<01:03, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.34.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 59%|██████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 37/63 [01:24<00:59, 2.28s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.35.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 60%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 38/63 [01:27<00:57, 2.31s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.36.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 62%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 39/63 [01:29<00:56, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.37.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 63%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 40/63 [01:32<00:55, 2.42s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.38.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 65%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 41/63 [01:34<00:53, 2.45s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.39.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 67%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎ | 42/63 [01:36<00:50, 2.38s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.40.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 68%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 43/63 [01:39<00:48, 2.41s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.41.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 70%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 44/63 [01:41<00:46, 2.45s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.42.mlx\n",+ "Loading shard 6/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 71%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 45/63 [01:44<00:44, 2.48s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.43.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 73%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 46/63 [01:46<00:41, 2.46s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.44.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 75%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 47/63 [01:49<00:39, 2.47s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.45.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 76%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 48/63 [01:51<00:35, 2.37s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.46.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 78%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 49/63 [01:53<00:32, 2.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.47.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 79%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 50/63 [01:56<00:30, 2.38s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.48.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 81%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎ | 51/63 [01:58<00:29, 2.42s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.49.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 83%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 52/63 [02:01<00:27, 2.51s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.50.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 84%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 53/63 [02:04<00:25, 2.56s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.51.mlx\n",+ "Loading shard 7/7\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 86%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 54/63 [02:06<00:22, 2.50s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.52.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 87%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 55/63 [02:08<00:19, 2.43s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.53.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 89%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 56/63 [02:11<00:17, 2.44s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.54.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 90%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 57/63 [02:13<00:15, 2.51s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.55.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 92%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 58/63 [02:16<00:13, 2.61s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.56.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 94%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 59/63 [02:19<00:10, 2.72s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.57.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 95%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎ | 60/63 [02:23<00:09, 3.17s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.58.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 97%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 61/63 [02:41<00:15, 7.60s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.layers.59.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/model.norm.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 63/63 [02:45<00:00, 2.62s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--01-ai--Yi-34B/snapshots/9292541b776cae9f25cf40e14764dcffc12c8999/splitted_model/lm_head.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "\n"+ ]+ }+ ],+ "source": [+ "model = AirLLMLlamaMlx(\"01-ai/Yi-34B\")#\"garage-bAInd/Platypus2-7B\")"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 4,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "text/plain": [+ "{'input_ids': array([[59597, 947]])}"+ ]+ },+ "execution_count": 4,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],+ "source": [+ "input_text = [\n",+ " #'What is the capital of United States?',\n",+ " 'I like',\n",+ " ]\n",+ "\n",+ "MAX_LENGTH = 128\n",+ "input_tokens = model.tokenizer(input_text,\n",+ " return_tensors=\"np\", \n",+ " return_attention_mask=False, \n",+ " truncation=True, \n",+ " max_length=MAX_LENGTH, \n",+ " padding=False)\n",+ "\n",+ "input_tokens"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 5,+ "metadata": {},+ "outputs": [+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:53<00:00, 1.12it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:55<00:00, 1.09it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:53<00:00, 1.12it/s]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ " to think that\n"+ ]+ }+ ],+ "source": [+ "\n",+ "import mlx.core as mx\n",+ "generation_output = model.generate(\n",+ " mx.array(input_tokens['input_ids']), \n",+ " max_new_tokens=3,\n",+ " use_cache=True,\n",+ " return_dict_in_generate=True)\n",+ "\n",+ "print(generation_output)"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# test Platypus2 7b"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 1,+ "metadata": {},+ "outputs": [],+ "source": [+ "from airllm import AirLLMLlamaMlx"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 2,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "ac9bc7f5f7cb4e98b8913cc533bf6d5c",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 0 files: 0it [00:00, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "474ae14c2f7b4c759f53393d13daa86f",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Fetching 12 files: 0%| | 0/12 [00:00<?, ?it/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "26ef8712234d42498ffbdee1ed17514a",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ ".gitattributes: 0%| | 0.00/1.52k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "2e48bcc168514e01a320e4f200390cf5",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "pytorch_model.bin.index.json: 0%| | 0.00/26.8k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "bf6bc64a7441489a90501915a8b910c2",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "Best_Platty_small.jpeg: 0%| | 0.00/7.35k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "88bc6a86ebff4c1a8031411a1465abb8",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "generation_config.json: 0%| | 0.00/132 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "6281737965004d0698a80bfaac8c518e",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "config.json: 0%| | 0.00/625 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "3dd2a5971b664179911aecf465bc5181",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "README.md: 0%| | 0.00/5.23k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "f334509f6e83496587b4b79319c07795",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer_config.json: 0%| | 0.00/725 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "e2066e8b954d4611bef220a5c61fe0d3",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.json: 0%| | 0.00/1.84M [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "3e63b3ef1601494e8fd537613119bf3e",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "special_tokens_map.json: 0%| | 0.00/414 [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "84f6ff70472946e5828a6376dd60cdbe",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "pytorch_model-00002-of-00002.bin: 0%| | 0.00/3.50G [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "a5ded99432254e8781d2e3ebef09c597",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "pytorch_model-00001-of-00002.bin: 0%| | 0.00/9.98G [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "data": {+ "application/vnd.jupyter.widget-view+json": {+ "model_id": "4f65c2c1cc094b4f80dace069698503f",+ "version_major": 2,+ "version_minor": 0+ },+ "text/plain": [+ "tokenizer.model: 0%| | 0.00/500k [00:00<?, ?B/s]"+ ]+ },+ "metadata": {},+ "output_type": "display_data"+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 0%| | 0/35 [00:00<?, ?it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Loading shard 1/2\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.embed_tokens.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 6%|██████████▍ | 2/35 [00:10<02:27, 4.46s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.0.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 9%|███████████████▋ | 3/35 [00:12<01:47, 3.35s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.1.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 11%|████████████████████▉ | 4/35 [00:13<01:23, 2.71s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.2.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 14%|██████████████████████████▏ | 5/35 [00:15<01:09, 2.31s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.3.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 17%|███████████████████████████████▎ | 6/35 [00:17<01:02, 2.14s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.4.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 20%|████████████████████████████████████▌ | 7/35 [00:17<00:42, 1.52s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.5.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 23%|█████████████████████████████████████████▊ | 8/35 [00:17<00:30, 1.12s/it]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.6.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 26%|███████████████████████████████████████████████ | 9/35 [00:17<00:21, 1.19it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.7.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 29%|████████████████████████████████████████████████████ | 10/35 [00:18<00:16, 1.51it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.8.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 31%|█████████████████████████████████████████████████████████▏ | 11/35 [00:18<00:13, 1.80it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.9.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 34%|██████████████████████████████████████████████████████████████▍ | 12/35 [00:18<00:11, 2.00it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.10.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 37%|███████████████████████████████████████████████████████████████████▌ | 13/35 [00:19<00:09, 2.23it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.11.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 40%|████████████████████████████████████████████████████████████████████████▊ | 14/35 [00:19<00:08, 2.50it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.12.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 43%|██████████████████████████████████████████████████████████████████████████████ | 15/35 [00:19<00:07, 2.80it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.13.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 46%|███████████████████████████████████████████████████████████████████████████████████▏ | 16/35 [00:20<00:06, 3.00it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.14.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 49%|████████████████████████████████████████████████████████████████████████████████████████▍ | 17/35 [00:20<00:06, 2.76it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.15.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 51%|█████████████████████████████████████████████████████████████████████████████████████████████▌ | 18/35 [00:20<00:06, 2.65it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.16.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 54%|██████████████████████████████████████████████████████████████████████████████████████████████████▊ | 19/35 [00:21<00:06, 2.61it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.17.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 57%|████████████████████████████████████████████████████████████████████████████████████████████████████████ | 20/35 [00:21<00:05, 2.60it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.18.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 60%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 21/35 [00:22<00:05, 2.63it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.19.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 63%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 22/35 [00:22<00:04, 2.71it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.20.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 66%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 23/35 [00:22<00:04, 2.73it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.21.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 69%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 24/35 [00:23<00:03, 2.79it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.22.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 71%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 25/35 [00:23<00:03, 2.83it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.23.mlx\n",+ "Loading shard 2/2\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 74%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 26/35 [00:24<00:05, 1.68it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.24.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 77%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 27/35 [00:24<00:04, 2.00it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.25.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 28/35 [00:25<00:02, 2.34it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.26.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.27.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 86%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 30/35 [00:25<00:01, 3.36it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.28.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.29.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 91%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 32/35 [00:25<00:00, 4.12it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.30.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 94%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 33/35 [00:26<00:00, 4.33it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.layers.31.mlx\n",+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/model.norm.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 35/35 [00:26<00:00, 1.33it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "saved as: /Users/l_y_o/.cache/huggingface/hub/models--garage-bAInd--Platypus2-7B/snapshots/c27aff7201e611f301c0e19f351cbe74b1a9f1f1/splitted_model/lm_head.mlx\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "\n"+ ]+ }+ ],+ "source": [+ "model = AirLLMLlamaMlx(\"garage-bAInd/Platypus2-7B\")"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ },+ {+ "cell_type": "code",+ "execution_count": 3,+ "metadata": {},+ "outputs": [+ {+ "data": {+ "text/plain": [+ "{'input_ids': array([[ 1, 306, 763]])}"+ ]+ },+ "execution_count": 3,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],+ "source": [+ "input_text = [\n",+ " #'What is the capital of United States?',\n",+ " 'I like',\n",+ " ]\n",+ "\n",+ "MAX_LENGTH = 128\n",+ "input_tokens = model.tokenizer(input_text,\n",+ " return_tensors=\"np\", \n",+ " return_attention_mask=False, \n",+ " truncation=True, \n",+ " max_length=MAX_LENGTH, \n",+ " padding=False)\n",+ "\n",+ "input_tokens"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 4,+ "metadata": {},+ "outputs": [+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:07<00:00, 4.43it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:06<00:00, 4.77it/s]\n",+ "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:07<00:00, 4.50it/s]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "to think of\n"+ ]+ }+ ],+ "source": [+ "\n",+ "import mlx.core as mx\n",+ "generation_output = model.generate(\n",+ " mx.array(input_tokens['input_ids']), \n",+ " max_new_tokens=3,\n",+ " use_cache=True,\n",+ " return_dict_in_generate=True)\n",+ "\n",+ "print(generation_output)"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "Python 3 (ipykernel)",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.11.5"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 4+}