{"record":{"id":"dd5be80236f24cbf","repo":"sgl-project/sglang","slug":"module-name-r-has-no-attribute-name-r-dd5be8","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/flash_attn/cute/flash_fwd.py","lineNumber":1538,"sourceCode":"            self.score_vec_size,\n            self.qk_acc_dtype,\n            aux_data,\n            fastdiv_mods,\n            seqlen_info=seqlen,\n            constant_q_idx=None,\n            qhead_per_kvhead=self.qhead_per_kvhead if const_expr(self.pack_gqa) else 1,\n        )\n\n\n# SM90 forward pass moved to flash_fwd_sm90.py; re-export for backward compatibility\ndef __getattr__(name):\n    if name == \"FlashAttentionForwardSm90\":\n        from sglang.kernels.ops.attention.flash_attn.cute.flash_fwd_sm90 import (\n            FlashAttentionForwardSm90,\n        )\n\n        return FlashAttentionForwardSm90\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n","sourceCodeStart":1520,"sourceCodeEnd":1539,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attn/cute/flash_fwd.py#L1520-L1539","documentation":"This module uses a lazy attribute hook: only FlashAttentionForwardSm90 is importable on demand; any other attribute access on the module raises AttributeError. This avoids importing the heavy Sm90 kernel (and its CUTLASS DSL compilation machinery) unless actually needed.","triggerScenarios":"Doing from ...flash_fwd import FlashAttentionForward or accessing any name other than FlashAttentionForwardSm90 on the module, e.g. via importlib, getattr(module, name), or tab-completion-driven code. Also triggered by tools like mock.patch('...flash_fwd.Something') or hasattr probes.","commonSituations":"Refactoring imports after a file split where older names lived in this module; test frameworks patching module attributes; static-analysis or dynamic-import code enumerating module members.","solutions":["Import the correct symbol: from sglang.kernels.ops.attention.flash_attn.cute.flash_fwd_sm90 import FlashAttentionForwardSm90, or getattr(module, 'FlashAttentionForwardSm90')","Find the new home of the moved symbol with grep in python/sglang/kernels/ops/attention/flash_attn/cute/","Update mock.patch targets to the defining module, not this lazy facade"],"exampleFix":"// before\nfrom sglang.kernels.ops.attention.flash_attn.cute.flash_fwd import FlashAttentionForward\n// after\nfrom sglang.kernels.ops.attention.flash_attn.cute.flash_fwd import FlashAttentionForwardSm90","handlingStrategy":"try-catch","validationCode":"ALLOWED = ('FlashAttentionForwardSm90',)\nif name not in ALLOWED:\n    raise ImportError(f'{name} is not exported by flash_fwd; allowed: {ALLOWED}')","typeGuard":"def has_attr(mod, name) -> bool:\n    return name == 'FlashAttentionForwardSm90'","tryCatchPattern":"try:\n    cls = getattr(flash_fwd_module, name)\nexcept AttributeError:\n    raise ImportError(f'{name} moved; import from flash_fwd_sm90 directly') from None","preventionTips":["Import symbols from their defining module (flash_fwd_sm90), not the lazy facade","After file splits, grep for old import paths before assuming they work","Pin mock.patch targets to defining modules"],"tags":["python","import","lazy-import","attributeerror","refactoring"],"backgroundTag":null,"analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}