{"record":{"id":"90d799ac94f76f11","repo":"vllm-project/vllm","slug":"call-module-is-not-allowed-for-codegen-target-tar","errorCode":null,"errorMessage":"call_module is not allowed for codegen target {target}.","messagePattern":"call_module is not allowed for codegen target (.+?)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vllm/compilation/codegen.py","lineNumber":67,"sourceCode":"        users = list(node.users.keys())\n        if not users:\n            continue\n        last_user = max(users, key=lambda u: node_order[u])\n        if last_user.op == \"output\":\n            continue\n        del_after.setdefault(node_order[last_user], []).append(node.name)\n\n    def ref(arg: Any) -> str:\n        return _node_ref(arg, consts, const_index)\n\n    for i, node in enumerate(nodes):\n        if node.op == \"placeholder\":\n            param_names.append(node.name)\n\n        elif node.op == \"call_module\":\n            target = node.target\n            if not with_submod:\n                raise RuntimeError(\n                    f\"call_module is not allowed for codegen target {target}.\"\n                )\n            if target not in submod_index:\n                submod_index[target] = len(submod_names)\n                submod_names.append(target)\n            idx = submod_index[target]\n            args_str = \", \".join(ref(a) for a in node.args)\n            kwargs_str = \", \".join(f\"{k}={ref(v)}\" for k, v in node.kwargs.items())\n            all_args = \", \".join(filter(None, [args_str, kwargs_str]))\n            submod = getattr(split_gm, target)\n            if isinstance(submod, torch.fx.GraphModule):\n                callable_name = f\"__vllm_inlined_submods__{idx}\"\n                inlined_code, _, _ = generate_execution_code_with_name(\n                    submod,\n                    callable_name,\n                    with_submod=False,\n                    consts=consts,\n                    const_index=const_index,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/compilation/codegen.py#L49-L85","documentation":"The FX-graph code generator turns a split GraphModule back into plain Python source. After splitting, nodes should be call_function/getattr/placeholder/output; encountering a call_module node (an un-inlined submodule) is only legal when with_submod=True (which emits the submodule as an inlined closure). With with_submod=False the code generator cannot reference the module, so it raises RuntimeError naming the offending target.","triggerScenarios":"Calling the codegen helper on a graph that still contains call_module nodes (not fully traced/inlined by dynamo, e.g. a module boundary dynamo did not inline) with with_submod=False.","commonSituations":"Model code with modules that dynamo fails to trace (custom Module subclasses with __call__ side effects, module-level state), or internal callers invoking the codegen utility on unsplit graphs; usually a vLLM/torch version-compat issue rather than a user config error.","solutions":["Pass with_submod=True so call_module nodes are emitted as inlined submodule closures","Re-split the graph (split_gm) so module calls are lowered before codegen","If tracing from model code, refactor the module into functional calls dynamo can inline, or report a vLLM bug with the graph"],"exampleFix":"# before\ncode = codegen(fn_name, nodes, split_gm, consts, with_submod=False)\n# after\ncode = codegen(fn_name, nodes, split_gm, consts, with_submod=True)","handlingStrategy":"validation","validationCode":"bad = [n for n in graph.nodes if n.op == \"call_module\"]\nassert with_submod or not bad, f\"graph still has call_module nodes: {[n.target for n in bad]}\"","typeGuard":"def codegen_ready(graph: torch.fx.Graph, with_submod: bool) -> bool:\n    return with_submod or all(n.op != \"call_module\" for n in graph.nodes)","tryCatchPattern":null,"preventionTips":["Split/inline graphs before codegen","Pass with_submod=True when module boundaries may survive tracing"],"tags":["compilation","torch-compile","fx-graph","codegen","internal"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}