bugger.
All challenges/Pythonmediumllm-swiglu-v1
THE INVESTIGATION

SiLU and the SwiGLU feed-forward layer

Implement a SwiGLU feed-forward network with intermediate expansion.

LLM ArchitectureTransformer components

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 batch of input rows of width D; gate and up are D×F matrices, and down is F×O. Compute SiLU(x·gate) elementwise, multiply with x·up, then project through down. SiLU(z) is z times a stable sigmoid. Return the batch of output rows.

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 a SwiGLU feed-forward network with intermediate expansion.

Reproduction

01 Expansion mixes distinct gate and up features
{"x":[[1,2]],"gate":[[1,0,2],[0,1,-1]],"up":[[0,2,1],[1,0,1]],"down":[[1,0],[0,1],[2,1]]}
[[1.462117,3.523188]]
02 Zero gates suppress the up projection
{"x":[[1]],"gate":[[0]],"up":[[5]],"down":[[9]]}
[[0]]
03 Large negative gates remain finite
{"x":[[1]],"gate":[[-1000]],"up":[[2]],"down":[[1]]}
[[0]]

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.