Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions gptqmodel/looper/gptq_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def process(

wq, q_scales, q_zeros, q_g_idx, duration, avg_loss, damp_percent, nsamples = g.quantize()

workspace_summary = getattr(g, "_borrow_workspace_last_summary", None)
workspace_totals = getattr(g, "_borrow_workspace_totals", None)

module.stream_state_payload_to_cpu(
{
"q_scales": q_scales,
Expand Down Expand Up @@ -235,6 +238,25 @@ def process(
PROCESS_USED_MEMORY: self.device_memory_report(),
}

if workspace_summary:
requests = int(workspace_summary.get("requests", 0) or 0)
if requests:
hit_rate = float(workspace_summary.get("hit_rate", 0.0) or 0.0)
chunk_rows = workspace_summary.get("chunk_rows")
stat["workspace_cache_requests"] = str(requests)
stat["workspace_cache_hit_rate"] = f"{hit_rate:.1%}"
stat["workspace_stage_dtype"] = workspace_summary.get("staging_dtype", "")
if chunk_rows is not None:
stat["workspace_chunk_rows"] = str(chunk_rows)
if workspace_totals:
total_requests = int(workspace_totals.get("requests", 0) or 0)
if total_requests:
cumulative_hit_rate = (
float(workspace_totals.get("materialized_hits", 0) or 0.0) / total_requests
)
stat["workspace_total_requests"] = str(total_requests)
stat["workspace_total_hit_rate"] = f"{cumulative_hit_rate:.1%}"

if self.qcfg.dynamic is not None:
stat["dynamic"] = self.qcfg.dynamic_get(layer_name=module.full_name)

Expand All @@ -244,6 +266,8 @@ def process(
# Log the new row
self.log_new_row(stat)

g.log_workspace_stats(context="gptq_process")

if self.calculate_w_wq_diff:
# diff in float32
w_wq_diff = module.weight.data.to(dtype=torch.float32) - wq.to(dtype=torch.float32)
Expand Down
6 changes: 4 additions & 2 deletions gptqmodel/looper/loop_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,11 @@ def device_memory_report(self) -> str:
return "n/a"

def _format_gib(value: float) -> str:
text = f"{value:.1f}"
if text.endswith(".0"):
text = f"{value:.2f}"
if text.endswith("00"):
text = text[:-2]
elif text.endswith("0"):
text = text[:-1]
return f"{text}G"

grouped: Dict[str, List[Tuple[str, float, int]]] = {}
Expand Down
Loading