Skip to content

【Operator Mechanism】add fused_stack_transpose_quant api #73228

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

Merged
merged 5 commits into from
Jun 14, 2025

Conversation

ggggxm
Copy link
Contributor

@ggggxm ggggxm commented Jun 10, 2025

PR Category

Operator Mechanism

PR Types

New features

Description

新增fused_stack_transpose_quant和fused_stack_quant支持

Copy link

paddle-bot bot commented Jun 10, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Jun 10, 2025
@lshpku lshpku changed the title 【Operator Mechanism 】add fused_stack_transpose_quant api 【Operator Mechanism】add fused_stack_transpose_quant api Jun 10, 2025
@ggggxm ggggxm force-pushed the stack_tranpose_quant branch from b8eefa1 to daff73d Compare June 11, 2025 06:52
@@ -2382,6 +2382,24 @@
backward: fused_softmax_mask_upper_triangle_grad
interfaces : paddle::dialect::InferSymbolicShapeInterface

- op : fused_stack_quant
Copy link
Contributor

Choose a reason for hiding this comment

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

有一个专门存放融合算子的:paddle/phi/ops/yaml/fused_ops.yaml

#include <iostream>
#include <limits>

// #include "paddle/extension.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

delete unused code

} \
}

// 对二维坐标进行swizzle变换,提供相对offset,避免bank conflict
Copy link
Contributor

Choose a reason for hiding this comment

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

中文注释清理一下

@ggggxm ggggxm force-pushed the stack_tranpose_quant branch from daff73d to 149c8c1 Compare June 13, 2025 06:08
@@ -6245,6 +6245,108 @@ void FullWithTensorInferMeta(const IntArray& shape,
out->set_dtype(dtype);
}

std::tuple<int64_t, int64_t, int64_t> FusedStackQuantCommonCheck(
Copy link
Contributor

Choose a reason for hiding this comment

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

放到fusion.h/.cc中

Comment on lines 553 to 554
std::tuple<int64_t, int64_t, int64_t> FusedStackQuantCommonCheck(
const std::vector<const MetaTensor*>& x);
Copy link
Contributor

Choose a reason for hiding this comment

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

非InferMeta函数不用把声明加到.h

@@ -0,0 +1,84 @@
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2023 -> 2025



"""
if in_dynamic_mode():
Copy link
Contributor

Choose a reason for hiding this comment

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

dynamic or pir mode

else:
return _C_ops.fused_stack_quant(x)

else:
Copy link
Contributor

Choose a reason for hiding this comment

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

else分支去掉

Comment on lines 79 to 84
dev_ctx.template Alloc<phi::dtype::float8_e4m3fn>(out);
dev_ctx.template Alloc<float>(scale);
auto out_dims = out->dims();
out->Resize(out_dims);
auto scale_dims = scale->dims();
scale->Resize(scale_dims);
Copy link
Contributor

@lshpku lshpku Jun 13, 2025

Choose a reason for hiding this comment

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

一般是先resize才alloc:

phi::DenseTensor tmp;
tmp.Resize(dim);
dev_ctx.template Alloc<T>(&tmp);
return tmp;

还有为啥要把一个tensor resize成自己的dims?这样会产生什么变化吗

@ggggxm ggggxm force-pushed the stack_tranpose_quant branch from f6798e5 to 4ddde16 Compare June 13, 2025 12:14
zyfncg
zyfncg previously approved these changes Jun 13, 2025
zhangbo9674
zhangbo9674 previously approved these changes Jun 14, 2025
Copy link
Contributor

@zhangbo9674 zhangbo9674 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhangbo9674 zhangbo9674 merged commit 36f76e1 into PaddlePaddle:develop Jun 14, 2025
47 of 52 checks passed
DrRyanHuang pushed a commit to DrRyanHuang/Paddle that referenced this pull request Jun 14, 2025
…#73228)

* add fused_stack_transpose_quant api

* modify platform check

* Revert "modify platform check"

This reverts commit 06ca104.

* split op test

* refine op test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants