Datadog interview questions
Big tech · 3 questions reported
- junior 0
- mid 2
- senior 1
These are 3 technical questions candidates reported being asked in Datadog interviews for AI engineer, ML engineer and applied AI engineer roles, each with a model answer you can say out loud in a minute or two. They cover context & kv cache, agents and training: 0 junior, 2 mid-level and 1 senior questions. Every question comes from a public interview write-up that names Datadog.Updated
Datadog context windows and the KV cache questions
Model answer
Write it once as GQA: plain MHA is the case where key-value heads equal query heads, and multi-query is one key-value head.
import torch, torch.nn as nn, torch.nn.functional as F
class GQA(nn.Module):
def __init__(self, d, n_q, n_kv):
super().__init__()
self.hd, self.nq, self.nkv = d // n_q, n_q, n_kv
self.q = nn.Linear(d, d, bias=False)
self.kv = nn.Linear(d, 2 * n_kv * self.hd,
bias=False)
self.o = nn.Linear(d, d, bias=False)
def forward(self, x, cache=None):
B, T, _ = x.shape
q = self.q(x).view(B, T, self.nq, self.hd)
k, v = self.kv(x).view(
B, T, 2, self.nkv, self.hd).unbind(2)
q, k, v = (t.transpose(1, 2) for t in (q, k, v))
if cache is not None:
k = torch.cat([cache[0], k], dim=2)
v = torch.cat([cache[1], v], dim=2)
cache = (k, v) # n_kv heads: the memory saving
r = self.nq // self.nkv
k = k.repeat_interleave(r, dim=1)
v = v.repeat_interleave(r, dim=1)
S = k.shape[2] # cached + new positions
# new query i sits at position S - T + i
m = torch.ones(T, S, dtype=torch.bool,
device=x.device).tril(S - T)
a = q @ k.transpose(-2, -1) / self.hd ** 0.5
a = a.masked_fill(~m, float("-inf"))
y = F.softmax(a, dim=-1) @ v
y = y.transpose(1, 2).reshape(B, T, -1)
return self.o(y), cache
Interviewers check three things: the mask is offset by the cached length, the cache stores keys and values before repeating them, so it shrinks by the group factor, and cached decoding reproduces a full forward pass token for token.
Datadog agents questions
Model answer
A pipeline with an agent in the middle. Triage first: take only tickets with a clear reproduction and a scoped component. The agent gathers context with tools: code search, file reads, git history, and tests run in a sandbox without production credentials. It writes a failing test, edits code and loops until tests pass, under step and cost limits.
Scroll sideways to see the whole diagram
The context holds the tool definitions and the user's question.
Text version
- The context holds the tool definitions and the user's question.
- The model emits a structured call: a tool name and JSON arguments. With Anthropic's API the reply stops with stop_reason "tool_use".
- The call is text the model generated. Your code checks it before anything runs.
- Your code executes the function. The model has no hands: it only asked.
- The output goes back into the context (a tool_result block) and the model runs again, until it answers instead of calling.
After AI Engineering, Ch. 6 "Function calling", and Anthropic, "Tool use with Claude" (fetched 2026-10-21). Illustrative call.
The output is a pull request with a summary and links, always reviewed by a human.
Datadog training and optimisation questions
Model answer
Focal loss scales cross-entropy by (1 − p_t) to the power gamma, so well-classified examples add little and training focuses on hard ones; alpha rebalances the classes. Work from logits throughout.
import torch
def focal_loss(z, y, alpha=0.25, gamma=2.0):
# z: logits, y: float 0/1 targets, same shape
# stable BCE: max(z,0) - z*y + log(1+exp(-|z|))
ce = (z.clamp(min=0) - z * y
+ torch.log1p(torch.exp(-z.abs())))
p_t = torch.exp(-ce)
a_t = alpha * y + (1 - alpha) * (1 - y)
return (a_t * (1 - p_t) ** gamma * ce).mean()
Interviewers check you never take the log of a sigmoid output, that p_t comes from exp of minus the loss, and that gamma 0 recovers alpha-weighted cross-entropy.
Each question comes from a public interview write-up or video that names Datadog; the answers are ours. Not affiliated with Datadog.