def valid_alignment(align: int, dtype: str) -> bool:
    """
    Return True if the given align value is legitimate for the dtype.
    """
    dtype = normalize_dtype(dtype)
    # 2-elem-alignment is required by fp16, because async.copy needs at least 32
    # bits. For fp32 dtype values, 1-elem-alignment is valid.
    if dtype in ("float16", "bfloat16"):
        return align % 2 == 0
    elif dtype in ("float", "float32"):
        return True
    else:
        raise NotImplementedError(f"unsupported {dtype=} for valid_alignment")
Return True if the given align value is legitimate for the dtype.
python/aitemplate/utils/alignment.py