@@ -234,6 +234,8 @@ def dump_markdown_metadata(reader: GGUFReader, args: argparse.Namespace) -> None
234
234
markdown_content += '## Key Value Metadata Store\n \n '
235
235
markdown_content += f'There are { len (reader .fields )} key-value pairs in this file\n '
236
236
markdown_content += '\n '
237
+ total_model_bytes = 0
238
+ total_model_elements = 0
237
239
238
240
kv_dump_table : list [dict [str , str | int ]] = []
239
241
for n , field in enumerate (reader .fields .values (), 1 ):
@@ -377,6 +379,8 @@ def escape_markdown_inline_code(value_string):
377
379
tensors = tensor_groups [group ]
378
380
group_elements = sum (tensor .n_elements for tensor in tensors )
379
381
group_percentage = group_elements / total_elements * 100
382
+ total_group_bytes = 0
383
+ total_group_elements = 0
380
384
markdown_content += f"### <a name=\" { group .replace ('.' , '_' )} \" >{ translate_tensor_name (group )} Tensor Group : { element_count_rounded_notation (group_elements )} Elements</a>\n \n "
381
385
382
386
# Precalculate column sizing for visual consistency
@@ -397,7 +401,13 @@ def escape_markdown_inline_code(value_string):
397
401
element_count_est = f"({ element_count_rounded_notation (tensor .n_elements ):>{prettify_element_est_count_size }} )"
398
402
element_count_string = f"{ element_count_est } { tensor .n_elements :>{prettify_element_count_size }} "
399
403
type_name_string = f"{ tensor .tensor_type .name } "
400
- tensor_dump_table .append ({"t_id" :tensor_name_to_key [tensor .name ], "layer_name" :tensor .name , "human_layer_name" :human_friendly_name , "element_count" :element_count_string , "pretty_dimension" :pretty_dimension , "tensor_type" :type_name_string })
404
+ if tensor .n_elements > 0 :
405
+ bpw = (tensor .n_bytes * 8 ) / tensor .n_elements
406
+ else :
407
+ bpw = float ('nan' )
408
+ tensor_dump_table .append ({"t_id" :tensor_name_to_key [tensor .name ], "layer_name" :tensor .name , "human_layer_name" :human_friendly_name , "element_count" :element_count_string , "pretty_dimension" :pretty_dimension , "tensor_type" :type_name_string , "bpw" : f"{ bpw :.4f} " })
409
+ total_group_bytes += tensor .n_bytes
410
+ total_group_elements += tensor .n_elements
401
411
402
412
tensor_dump_table_header_map = [
403
413
{'key_name' :'t_id' , 'header_name' :'T_ID' , 'align' :'right' },
@@ -406,15 +416,28 @@ def escape_markdown_inline_code(value_string):
406
416
{'key_name' :'element_count' , 'header_name' :'Elements' , 'align' :'left' },
407
417
{'key_name' :'pretty_dimension' , 'header_name' :'Shape' , 'align' :'left' },
408
418
{'key_name' :'tensor_type' , 'header_name' :'Type' , 'align' :'left' },
419
+ {'key_name' :'bpw' , 'header_name' :'BPW' , 'align' :'right' },
409
420
]
410
421
411
422
markdown_content += markdown_table_with_alignment_support (tensor_dump_table_header_map , tensor_dump_table )
412
423
413
424
markdown_content += "\n "
414
425
markdown_content += f"- Total elements in { group } : ({ element_count_rounded_notation (group_elements ):>4} ) { group_elements } \n "
415
426
markdown_content += f"- Percentage of total elements: { group_percentage :.2f} %\n "
427
+ if total_group_elements > 0 :
428
+ total_group_bpw = (total_group_bytes * 8 ) / total_group_elements
429
+ markdown_content += f"- Bits per Weight (BPW) for { group } : { total_group_bpw :.4f} bits\n "
430
+ else :
431
+ markdown_content += f"- Bits per Weight (BPW) for { group } : undefined (no elements)\n "
416
432
markdown_content += "\n \n "
433
+ total_model_bytes += total_group_bytes
434
+ total_model_elements += total_group_elements
417
435
436
+ if total_model_elements > 0 :
437
+ total_model_bpw = (total_model_bytes * 8 ) / total_model_elements
438
+ markdown_content += f"Total BPW for { os .path .basename (args .model )} : { total_model_bpw :.4f} bits"
439
+ else :
440
+ markdown_content += f"Total BPW for { os .path .basename (args .model )} : undefined (no elements)"
418
441
print (markdown_content ) # noqa: NP100
419
442
420
443
0 commit comments