benchmark
shrinkai.profiler.benchmark
Classes:
| Name | Description |
|---|---|
BenchmarkReport |
Holds comparison results between Teacher and Student models. |
ModelProfile |
Container holding profiled metrics for an individual model. |
Profiler |
Benchmark runner comparing Teacher and Student architectures. |
Classes
BenchmarkReport
Holds comparison results between Teacher and Student models.
Methods:
| Name | Description |
|---|---|
show |
Renders an interactive formatted comparison table in the console. |
Source code in src/shrinkai/profiler/benchmark.py
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
Methods:
show
Renders an interactive formatted comparison table in the console.
Source code in src/shrinkai/profiler/benchmark.py
ModelProfile
dataclass
Container holding profiled metrics for an individual model.
Source code in src/shrinkai/profiler/benchmark.py
Profiler
Benchmark runner comparing Teacher and Student architectures.
Methods:
| Name | Description |
|---|---|
compare |
Executes complete profiling suite on both models and generates comparison. |
Source code in src/shrinkai/profiler/benchmark.py
Methods:
compare
staticmethod
compare(
teacher: Module,
student: Module,
sample_input: Tensor,
device: device | str = "auto",
teacher_name: str = "Teacher",
student_name: str = "Student",
teacher_acc: float | None = None,
student_acc: float | None = None,
compute_flops: bool = False,
) -> BenchmarkReport
Executes complete profiling suite on both models and generates comparison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
teacher
|
Module
|
Teacher PyTorch model. |
required |
student
|
Module
|
Student PyTorch model. |
required |
sample_input
|
Tensor
|
Representative tensor input batch. |
required |
device
|
device | str
|
Device target ('auto', 'mps', 'cuda', 'cpu'). |
'auto'
|
teacher_name
|
str
|
Display label for teacher. |
'Teacher'
|
student_name
|
str
|
Display label for student. |
'Student'
|
teacher_acc
|
float | None
|
Optional pre-computed teacher accuracy. |
None
|
student_acc
|
float | None
|
Optional pre-computed student accuracy. |
None
|
compute_flops
|
bool
|
If True, also counts and reports FLOPs per sample for
both models (see |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
BenchmarkReport |
BenchmarkReport
|
Structured report ready for |