Views
No views yet
tmux.1LOGDIR="" python3 -m fastchat.serve.openai_api_server \
2 --host 0.0.0.0 --port 8080 \
3 --controller-address http://localhost:21000
4
5LOGDIR="" python3 -m fastchat.serve.controller \
6 --host 0.0.0.0 --port 21000
7
8LOGDIR="" RAY_LOG_TO_STDERR=1 \
9 python3 -m fastchat.serve.vllm_worker \
10 --model-path ./VirtualCompiler \
11 --num-gpus 8 \
12 --controller http://localhost:21000 \
13 --max-num-batched-tokens 40960 \
14 --disable-log-requests \
15 --host 0.0.0.0 --port 22000 \
16 --worker-address http://localhost:22000 \
17 --model-names "VirtualCompiler"do_request.py to make request to the model.1~/C/VirtualCompiler (main)> python3 do_request.py
2test rdx, rdx
3setz al
4movzx eax, al
5neg eax
6retnmodel.py to test the custom model loading.1def calc_map_at_k(logits, pos_cnt, ks=[10,]):
2 _, indices = torch.sort(logits, dim=1, descending=True)
3
4 # [batch_size, pos_cnt]
5 ranks = torch.nonzero(
6 indices < pos_cnt,
7 as_tuple=False
8 )[:, 1].reshape(logits.shape[0], -1)
9
10 # [batch_size, pos_cnt]
11 mrr = torch.mean(1 / (ranks + 1), dim=1)
12
13 res = {}
14
15 for k in ks:
16 res[k] = (
17 torch.sum((ranks < k).float(), dim=1) / min(k, pos_cnt)
18 ).cpu().numpy()
19
20 return ranks.cpu().numpy(), res, mrr.cpu().numpy()
21
22pos_asm_cnt = 1
23
24query = ["List all files in a directory"]
25
26# Extracted by the process_asm.py script mentioned above
27anchor_asm = [ {"1": "endbr64", "2": "mov eax, 0" }, ... ]
28neg_anchor_asm = [ {"1": "push rbp", "2": "mov rbp, rsp", ... }, ... ]
29
30query_embs = text_encoder(**text_tokenizer(query))
31
32kwargs = dict(padding=True, pad_to_multiple_of=8, return_tensors="pt")
33anchor_asm_ids = asm_tokenizer.pad([asm_tokenizer(pos) for pos in anchor_asm], **kwargs)
34neg_anchor_asm_ids = asm_tokenizer.pad([asm_tokenizer(neg) for neg in neg_anchor_asm], **kwargs)
35
36asm_embs = asm_encoder(**anchor_asm_ids)
37asm_neg_emb = asm_encoder(**neg_anchor_asm_ids)
38
39# query_embs: [query_cnt, emb_dim]
40# asm_embs: [pos_asm_cnt, emb_dim]
41
42# logits_pos: [query_cnt, pos_asm_cnt]
43logits_pos = torch.einsum(
44 "ic,jc->ij", [query_embs, asm_embs])
45# logits_neg: [query_cnt, neg_asm_cnt]
46logits_neg = torch.einsum(
47 "ic,jc->ij", [query_embs, asm_neg_emb[pos_asm_cnt:]]
48)
49logits = torch.cat([logits_pos, logits_neg], dim=1)
50
51ranks, map_at_k, mrr = calc_map_at_k(
52 logits, pos_asm_cnt, [1, 5, 10, 20, 50, 100])