Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport v3.7] SDPA fixes for regular scale tensor and alignment for K tensor #2284

Open
wants to merge 2 commits into
base: rls-v3.7-pc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gpu/intel/ocl/micro_sdpa.cl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ micro_sdpa(const global KEY_DATA_T *K, const global half *Q,
uint lda = DST_S2;

#if KEY_SCALES || KEY_ZERO_POINTS
uint ldkq = div_up(d, KEY_GROUP_SIZE);
uint ldkq = KEY_D3;
#endif
#if VAL_SCALES || VAL_ZERO_POINTS
uint ldvq = div_up(d, VAL_GROUP_SIZE);
Expand Down
9 changes: 6 additions & 3 deletions src/gpu/intel/ocl/micro_sdpa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ status_t micro_sdpa_t::pd_t::init_microkernels(impl::engine_t *engine) {
auto scale_dt = key_scales_dt();
problem_kq.Ta_scale = jit::convert_dnnl_to_kernel_type(scale_dt);
problem_kq.A_scale.alignment = uint8_t(types::data_type_size(scale_dt));
problem_kq.A_scale.layout = MatrixLayout::T;
problem_kq.A_scale.layout = MatrixLayout::N;
problem_kq.aScale2D = true;
}
if (with_key_zp()) {
auto zp_dt = key_zp_dt();
problem_kq.Tao = jit::convert_dnnl_to_kernel_type(zp_dt);
problem_kq.AO.alignment = uint8_t(types::data_type_size(zp_dt));
problem_kq.AO.layout = MatrixLayout::T;
problem_kq.AO.layout = MatrixLayout::N;
problem_kq.aoPtrDims = kq_common_zp ? 0 : 2;
problem_kq.aOffset = ABOffset::Calc;
}
Expand All @@ -264,7 +264,10 @@ status_t micro_sdpa_t::pd_t::init_microkernels(impl::engine_t *engine) {

problem_kq.B.layout = MatrixLayout::Pr;
problem_kq.C.layout = MatrixLayout::T;
problem_kq.A.setAlignment(alignmentForLD(d->head_size() * problem.Ta));
const memory_desc_wrapper key_mdw(key_md());
auto ldk = static_cast<int>(
gemm_desc_t::get_ld(*key_md()) * key_mdw.data_type_size());
problem_kq.A.setAlignment(alignmentForLD(ldk));
problem_kq.B.setAlignment(64); // Q is packed in VNNI format in SLM
problem_kq.B.crosspack = 2;
problem_kq.B.tileR = into<uint16_t>(d_max());
Expand Down
Loading