{"record":{"id":"fb35d1ac8893edb2","repo":"xai-org/x-algorithm","slug":"astnode-s-expected-d-to-d-arguments-d-passed","errorCode":null,"errorMessage":"ASTNode %s expected %d to %d arguments, %d passed.","messagePattern":"ASTNode (.+?) expected (.+?) to (.+?) arguments, (.+?) passed\\.","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"critical","filePath":"botmaker/src/java/com/twitter/botmaker/ASTNode.java","lineNumber":181,"sourceCode":"          node.getReturnType().toString())\n      );\n    }\n  }\n\n  public static void assertChildrenSize(\n      String exprText, ImmutableList<ASTNode> children, int expected) throws SemanticCheckFailure {\n    if (children.size() != expected) {\n      throw new SemanticCheckFailure(String.format(\n          \"ASTNode %s expected %d arguments, %d passed.\", exprText, expected, children.size()));\n    }\n\n  }\n\n  public static void assertChildrenSize(\n      String exprText, ImmutableList<ASTNode> children,\n      int min, int max) throws SemanticCheckFailure {\n    if (children.size() < min || children.size() > max) {\n      throw new SemanticCheckFailure(String.format(\n          \"ASTNode %s expected %d to %d arguments, %d passed.\",\n          exprText, min, max, children.size()));\n    }\n  }\n\n  public abstract Signature getSignature();\n\n  public abstract Extractor<E> toExtractor();\n\n  protected final BoxedUnit unit() {\n    return BoxedUnit.UNIT;\n  }\n\n  protected final ImmutableList<Extractor> buildExtractorsOfChildren() {\n    ImmutableList.Builder<Extractor> builder = ImmutableList.builder();\n    for (ASTNode<E> node : getChildren()) {\n      builder.add(node.toExtractor());\n    }","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/ASTNode.java#L163-L199","documentation":"XAI_CUDA_CHECK wraps every CUDA Runtime API call in the xla_utils library: it executes the condition, captures the returned cudaError_t, and throws std::runtime_error with 'cuda error: file:line: <cudaGetErrorString(error)>' when the result is not cudaSuccess. This is the standard CUDA error propagation pattern so driver/runtime failures surface as C++ exceptions instead of being silently ignored.","triggerScenarios":"Any CUDA runtime call inside phoenix/xrex/cuda/xla_utils returning an error: cudaMalloc/cudaFree failing with cudaErrorMemoryAllocation when GPU memory is exhausted, cudaErrorInvalidDeviceSymbol or invalid device pointers from wrong-device tensors, cudaMemcpy failures from inaccessible/peer-unmapped memory, or sticky context errors (cudaErrorIllegalAddress, cudaErrorAssert) from an earlier kernel surfacing on the next API call.","commonSituations":"GPU out of memory from large model/tensors, using device pointers from a different GPU or process (unified memory not enabled), MPS or MIG misconfiguration, CUDA driver/runtime version mismatch, or a prior async kernel crash whose error only appears at the next checked API call.","solutions":["Parse the trailing cudaGetErrorString text (e.g. 'out of memory', 'illegal memory access') — it names the root cause","If OOM: reduce batch/tensor sizes, free cached allocations, or move tensors to another device","If illegal address: run with compute-sanitizer to find the faulting kernel access; check index tensors for out-of-bounds values","Verify all tensors and the handle are on the same CUDA device and the device is still available (nvidia-smi)","Match CUDA runtime and driver versions and confirm the build was compiled for the present GPU architecture"],"exampleFix":"// before\nXAI_CUDA_CHECK(cudaMemcpy(dst, src, n, cudaMemcpyDeviceToDevice));\n\n// after\n// validate pointers/devices first, and keep allocations scoped:\nXAI_CUDA_CHECK(cudaPointerGetAttributes(&src_attr, src));\nXAI_CUDA_CHECK(cudaPointerGetAttributes(&dst_attr, dst));\nassert(src_attr.device == dst_attr.device);\nXAI_CUDA_CHECK(cudaMemcpy(dst, src, n, cudaMemcpyDeviceToDevice));","handlingStrategy":"try-catch","validationCode":"// Pre-flight before CUDA-heavy work:\nsize_t free = 0, total = 0;\nif (cudaMemGetInfo(&free, &total) != cudaSuccess || free < required_bytes) {\n  // free memory, reduce sizes, or pick another device before proceeding\n}\nint dev = -1; cudaGetDevice(&dev);\n// ensure tensors' device == dev via cudaPointerGetAttributes before memcpy/kernels","typeGuard":"bool same_device(const void* a, const void* b) {\n  cudaPointerAttributes pa, pb;\n  if (cudaPointerGetAttributes(&pa, a) != cudaSuccess) return false;\n  if (cudaPointerGetAttributes(&pb, b) != cudaSuccess) return false;\n  return pa.device == pb.device;\n}","tryCatchPattern":"try {\n  run_xla_cuda_op(args);\n} catch (const std::runtime_error& e) {\n  std::string msg = e.what();\n  if (msg.find(\"out of memory\") != std::string::npos) {\n    // OOM: reduce workload and retry\n  } else if (msg.find(\"illegal memory access\") != std::string::npos) {\n    // sticky context error: fail fast, report kernel for sanitizer run\n  } else {\n    throw;\n  }\n}","preventionTips":["Check cudaGetLastError() after every kernel launch in debug builds to localize failures","Run compute-sanitizer in CI for kernels handling user-supplied indices","Keep runtime/driver versions aligned and verify with nvidia-smi before jobs","Validate index tensors are within [0, size) on the host or via a bounds-check kernel"],"tags":["cuda","runtime-error","gpu-memory","driver","cuda-api"],"backgroundTag":"cuda-runtime-api-error","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}