bugger.
All challenges/Pythonhardllm-tensor-parallel-linear-v1
THE INVESTIGATION

Shard linear layers across tensor-parallel ranks

Reconstruct a bias-added linear layer from tensor-parallel shards.

LLM ArchitectureML systems

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.

Input x is a nonempty batch, bias is an output vector, shards are nonempty matrices ordered by rank, and mode is column or row. Column: every shard has all input features and some consecutive output columns; concatenate per-rank outputs. Row: each shard owns consecutive input features and all output columns; multiply against its segment of x and sum per-rank outputs. Add bias once after gathering/reducing. Return partials by rank and output.

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

Reconstruct a bias-added linear layer from tensor-parallel shards.

Reproduction

01 Row shards own different input slices
{"mode":"row","x":[[2,3]],"shards":[[[1,2]],[[3,4]]],"bias":[0.1,-0.1]}
{"partials":[[[2,4]],[[9,12]]],"output":[[11.1,15.9]]}
02 Zero activations leave only bias
{"mode":"row","x":[[0,0]],"shards":[[[1]],[[2]]],"bias":[1]}
{"partials":[[[0]],[[0]]],"output":[[1]]}
03 Column shards concatenate uneven widths
{"mode":"column","x":[[1,2]],"shards":[[[1],[2]],[[2,0],[4,1]]],"bias":[0.1,0.2,0.3]}
{"partials":[[[5]],[[10,2]]],"output":[[5.1,10.2,2.3]]}

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.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.