JAXBench: Fix Megablox GMM no-op exploit: use realistic non-underflowing inputs#49
Open
charleshong3 wants to merge 1 commit into
Open
Conversation
The 11p_Megablox_GMM baseline scaled inputs by limit=1/(M*K) ~= 7.45e-9 (uniform), so each output element was ~2e-13 and underflowed toward zero in bf16. The reference output was therefore ~0 everywhere, which let a no-op kernel (returning zeros, or skipping the grouped matmul entirely) trivially pass np.allclose(atol=1e-2) and report an enormous, meaningless speedup (observed in practice: a degenerate kernel timing ~0.1 ms / ~27x). This replaces the inputs with small-normal weights/activations (~0.02 scale, output max ~0.14 / mean ~0.02 -- bf16-representable, no K=4096 overflow) and a simulated top-k router with mild popularity bias (router_bias_scale=0.15) so group sizes are realistic and non-uniform. max_expert_size is a static jit arg (added to CONFIG so harnesses that read static_argnums lower the reference correctly). With these inputs a no-op kernel now fails correctness. Scope: this fixes Megablox's input-underflow mechanism specifically. A separate and distinct no-op class -- KernelBench-derived baselines (18k-50k) that initialize weights/bias to jnp.zeros, yielding an all-zero reference -- is not addressed here and is left to a follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 11p_Megablox_GMM baseline scaled inputs by limit=1/(M*K) ~= 7.45e-9 (uniform), so each output element was ~2e-13 and underflowed toward zero in bf16. The reference output was therefore ~0 everywhere, which let a no-op kernel (returning zeros, or skipping the grouped matmul entirely) trivially pass np.allclose(atol=1e-2) and report an enormous, meaningless speedup (observed in practice: a degenerate kernel timing ~0.1 ms / ~27x).
This replaces the inputs with small-normal weights/activations (~0.02 scale, output max ~0.14 / mean ~0.02 -- bf16-representable, no K=4096 overflow) and a simulated top-k router with mild popularity bias (router_bias_scale=0.15) so group sizes are realistic and non-uniform. max_expert_size is a static jit arg (added to CONFIG so harnesses that read static_argnums lower the reference correctly). With these inputs a no-op kernel now fails correctness.
Scope: this fixes Megablox's input-underflow mechanism specifically. A separate and distinct no-op class -- KernelBench-derived baselines (18k-50k) that initialize weights/bias to jnp.zeros, yielding an all-zero reference -- is not addressed here and is left to a follow-up.