{"record":{"id":"33d9f8d3d39bf3c3","repo":"sgl-project/sglang","slug":"invalid-arch-format-arch-str","errorCode":null,"errorMessage":"Invalid arch format: {arch_str}","messagePattern":"Invalid arch format: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/flash_attn/cute/interface.py","lineNumber":81,"sourceCode":"    try_cached_paged_decode,\n    try_cached_varlen,\n)\nfrom sglang.kernels.ops.attention.flash_attn.cute.shearing_bias import ShearingBias\n\n# SM100 head_dim=256 2CTA kernel imports\nfrom sglang.kernels.ops.attention.flash_attn.cute.sm100_hd256_2cta_fmha_forward import (\n    BlackwellFusedMultiHeadAttentionForward,\n)\nfrom sglang.kernels.ops.attention.flash_attn.cute.utils import AuxData\n\n\ndef _parse_arch_str(arch_str):\n    \"\"\"Parse arch string (e.g. 'sm_80', 'sm_90a', '80', '100') to int (e.g. 80, 90, 100).\"\"\"\n    import re\n\n    match = re.match(r\"^(?:sm_?|SM_?)?(\\d+)(\\d)([af]?)$\", arch_str)\n    if not match:\n        raise ValueError(f\"Invalid arch format: {arch_str}\")\n    major, minor, _ = match.groups()\n    return int(major) * 10 + int(minor)\n\n\n@lru_cache(maxsize=None)\ndef _get_device_arch():\n    \"\"\"Cached device arch check.\n\n    Override with FLASH_ATTENTION_ARCH (e.g. 'sm_80' or '80') to select the\n    kernel path independently of the compilation target (CUTE_DSL_ARCH).\n\n    For CPU-only compilation (no GPU), set both:\n      FLASH_ATTENTION_ARCH=sm_80  (kernel selection)\n      CUTE_DSL_ARCH=sm_80         (compilation target)\n    \"\"\"\n    arch_override = os.environ.get(\"FLASH_ATTENTION_ARCH\", None)\n    if arch_override is not None:\n        return _parse_arch_str(arch_override)","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attn/cute/interface.py#L63-L99","documentation":"_parse_arch_str parses GPU architecture strings like 'sm_90a', 'SM100', or bare '90' into an integer. Anything not matching ^(?:sm_?)?(\\d)(\\d)([af]?)$ — bad separators, non-digits, more than one suffix letter — raises this ValueError.","triggerScenarios":"Calling _get_device_arch/_parse_arch_str (or an API that derives arch from a string) with malformed input like 'sm-90', '90aa', 'gpu100', or 'b200'.","commonSituations":"Passing a marketing GPU name (e.g. 'b200', 'h100') instead of the compute-capability form, or a typo in an env var / config that carries the arch string.","solutions":["Use the canonical form: 'sm_100', 'sm_100a', 'SM90', or plain '90'/'100'","Map vendor names to compute capability (h100->90, b200->100) before passing","Check for stray characters/typos in the config value"],"exampleFix":"// before\n_parse_arch_str('b200')\n// after\n_parse_arch_str('sm_100')","handlingStrategy":"validation","validationCode":"import re\nassert re.match(r'^(?:sm_?)?(\\d)(\\d)([af]?)$', arch_str), arch_str","typeGuard":"def is_valid_arch_str(s: str) -> bool:\n    return re.match(r'^(?:sm_?)?(\\d)(\\d)([af]?)$', s) is not None","tryCatchPattern":"try:\n    arch = _parse_arch_str(cfg)\nexcept ValueError:\n    arch = {'h100': 90, 'a100': 80, 'b200': 100}.get(cfg.lower())  # name map fallback","preventionTips":["Store compute capability as an int (e.g. 100) in configs, format to 'sm_100' only at the boundary","Map marketing GPU names to sm_XX centrally instead of ad-hoc"],"tags":["gpu-arch","validation","configuration","cuda"],"backgroundTag":"invalid-argument-format","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}