ncu --list-sets # The configuration for sets. A set defines a set of sections.
ncu --list-sections # The configuration for sections. A section defines a set of metrics.
ncu --query-metrics # All individual metrics.
ncu --query-metrics-mode suffix --metrics <metrics list> # Check various suffixes for a base metric name.
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
from dataclasses import dataclass | |
@dataclass | |
class Args: | |
vocab_size: int = 129280 | |
dim: int = 7168 | |
inter_dim: int = 18432 | |
moe_inter_dim: int = 2048 | |
n_layers: int = 61 |
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 sklearn | |
import torch | |
from sentence_transformers import SentenceTransformer | |
import torch.nn.functional as F | |
def get_score_diff(vectors): | |
scores = torch.matmul(vectors, vectors.T) | |
scores = scores[torch.triu(torch.ones_like(scores), diagonal=1).bool()] | |
score_diff = scores.reshape((1, -1)) - scores.reshape((-1, 1)) | |
score_diff = score_diff[torch.triu(torch.ones_like(score_diff), diagonal=1).bool()] |
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 | |
import torch._inductor.config | |
import time | |
torch._inductor.config.triton.cudagraphs = False | |
torch.set_float32_matmul_precision('high') | |
def bench(f, name=None, iters=100, warmup=5, display=True, profile=False): | |
for _ in range(warmup): | |
f() |
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 json | |
import sentencepiece as spm | |
import sentencepiece.sentencepiece_model_pb2 as sp_pb2 | |
from google.protobuf.json_format import MessageToDict | |
PATH = "tokenizer.model" | |
s = spm.SentencePieceProcessor(model_file=PATH) |
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
from transformers import AutoModelForCausalLM, AutoTokenizer | |
tok = AutoTokenizer.from_pretrained("distilgpt2") | |
model = AutoModelForCausalLM.from_pretrained("distilgpt2") | |
inputs = tok(["Hello how"], return_tensors="pt") | |
len_inp = len(inputs.input_ids[0]) | |
print(len_inp) | |
generated = model.generate(**inputs, do_sample=False, max_new_tokens=10) |
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 math | |
import torch | |
import torch.nn as nn | |
from torch.nn import functional as F | |
class RelativePositionBias(nn.Module): | |
def __init__(self, bidirectional=True, num_buckets=32, max_distance=128, n_heads=2): | |
super(RelativePositionBias, self).__init__() | |
self.bidirectional = bidirectional |
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 numpy as np # import numpy library | |
from util.paramInitializer import initialize_parameters # import function to initialize weights and biases | |
class LinearLayer: | |
""" | |
This Class implements all functions to be executed by a linear layer | |
in a computational graph | |
Args: |
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
#!/usr/bin/python | |
from z3 import * | |
s = [BitVec("s[%d]" % i,32)for i in range(0,8)] | |
# shouldve | |
z3_solver = Solver() | |
flag = "" | |
for i in range(0,len(s)): |
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
if(strlen(input) != 23) { | |
print_wrong; | |
return 0; | |
} | |
if((input[4] ^ 0x6c) != 0) { | |
print_wrong; | |
return 0; | |
} | |
if(input[3] + 1 != input[6]) { |
NewerOlder