mirror of
https://github.com/deepseek-ai/DeepSeek-V3.git
synced 2025-04-19 18:18:57 -04:00
Created fuzz_target.py
This commit is contained in:
parent
8710ec2ecb
commit
f5fb13ee14
28
fuzz/fuzz_target.py
Normal file
28
fuzz/fuzz_target.py
Normal file
@ -0,0 +1,28 @@
|
||||
import atheris
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import torch
|
||||
from safetensors.torch import load_file, save_file
|
||||
from kernel import weight_dequant
|
||||
|
||||
def TestOneInput(data):
|
||||
fdp = atheris.FuzzedDataProvider(data)
|
||||
try:
|
||||
fp8_path = fdp.ConsumeUnicodeNoSurrogates(50)
|
||||
bf16_path = fdp.ConsumeUnicodeNoSurrogates(50)
|
||||
torch.set_default_dtype(torch.bfloat16)
|
||||
os.makedirs(bf16_path, exist_ok=True)
|
||||
model_index_file = os.path.join(fp8_path, "model.safetensors.index.json")
|
||||
with open(model_index_file, "r") as f:
|
||||
model_index = json.load(f)
|
||||
weight_map = model_index["weight_map"]
|
||||
for tensor_name in weight_map:
|
||||
file_name = weight_map[tensor_name]
|
||||
file_path = os.path.join(fp8_path, file_name)
|
||||
load_file(file_path, device="cuda")
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
atheris.Setup(sys.argv, TestOneInput)
|
||||
atheris.Fuzz()
|
Loading…
Reference in New Issue
Block a user