[Bugfix][Quant] Raise actionable error instead of bare assert for group-size/TP mismatch (#46230) (#46236)
Signed-off-by: Arsalan Shakil <shakil.arsalan@yahoo.com>
This commit is contained in:
@@ -64,6 +64,24 @@ def divide(numerator, denominator):
|
||||
return numerator // denominator
|
||||
|
||||
|
||||
def verify_group_size_divides_partition(
|
||||
input_size_per_partition: int,
|
||||
group_size: int,
|
||||
layer_name: str | None = None,
|
||||
extra_suggestion: str = "",
|
||||
) -> None:
|
||||
"""Validate that a TP-sharded layer holds a whole number of quant groups."""
|
||||
if input_size_per_partition % group_size == 0:
|
||||
return
|
||||
location = f" for layer '{layer_name}'" if layer_name else ""
|
||||
raise ValueError(
|
||||
f"Weight {input_size_per_partition=}{location} is not divisible by "
|
||||
f"{group_size=}. This happens when tensor_parallel_size splits the layer input "
|
||||
"into shards that are not a whole number of quant groups. Consider reducing "
|
||||
f"tensor_parallel_size{extra_suggestion}."
|
||||
)
|
||||
|
||||
|
||||
def is_weak_contiguous(inp: torch.Tensor) -> bool:
|
||||
"""Check that *inp* occupies a single contiguous block of memory.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user