rohitg00/ai-engineering-from-scratch · error · ValueError
unknown op {op}
Error message
unknown op {op} What it means
Error "unknown op {op}" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/19-capstone-projects/76-collective-ops-from-scratch/code/main.py:229
dtype = getattr(torch, dtype_str)
tensor = torch.frombuffer(bytearray(tensor_bytes), dtype=dtype).reshape(shape).clone()
if op == "allreduce":
dist.all_reduce(tensor, op=dist.ReduceOp.SUM)
out = tensor
elif op == "broadcast":
dist.broadcast(tensor, src=0)
out = tensor
elif op == "allgather":
gathered = [torch.zeros_like(tensor) for _ in range(world_size)]
dist.all_gather(gathered, tensor)
out = torch.cat(gathered)
elif op == "reduce_scatter":
chunks = [c.contiguous() for c in tensor.chunk(world_size)]
recv = torch.zeros_like(chunks[0])
dist.reduce_scatter(recv, chunks, op=dist.ReduceOp.SUM)
out = recv
else:
raise ValueError(f"unknown op {op}")
out_queue.put((rank, out.clone()))
out_queue.close()
out_queue.join_thread()
os._exit(0)
def gloo_reference(op: str, world_size: int,
per_rank_tensors: list) -> list:
"""Run the same operation through torch.distributed gloo for verification.
Uses file-based init (file:// URI) because TCP init through libuv has
known issues on macOS with concurrent process group creation.
"""
ctx = mp.get_context("spawn")
out_queue = ctx.Queue()
init_dir = tempfile.mkdtemp(prefix="aie_gloo_")
init_file = os.path.join(init_dir, "rendezvous")
iface = _loopback_iface()View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/19-capstone-projects/76-collective-ops-from-scratch/code/main.py:229 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/43d47f138470ae06.
Report an issue: GitHub.