Reinforcement learning for driving: PPO vs GRPO and a speed-limit reward
I was asked this
No reports yet. Sign in to say where you were asked it.
An AI/ML design interview question asked in Tesla's technical phone screen, last asked Feb 2026. It tests reinforcement learning, reward design and autonomous driving.
You are training a reinforcement-learning policy to drive a vehicle. The interview goes from policy-optimization theory, to reward-design judgment, to writing a reward and finding where it breaks.
Part A: PPO vs GRPO
Explain how PPO and GRPO differ: the objective each optimizes, how each estimates the advantage, what each needs at training time besides the policy, and when you would pick one over the other.
Part B: heuristic vs learned reward
When would you use a hand-written reward, and when a learned reward model (for example, one trained on human preferences)? Discuss the trade-offs and how you would combine them.
Part C: a speed-limit reward
Trajectories arrive as traj with shape [batch, num_waypoint, 2] (x, y positions in a metric frame), sampled at 10 Hz, so consecutive waypoints are 0.1 s apart. The environment has a speed limit.
- Write a vectorized reward (or penalty) that discourages speeding. Give two variants: one that penalizes the time spent over the limit, and one that penalizes how far over the limit the vehicle goes.
- The real limit changes over time (for example 50 mph for the first 2 s, then 30 mph for the next 3 s), but your reward assumes one constant. What goes wrong?
- More generally, the limit changes but is not part of the agent's observation. What is broken, and how do you fix the setup?
Requirements
- Functional: speeds derived from positions; per-step or per-trajectory reward over the whole batch, no Python loop over the batch.
- Non-functional: a reward signal that is consistent, hard to game and safe.
Clarifying questions
- Which units are positions and the speed limit in? Is unit conversion part of the task?
- Per-step reward
[batch, num_waypoint - 1]or one scalar per trajectory? - Is the limit a scalar, per trajectory or per step?
- Is this classic continuous-control RL, or RLHF-style fine-tuning of a driving model?
What a strong answer covers
- PPO: clipped probability-ratio objective, a learned critic with GAE advantages, a KL or clip to stay near the old policy. GRPO: several samples per context, advantage = reward normalized by the group's mean and standard deviation, no critic. The trade-off: critic cost and instability vs needing many samples per context and noisy group statistics.
- Hand-written rewards for crisp rules (speeding, collisions); learned rewards for fuzzy preferences (comfort, naturalness); reward hacking on both sides; safety terms dominating.
- Speed as
norm(diff(traj, axis=1), axis=-1) / 0.1; variant one as an indicator (or count) of steps over the limit, variant two asrelu(v - v_max)(or squared); their different gradient shapes; the hard-braking-at-the-boundary behavior they can cause. - A constant limit under-penalizes when the real limit drops and over-penalizes when it rises; the fix is a per-step
v_max(t). - A limit missing from the observation breaks the Markov property: the right action depends on something the agent cannot see. Fixes: put the limit in the observation, give history to a recurrent or contextual policy, randomize limits in training. Computing the limit after the fact from the log is an oracle the policy never has online.
Follow-ups
- You must keep a constant-limit reward for legacy reasons. How would you detect that the agent is training against a hidden, time-varying objective?
- How does randomizing speed limits in training interact with a recurrent policy that infers the limit?
- Variant one is not differentiable. Does that matter for policy gradients? When does the smoother variant help?
- Extend the reward to discourage harsh braking at a limit change without double-counting the speed penalty.
Where it's asked
- Tesla · Technical phone screen · Last asked Feb 202645 min · 10 to 20 minutes on your background, then one compact coding, debugging or design task in CoderPad that must run
What it tests
reinforcement learning · reward design · autonomous driving
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
