xai-org/x-algorithm · critical · SemanticCheckFailure
ASTNode %s expected %d to %d arguments, %d passed.
Error message
ASTNode %s expected %d to %d arguments, %d passed.
What it means
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.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/ASTNode.java:181
node.getReturnType().toString())
);
}
}
public static void assertChildrenSize(
String exprText, ImmutableList<ASTNode> children, int expected) throws SemanticCheckFailure {
if (children.size() != expected) {
throw new SemanticCheckFailure(String.format(
"ASTNode %s expected %d arguments, %d passed.", exprText, expected, children.size()));
}
}
public static void assertChildrenSize(
String exprText, ImmutableList<ASTNode> children,
int min, int max) throws SemanticCheckFailure {
if (children.size() < min || children.size() > max) {
throw new SemanticCheckFailure(String.format(
"ASTNode %s expected %d to %d arguments, %d passed.",
exprText, min, max, children.size()));
}
}
public abstract Signature getSignature();
public abstract Extractor<E> toExtractor();
protected final BoxedUnit unit() {
return BoxedUnit.UNIT;
}
protected final ImmutableList<Extractor> buildExtractorsOfChildren() {
ImmutableList.Builder<Extractor> builder = ImmutableList.builder();
for (ASTNode<E> node : getChildren()) {
builder.add(node.toExtractor());
}View on GitHub (pinned to 24c60942c5)
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
Example fix
// before XAI_CUDA_CHECK(cudaMemcpy(dst, src, n, cudaMemcpyDeviceToDevice)); // after // validate pointers/devices first, and keep allocations scoped: XAI_CUDA_CHECK(cudaPointerGetAttributes(&src_attr, src)); XAI_CUDA_CHECK(cudaPointerGetAttributes(&dst_attr, dst)); assert(src_attr.device == dst_attr.device); XAI_CUDA_CHECK(cudaMemcpy(dst, src, n, cudaMemcpyDeviceToDevice));
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight before CUDA-heavy work:
size_t free = 0, total = 0;
if (cudaMemGetInfo(&free, &total) != cudaSuccess || free < required_bytes) {
// free memory, reduce sizes, or pick another device before proceeding
}
int dev = -1; cudaGetDevice(&dev);
// ensure tensors' device == dev via cudaPointerGetAttributes before memcpy/kernels Type guard
bool same_device(const void* a, const void* b) {
cudaPointerAttributes pa, pb;
if (cudaPointerGetAttributes(&pa, a) != cudaSuccess) return false;
if (cudaPointerGetAttributes(&pb, b) != cudaSuccess) return false;
return pa.device == pb.device;
} Try / catch
try {
run_xla_cuda_op(args);
} catch (const std::runtime_error& e) {
std::string msg = e.what();
if (msg.find("out of memory") != std::string::npos) {
// OOM: reduce workload and retry
} else if (msg.find("illegal memory access") != std::string::npos) {
// sticky context error: fail fast, report kernel for sanitizer run
} else {
throw;
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- type checking expression %s failed: invalid argument type: e
- type checking expression %s failed: invalid argument type: %
- ASTNode %s expected %d arguments, %d passed.
- type checking expression %s failed: expects %d arguments, %d
- no compiled async_emb binding: xrex.cuda.async_emb.src has n
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/fb35d1ac8893edb2.
Report an issue: GitHub.