WaveCut commited on
Commit
cb0ceb1
·
verified ·
1 Parent(s): c34d985

Report packed matmul storage footprint

Browse files
Files changed (2) hide show
  1. CARD.md +7 -0
  2. benchmarks/benchmark.py +14 -0
CARD.md CHANGED
@@ -84,3 +84,10 @@ The script prints JSON with `packed_seconds_per_iter`,
84
  `packed_vs_dequantize_then_f_linear_speedup`, compatibility aliases
85
  `reference_seconds_per_iter` and `packed_vs_reference_speedup`, and
86
  `max_abs_error`.
 
 
 
 
 
 
 
 
84
  `packed_vs_dequantize_then_f_linear_speedup`, compatibility aliases
85
  `reference_seconds_per_iter` and `packed_vs_reference_speedup`, and
86
  `max_abs_error`.
87
+
88
+ It also reports storage accounting for the packed weight path:
89
+ `packed_weight_indices_bytes`, `row_norms_bytes`, `centroid_bytes`,
90
+ `packed_weight_path_bytes`, `materialized_weight_bytes`, and
91
+ `packed_weight_path_vs_materialized_weight_ratio`. These values describe only
92
+ the weight-side storage used by this operator; they are not end-to-end model
93
+ VRAM measurements.
benchmarks/benchmark.py CHANGED
@@ -74,6 +74,11 @@ def main() -> None:
74
  return (row_norms[:, None] * centroids[indices_device]).to(dtype)
75
 
76
  reference_weight = materialize_reference_weight()
 
 
 
 
 
77
 
78
  def packed_call() -> torch.Tensor:
79
  return matmul_packed_weight(
@@ -128,6 +133,15 @@ def main() -> None:
128
  "packed_seconds_per_iter": packed_seconds,
129
  "predequantized_f_linear_seconds_per_iter": predequantized_linear_seconds,
130
  "dequantize_then_f_linear_seconds_per_iter": dequantize_then_linear_seconds,
 
 
 
 
 
 
 
 
 
131
  "packed_vs_predequantized_f_linear_speedup": predequantized_linear_seconds
132
  / packed_seconds
133
  if packed_seconds > 0
 
74
  return (row_norms[:, None] * centroids[indices_device]).to(dtype)
75
 
76
  reference_weight = materialize_reference_weight()
77
+ packed_weight_indices_bytes = packed.numel() * packed.element_size()
78
+ row_norms_bytes = row_norms.numel() * row_norms.element_size()
79
+ centroid_bytes = centroids.numel() * centroids.element_size()
80
+ packed_weight_path_bytes = packed_weight_indices_bytes + row_norms_bytes + centroid_bytes
81
+ materialized_weight_bytes = reference_weight.numel() * reference_weight.element_size()
82
 
83
  def packed_call() -> torch.Tensor:
84
  return matmul_packed_weight(
 
133
  "packed_seconds_per_iter": packed_seconds,
134
  "predequantized_f_linear_seconds_per_iter": predequantized_linear_seconds,
135
  "dequantize_then_f_linear_seconds_per_iter": dequantize_then_linear_seconds,
136
+ "packed_weight_indices_bytes": packed_weight_indices_bytes,
137
+ "row_norms_bytes": row_norms_bytes,
138
+ "centroid_bytes": centroid_bytes,
139
+ "packed_weight_path_bytes": packed_weight_path_bytes,
140
+ "materialized_weight_bytes": materialized_weight_bytes,
141
+ "packed_weight_path_vs_materialized_weight_ratio": packed_weight_path_bytes
142
+ / materialized_weight_bytes
143
+ if materialized_weight_bytes > 0
144
+ else None,
145
  "packed_vs_predequantized_f_linear_speedup": predequantized_linear_seconds
146
  / packed_seconds
147
  if packed_seconds > 0