INNER CODE UNIT · Python

parse_bytes

invergent-ai/surogate · surogate/serve/tools/reference/qwen3_5/cli.py:45

def parse_bytes(text: str | None) -> int | None:
    if text is None or text.strip().lower() == "auto":
        return None
    units = {"gib": 1 << 30, "mib": 1 << 20, "gb": 10**9, "mb": 10**6}
    lowered = text.strip().lower()
    for suffix, scale in units.items():
        if lowered.endswith(suffix):
            return int(float(lowered[: -len(suffix)]) * scale)
    return int(lowered)


def build_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--weights", required=True, help="a .sinfer artifact of this architecture, at any size")
    prompt = parser.add_mutually_exclusive_group(required=True)
    prompt.add_argument("--prompt", help="single user message rendered by the artifact template")
    prompt.add_argument("--ids", help="comma/space-separated prompt token IDs")
    prompt.add_argument("--messages", help="Qwen messages JSON with optional image/video content")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…