Skip to content

Instantly share code, notes, and snippets.

import Metal
import MetalPerformanceShadersGraph
let type = MTLDataType.float;
let dataType = type;
var B = 2;
var M = 2;
@Narsil
Narsil / gist:c15cdc4c9b8efd77017fcecc99bb20bf
Created August 16, 2023 06:55
Proposal for `VarBuilder` more generic + Doable in user space.
struct Tensor{
id: usize
}
struct Linear{
weight: Tensor,
bias: Option<Tensor>,
}
import http from 'k6/http';
import {sleep} from 'k6';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
const token = __ENV.API_TOKEN;
const MODEL_ID = "f-1" // Or "s-1"
export const options = {
.globl <gemm_f16::gemm::f16::GEMM as lazy_static::LazyStatic>::initialize
.p2align 2
<gemm_f16::gemm::f16::GEMM as lazy_static::LazyStatic>::initialize:
Lfunc_begin18:
.cfi_startproc
sub sp, sp, #48
.cfi_def_cfa_offset 48
stp x29, x30, [sp, #32]
add x29, sp, #32
.cfi_def_cfa w29, 16
import torch
from transformers import AutoTokenizer, RobertaForMaskedLM, AutoConfig
from transformers.pipelines.base import infer_framework_load_model
from os import path
from huggingface_hub import hf_hub_download
def compare_models(pt_mdl, sf_mdl):
# A blend of convert.py's generalized check_final_model with concrete usage example to demonstrate
sf_dict = sf_mdl.state_dict()
//
// Created by mfuntowicz on 3/28/23.
//
// ! Requires std=c++20
#include <span>
#include "safetensors.hpp"
#include "nlohmann/json.hpp"
namespace huggingface::safetensors {
#!/usr/bin/env python3
"""Toggle the bit at the specified offset.
Syntax: <cmdname> filename bit-offset"""
import sys
import os
import random
fname = sys.argv[1]
# Convert bit offset to bytes + leftover bits
@Narsil
Narsil / out.log
Created March 10, 2023 18:45
Logs for ChunkPipeline for token classification
----------------
conll2003
===========================
StanfordAIMI/stanford-deidentifier-base
Results : 0.93 (4846/5233 (ignored 8808)
===========================
Davlan/bert-base-multilingual-cased-ner-hrl
Results : 0.98 (604/618 (ignored 13423)
===========================
dslim/bert-base-NER
from safetensors import safe_open
import torch
from huggingface_hub import hf_hub_download
filenames = [
"safety_checker/model.safetensors",
"safety_checker/pytorch_model.bin",
"vae/diffusion_pytorch_model.safetensors",
"vae/diffusion_pytorch_model.bin",
from huggingface_hub import hf_hub_download
from flax.serialization import msgpack_restore
from safetensors.flax import save_file
import numpy as np
filename = hf_hub_download("gpt2", filename="flax_model.msgpack")
with open(filename, "rb") as f:
data = f.read()
flax_weights = msgpack_restore(data)