Skip to content

Instantly share code, notes, and snippets.

View proger's full-sized avatar
🎯
Focusing

Volodymyr Kyrylov proger

🎯
Focusing
View GitHub Profile
@proger
proger / scan3.ptx
Last active December 31, 2023 16:59
scan3 PTX from nanokitchen. Why is it numerically unstable? Is that the gate multiplication? Something else?
//
// 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
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"):
@proger
proger / mkm.py
Last active December 7, 2023 13:37
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):
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
@proger
proger / wind.py
Last active November 30, 2023 11:04
"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):
@proger
proger / robomaster_sim.patch
Last active November 23, 2023 13:31
robomaster_sim to work with Coppelia 4.6
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)
"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:
import torch
import torch.nn as nn
import torch.nn.functional as F
def forward_rnn(forget, input, output, hidden, T, x):
outputs = []
for t in range(T):
u = input(x[:, t, :])
import torch
import torch.nn as nn
def forward_rnn(forget, input, output, hidden, T, x):
outputs = []
for t in range(T):
hidden = (forget(hidden) + input(x[:, t, :])).relu()
outputs.append(output(hidden))
import torch
import torch.nn as nn
import math
def scan0(f, x):
y = [torch.zeros_like(x[..., 0])]
for i in range(0, x.size(-1)):
y.append(f*y[..., i-1] + x[..., i])
return torch.stack(y, dim=-1)