Course · Autodiff & JAX internalsPhase 14 · Study guide

Which mathematical operation does the transformed program represent?

Domain Specialization · Local CPULaptop CPU4 lessons (~7.4h)

Revision v0.18.1 ·

Transformations become less mysterious when you follow the quantities they carry. A primal is the ordinary value, a tangent describes change in an input direction, and a cotangent weights changes in outputs. Their shapes and roles explain why forward- and reverse-mode products answer different questions. Read one transformed equation with an independent derivative beside it. Check the adjoint relationship, then challenge a custom rule at a different base point and direction. Internal printed names are incidental; the mathematical relationship and the supported primitive boundary are what you need to understand.

Preparation: Math & optimization

Runtime: CPU

Check your starting point

A function maps an input vector to an output vector. Does a JVP multiply by the Jacobian or its transpose?

Compare your reasoning

A JVP maps an input tangent through the Jacobian. A VJP maps an output cotangent through its transpose. Check the spaces and the adjoint inner-product identity.

If this is unfamiliar, work through JVPs, VJPs, and higher-order derivatives before attempting the project.

Build in stages

1. Read and check transformed programs

Follow one jaxpr equation, compare directional derivatives independently and verify the adjoint identity at changed inputs.

2. Enforce a custom transformation boundary

Require tangent linearity and test higher-order promises. For the tiny interpreter, reject unsupported primitives rather than returning a plausible incomplete result.

Try a changed condition

Make a prediction before opening the reasoning. Keep your answer and the evidence you would collect.

A proposed JVP returns 2xv22xv^2 for f(x)=x2f(x)=x^2. It agrees at direction 1. Test direction 2 and explain the failure.

Compare an approach

The correct derivative map is 2xv2xv. At direction 2 the proposal gives 8x8x instead of 4x4x, except at the uninformative base point zero. Test nonzero base points and linear combinations of directions, then compare against an independent primal derivative.

Diagnose a likely failure

Symptom: A derivative test passes at one input but fails after a shift.

Check next: Inspect captured constants, detached values and custom rules. Compare both primal and derivative behavior at changed base points.

Decide what is ready

Use derivative-audit. Keep analytic/directional checks, the adjoint identity, supported higher-order behavior and explicit unsupported-program rejections.

Where to put your project code

Write your code in: projects/derivative-audit/my_model.py (copy projects/derivative-audit/starter/model.py first: cp projects/derivative-audit/starter/model.py projects/derivative-audit/my_model.py).

Verify your implementation: python3 projects/derivative-audit/tests/check.py --stage all --impl projects/derivative-audit/my_model.py

Run the staged project checks on your implementation in projects/derivative-audit/my_model.py and record your transfer experiment results in your portfolio.

Open Audit derivatives and a tiny transformation

What still needs further work

The tiny interpreter is intentionally incomplete. Production extension APIs, effects and full compiler transformation coverage require further targeted work.