Skip to content

Commit

Permalink
[Bugfix] Fix the incorrect offset computation for SGMV shrink (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzh119 authored Nov 27, 2023
1 parent 91f1592 commit 51cd092
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions csrc/sgmv_flashinfer/sgmv_flashinfer.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ __global__ void sgmv_shrink(T* y, T* x, T** w, IdType* s, float* tmp,
offset += 8;
}
row_idx += 8;
y_ptr += 8 * d_out;
y_ptr += 8 * d_out - 2 * num_blocks_n * cell_capacity<T>();
offset += 8 * num_cells_n - 4 * num_blocks_n;
}
}
Expand Down Expand Up @@ -329,7 +329,7 @@ __global__ void sgmv_shrink(T* y, T* x, T** w, IdType* s, float* tmp,
offset += 8;
}
row_idx += 8;
y_ptr += 8 * d_out;
y_ptr += 8 * d_out - 2 * num_blocks_n * cell_capacity<T>();
offset += 8 * num_cells_n - 4 * num_blocks_n;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sgmv.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def lora_ref_impl(
pytest.param("expand", marks=pytest.mark.xfail(reason="TODO: sgmv expand")),
],
)
@pytest.mark.parametrize("batch_setup", ["1x7", "7x1", "3x3"])
@pytest.mark.parametrize("batch_setup", ["1x7", "7x1", "3x3", "32x1", "1x32"])
@torch.inference_mode()
def test_sgmv_correctness(dtype_str, h, r, direction, batch_setup):
torch.manual_seed(0xABCDABCD987)
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_sgmv_correctness(dtype_str, h, r, direction, batch_setup):

@pytest.mark.xfail(reason="TODO: sgmv expand")
@pytest.mark.parametrize("dtype_str", ["float16", "bfloat16"])
@pytest.mark.parametrize("batch_setup", ["1x7", "7x1", "3x3"])
@pytest.mark.parametrize("batch_setup", ["1x7", "7x1", "3x3", "32x1", "1x32"])
@torch.inference_mode()
def test_lora_correctness(dtype_str, batch_setup):
torch.manual_seed(0xABCDABCD987)
Expand Down

0 comments on commit 51cd092

Please sign in to comment.