-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
65 lines (51 loc) · 1.64 KB
/
Copy pathconfig.py
File metadata and controls
65 lines (51 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Typed configuration and result models for the benchmark.
Kept as pydantic models (same pattern as the original RAG project) so the
agent, benchmark harness, and reporting code all share one validated schema
instead of passing raw dicts around.
"""
from __future__ import annotations
from enum import Enum
from typing import Optional
import torch
from pydantic import BaseModel, Field
class CompileMode(str, Enum):
EAGER = "eager"
DEFAULT = "default"
REDUCE_OVERHEAD = "reduce-overhead"
MAX_AUTOTUNE = "max-autotune"
class DType(str, Enum):
FP32 = "fp32"
FP16 = "fp16"
BF16 = "bf16"
def to_torch(self) -> torch.dtype:
return {
DType.FP32: torch.float32,
DType.FP16: torch.float16,
DType.BF16: torch.bfloat16,
}[self]
class ExperimentConfig(BaseModel):
batch_size: int = Field(gt=0, le=256)
seq_len: int = Field(gt=0, le=8192)
dtype: DType
compile_mode: CompileMode
use_triton_softmax: bool = False
def key(self) -> str:
return (
f"bs{self.batch_size}_sl{self.seq_len}_{self.dtype.value}"
f"_{self.compile_mode.value}_triton{int(self.use_triton_softmax)}"
)
class BenchmarkResult(BaseModel):
config: ExperimentConfig
mean_latency_ms: float
std_latency_ms: float
throughput_tokens_per_s: float
peak_memory_mb: float
compile_overhead_s: Optional[float] = None
max_abs_error: Optional[float] = None
top1_agreement: Optional[float] = None
correctness_passed: Optional[bool] = None
error: Optional[str] = None
@property
def ok(self) -> bool:
return self.error is None