Skip to content

fix: change jaxbench 42k to avoid producing zero output - #76

Merged
shangkunwang01 merged 2 commits into
mainfrom
shangkun-fix-jaxbench-42k
Jul 31, 2026
Merged

fix: change jaxbench 42k to avoid producing zero output#76
shangkunwang01 merged 2 commits into
mainfrom
shangkun-fix-jaxbench-42k

Conversation

@shangkunwang01

Copy link
Copy Markdown
Collaborator

No description provided.

@shangkunwang01
shangkunwang01 requested a review from NinaCai July 30, 2026 17:24
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

x = jnp.matmul(x, weight) + bias
x = jnp.max(x, axis=1, keepdims=True)
x = x - jnp.mean(x, axis=1, keepdims=True)
x = jnp.max(x, axis=1, keepdims=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to change the order of operations? Looks like the new order is not consistent with the order in the folder name.

x = jnp.matmul(x, weight) + bias
x = jnp.max(x, axis=1, keepdims=True)
x = x - jnp.mean(x, axis=1, keepdims=True)
x = jnp.max(x, axis=1, keepdims=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original operation will always output zero no matter what input you give. Agent will find this issue and produce a kernel that just produce zero.The kernel will be super fast and the speedup can be 100×. So the original operation is actually not a good test case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you changed x,weight,bias to non-zero values, but I don't understand why do you change matmul->max->subtract->gelu to matmul->subtract->max->gelu? My confusion part is the order in computation().

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the input is not enough. No matter what input, the final result will be zero. What I did is actually changing the operation. We may change the name of this operation if you think it is needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be another way to make this operation makes more sense: we should not change the x to be its maximum. I will make a new commit.

@NinaCai NinaCai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: How do we decide the benchmark here? Is it extracted from maxtext or just a combinations of different operations? If such combination is never used in any model, why do we want to benchmark them?

@shangkunwang01

Copy link
Copy Markdown
Collaborator Author

Out of curiosity: How do we decide the benchmark here? Is it extracted from maxtext or just a combinations of different operations? If such combination is never used in any model, why do we want to benchmark them?

It is adapted from KernelBench https://github.com/ScalingIntelligence/KernelBench/blob/main/KernelBench/level2/80_Gemm_Max_Subtract_GELU.py.
The original workload also has this degenerate issue.

@shangkunwang01
shangkunwang01 merged commit db70eab into main Jul 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants