moe: correct + deterministic KV-cached gpt-oss decode (single card)
Root-caused the decode non-determinism: matmul's m==1 custom-GEMV fast path reduces over K with a grid-split atomicAdd, whose float accumulation order is non-deterministic. Negligible for attention's stable pre-transposed weights, but for gpt-oss's wide expert GEMMs (K=2880, N up to 5760) over freshly-dequantized MXFP4 weights it produced visibly different results run-to-run (and a wrong argmax). Added gemm::matmul_dense (plain cublasGemmEx, no GEMV shortcut) and route the expert GEMMs through it. Now decode_step (KV cache + GPU sink-attention + MXFP4 experts) is: - deterministic: 3/3 identical runs - correct: top-1 token 12650 = " Paris" for "The capital of France is", MATCH_TOP1 with the host-attention reference forward - end-to-end: gptoss-gen generates 32 tokens at ~6.85 tok/s on one 5090. Removed the temporary A/B debug dumps. gptoss-logits runs both paths and asserts the top-1 match; gptoss-gen times greedy generation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -12,9 +12,9 @@ pub mod transpose;
|
||||
|
||||
pub use activation::{add, gelu, mul, scale, silu, silu_mul};
|
||||
pub use transpose::{merge_heads_gpu, repeat_kv_gpu, reshape_heads_gpu, strided_to_contiguous_gpu, transpose_for_rope_gpu, transpose_from_rope_gpu};
|
||||
pub use attention::{attention, decode_attention, flash_attention, paged_decode_attention};
|
||||
pub use attention::{attention, decode_attention, decode_attention_sink, flash_attention, paged_decode_attention};
|
||||
pub use embedding::embedding;
|
||||
pub use gemm::{batched_matmul, matmul, GemmBackend};
|
||||
pub use gemm::{batched_matmul, matmul, matmul_dense, GemmBackend};
|
||||
pub use layernorm::layernorm;
|
||||
pub use quant::dequant_mxfp4;
|
||||
pub use rmsnorm::{add_rmsnorm, rmsnorm};
|
||||
|
||||
Reference in New Issue
Block a user