This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# download the model | |
huggingface-cli download google/gemma-2b-it | |
# run the server (set the model name here and in the prompt function below) | |
# notice --kv_cache_dtype fp8_e5m2 | |
docker run --gpus all -p 8000:8000 -e HF_HOME=/hf -e CUDA_VISIBLE_DEVICES=1 -v ~/.cache/huggingface:/hf vllm/vllm-openai:latest:latest --host 0.0.0.0 --model google/gemma-2b-it --kv-cache-dtype fp8_e5m2 | |
# ask one question | |
echo 'what is python?' | python -m prompt | jq -r '.choices[].text' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
def binary(digits: int) -> torch.IntTensor: | |
"Make a basis of powers of two of dimension `digits`, lowest bits to the right" | |
return 1 << torch.arange(digits).flip(-1) | |
def sbt(x: torch.IntTensor) -> torch.IntTensor: | |
"""Slow Binary Transform. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from itertools import islice | |
import logging | |
from pathlib import Path | |
import evaluate | |
from datasets import load_dataset | |
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig | |
from transformers.generation import BeamSearchDecoderOnlyOutput | |
from peft import PeftModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Generated by LLVM NVPTX Back-End | |
// See scan3 in https://github.com/proger/nanokitchen/blob/main/triscan.py | |
// | |
.version 8.1 | |
.target sm_86 | |
.address_size 64 | |
// .globl scan3_0d1d2d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import requests | |
import json | |
context = """[INST] They are planning to host a party next weekend. [/INST] Вони планують провести вечірку наступного вікенду. | |
[INST] I enjoy swimming in the ocean and feeling the salty breeze. [/INST] Мені подобається плавати в океані та відчувати солоний вітер. | |
[INST]""" | |
# docker run --gpus all -p 8000:8000 -e HF_HOME=/hf -e CUDA_VISIBLE_DEVICES=1 -v ~/.cache/huggingface:/hf ghcr.io/mistralai/mistral-src/vllm:latest --host 0.0.0.0 --model mistralai/Mistral-7B-v0.1 | |
def prompt(input, url="http://localhost:8000/v1/completions"): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn | |
from torch.utils.data import DataLoader, TensorDataset | |
import gzip | |
import numpy as np | |
torch.set_float32_matmul_precision('high') | |
def read(filename): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
import numpy as np | |
from sklearn.cluster import MiniBatchKMeans | |
def read(filename): | |
with gzip.open(filename, 'rb') as file: | |
compressed_data = file.read() | |
data = np.frombuffer(compressed_data, dtype=np.float32) | |
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"this module sets phasors to stun using gradient descent" | |
import torch | |
import torch.nn as nn | |
import torch.nn.utils.parametrize as parametrize | |
tau = 6.28 | |
stun = 0.25*tau | |
class Cyclic(nn.Module): | |
def forward(self, x): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This patch makes robomaster_sim work with Coppelia 4.6 | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index 03c1ab6..be6e2cf 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -11,7 +11,7 @@ IF (WIN32) | |
ELSE() | |
set(CMAKE_CXX_STANDARD 17) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"accumulate repeating characters: convolution frontend, RNN backend" | |
import collections | |
from itertools import islice | |
def conv(iterable, n=2): | |
"1d convolution" | |
it = iter(iterable) | |
window = collections.deque(islice(it, n-1), maxlen=n) | |
for x in it: |
NewerOlder