THE INVESTIGATION
Rectangular matrix multiplication
Implement matrix multiplication and both input gradients.
LLM ArchitectureML foundations
What’s going wrong
Original LLM Architecture lab. Implement the missing behavior in solve(data) and keep the supplied JSON interface. Use Python’s standard library.
Given a of shape m×k, b of shape k×n and upstream of shape m×n, return product, grad_a and grad_b. Shapes are nonempty and compatible. upstream is the gradient of a scalar objective with respect to the product.
Small, well-formed JSON inputs and standard-library Python arithmetic. Keep full precision during computation. The supplied output wrapper rounds results to six decimal places.
Expected behavior
Implement matrix multiplication and both input gradients.
Reproduction
01 Rectangular projection and nonuniform gradients
{"a":[[1,2,3],[4,5,6]],"b":[[1,0],[0,1],[2,0]],"upstream":[[1,2],[3,4]]}{"product":[[7,2],[16,5]],"grad_a":[[1,2,2],[3,4,6]],"grad_b":[[13,18],[17,24],[21,30]]}02 All operands zero
{"a":[[0]],"b":[[0]],"upstream":[[5]]}{"product":[[0]],"grad_a":[[0]],"grad_b":[[0]]}03 Negative scalar factors
{"a":[[-2]],"b":[[4]],"upstream":[[-3]]}{"product":[[-8]],"grad_a":[[-12]],"grad_b":[[6]]}Before you begin
- Python functions, lists and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
Ready when you are
Every fix starts with a failing test.
Read the report, then sign in to start your investigation.