文件最后提交记录最后更新时间
调整文档 Co-authored-by: weixin_44156099<heyuhang20@h-partners.com> # message auto-generated for no-merge-commit merge: !3894 merge fix_md_rope into master 调整文档 Created-by: weixin_44156099 Commit-by: weixin_44156099 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 调整ROPE算子接口文档对mropeSection描述 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> https://gitcode.com/cann/ops-transformer/issues/1772 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> 不涉及 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> posembedding/rope_with_sin_cos_cache/docs/aclnnRopeWithSinCosCache.md posembedding/rope_with_sin_cos_cache/docs/aclnnRopeWithSinCosCacheV2.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [x] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!38941 个月前
为aclnnRopeWithSinCosCacheV2接口补充说明资料 Co-authored-by: weixin_44156099<heyuhang20@h-partners.com> # message auto-generated for no-merge-commit merge: !2121 merge add_ropev2_md into master 为aclnnRopeWithSinCosCacheV2接口补充说明资料 Created-by: weixin_44156099 Commit-by: weixin_44156099 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 为aclnnRopeWithSinCosCacheV2接口补充说明资料 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> https://gitcode.com/cann/ops-transformer/issues/969 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> docs/zh/op_api_list.md posembedding/rope_with_sin_cos_cache/docs/aclnnRopeWithSinCosCacheV2.md posembedding/rope_with_sin_cos_cache/examples/test_aclnn_rope_with_sin_cos_cache_v2.cpp ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!21213 个月前
更新license Co-authored-by: PerrySkywalker<wangmingkang1@huawei.com> # message auto-generated for no-merge-commit merge: !568 merge lic into master 更新license Created-by: PerrySkywalker Commit-by: PerrySkywalker Merged-by: cann-robot Description: ## 描述 更新license <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!5685 个月前
空指针校验逻辑调整 Co-authored-by: kdy18482276080<kongdeyuan3@huawei.com> # message auto-generated for no-merge-commit merge: !2851 merge fix_rope_nullptr_check into master 空指针校验逻辑调整 Created-by: weixin_44156099 Commit-by: kdy18482276080 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 解决ROPE算子,校验第1、3输入空指针无预期报错的问题。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> https://gitcode.com/cann/ops-transformer/issues/1230 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> 编译通过; 前冒烟通过; 本地验证通过; ![image.png](https://raw.gitcode.com/user-images/assets/7673863/7cb7fe23-4290-483c-89c4-793bf91a3723/image.png 'image.png') ![image.png](https://raw.gitcode.com/user-images/assets/7673863/e059f798-2d77-4d49-bec9-eb9a94f542d8/image.png 'image.png') ![image.png](https://raw.gitcode.com/user-images/assets/7673863/8f3c8e49-2eea-4791-95b5-a509686b985d/image.png 'image.png') ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [x] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!28512 个月前
适配rope hunyuan Co-authored-by: hugh<heyuhang20@h-partners.com> # message auto-generated for no-merge-commit merge: !2187 merge add_mrope_hunyuan into master 适配rope hunyuan Created-by: weixin_44156099 Commit-by: hugh Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> rope_with_sin_cos_cache算子适配hunyuan-ocr实现,支持[16, 16, 16, 16] ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> https://gitcode.com/cann/ops-transformer/issues/1051 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> 编译:通过 冒烟测试:通过 前冒烟测试:通过 看护用例:通过 精度验证:通过 性能验证:通过 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!21872 个月前
整改st目录下的atk用例统一目录格式 Co-authored-by: yue-ma<mayue54@huawei.com> # message auto-generated for no-merge-commit merge: !5166 merge master into master 整改st目录下的atk用例统一目录格式 Created-by: yue-ma Commit-by: yue-ma Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 整改st目录下的atk用例统一目录格式 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> https://gitcode.com/cann/ops-math/issues/1538 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [x] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [x] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!516620 天前
更新license Co-authored-by: PerrySkywalker<wangmingkang1@huawei.com> # message auto-generated for no-merge-commit merge: !568 merge lic into master 更新license Created-by: PerrySkywalker Commit-by: PerrySkywalker Merged-by: cann-robot Description: ## 描述 更新license <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!5685 个月前
Wsl_transform资料修改 Co-authored-by: wang_shuli<wangshuli6@h-partners.com> # message auto-generated for no-merge-commit merge: !3489 merge master into master Wsl_transform资料修改 Created-by: wang_shuli Commit-by: wang_shuli Merged-by: cann-robot Description: ## 描述 之前没有注意到图灵的一些资料是有误的,对kirin是否支持一些数据类型添加了说明,现发现存在一定问题,进行排查修改 ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/1554 ## 测试 ## 文档更新 更新了README.md文件。 ## 类型标签 - [ ] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [x] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!34891 个月前
README.md

RopeWithSinCosCache

产品支持情况

产品 是否支持
Ascend 950PR/Ascend 950DT
Atlas A3 训练系列产品/Atlas A3 推理系列产品
Atlas A2 训练系列产品/Atlas A2 推理系列产品
Atlas 200I/500 A2 推理产品 ×
Atlas 推理系列产品 ×
Atlas 训练系列产品 ×
Kirin X90 处理器系列产品
Kirin 9030 处理器系列产品

功能说明

  • 算子功能:推理网络为了提升性能,将sin和cos输入通过cache传入,执行旋转位置编码计算。

  • 计算公式:

    1、mrope模式:positions的shape输入是[3, numTokens]:

    cosSin[i]=cosSinCache[positions[i]]cosSin[i] = cosSinCache[positions[i]]

    cos,sin=cosSin.chunk(2,dim=−1)cos, sin = cosSin.chunk(2, dim=-1)

    cos0=cos[0,:,:mropeSection[0]]cos0 = cos[0, :, :mropeSection[0]]

    cos1=cos[1,:,mropeSection[0]:(mropeSection[0]+mropeSection[1])]cos1 = cos[1, :, mropeSection[0]:(mropeSection[0] + mropeSection[1])]

    cos2=cos[2,:,(mropeSection[0]+mropeSection[1]):(mropeSection[0]+mropeSection[1]+mropeSection[2])]cos2 = cos[2, :, (mropeSection[0] + mropeSection[1]):(mropeSection[0] + mropeSection[1] + mropeSection[2])]

    cos=torch.cat((cos0,cos1,cos2),dim=−1)cos = torch.cat((cos0, cos1, cos2), dim=-1)

    sin0=sin[0,:,:mropeSection[0]]sin0 = sin[0, :, :mropeSection[0]]

    sin1=sin[1,:,mropeSection[0]:(mropeSection[0]+mropeSection[1])]sin1 = sin[1, :, mropeSection[0]:(mropeSection[0] + mropeSection[1])]

    sin2=sin[2,:,(mropeSection[0]+mropeSection[1]):(mropeSection[0]+mropeSection[1]+mropeSection[2])]sin2 = sin[2, :, (mropeSection[0] + mropeSection[1]):(mropeSection[0] + mropeSection[1] + mropeSection[2])]

    sin=torch.cat((sin0,sin1,sin2),dim=−1)sin= torch.cat((sin0, sin1, sin2), dim=-1)

    queryRot=query[...,:rotaryDim]queryRot = query[..., :rotaryDim]

    queryPass=query[...,rotaryDim:]queryPass = query[..., rotaryDim:]

    (1)rotate_half(GPT-NeoX style)计算模式:

    x1,x2=torch.chunk(queryRot,2,dim=−1)x1, x2 = torch.chunk(queryRot, 2, dim=-1)

    o1[i]=x1[i]∗cos[i]−x2[i]∗sin[i]o1[i] = x1[i] * cos[i] - x2[i] * sin[i]

    o2[i]=x2[i]∗cos[i]+x1[i]∗sin[i]o2[i] = x2[i] * cos[i] + x1[i] * sin[i]

    queryRot=torch.cat((o1,o2),dim=−1)queryRot = torch.cat((o1, o2), dim=-1)

    query=torch.cat((queryRot,queryPass),dim=−1)query = torch.cat((queryRot, queryPass), dim=-1)

    (2)rotate_interleaved(GPT-J style)计算模式:

    x1=queryRot[...,::2]x1 = queryRot[..., ::2]

    x2=queryRot[...,1::2]x2 = queryRot[..., 1::2]

    o1[i]=x1[i]∗cos[i]−x2[i]∗sin[i]o1[i] = x1[i] * cos[i] - x2[i] * sin[i]

    o2[i]=x2[i]∗cos[i]+x1[i]∗sin[i]o2[i] = x2[i] * cos[i] + x1[i] * sin[i]

    queryRot=torch.stack((o1,o2),dim=−1)queryRot = torch.stack((o1, o2), dim=-1)

    query=torch.cat((queryRot,queryPass),dim=−1)query = torch.cat((queryRot, queryPass), dim=-1)

    2、rope模式:positions的shape输入是[numTokens]:

    cosSin[i]=cosSinCache[positions[i]]cosSin[i] = cosSinCache[positions[i]]

    cos,sin=cosSin.chunk(2,dim=−1)cos, sin = cosSin.chunk(2, dim=-1)

    queryRot=query[...,:rotaryDim]queryRot = query[..., :rotaryDim]

    queryPass=query[...,rotaryDim:]queryPass = query[..., rotaryDim:]

    (1)rotate_half(GPT-NeoX style)计算模式:

    x1,x2=torch.chunk(queryRot,2,dim=−1)x1, x2 = torch.chunk(queryRot, 2, dim=-1)

    o1[i]=x1[i]∗cos[i]−x2[i]∗sin[i]o1[i] = x1[i] * cos[i] - x2[i] * sin[i]

    o2[i]=x2[i]∗cos[i]+x1[i]∗sin[i]o2[i] = x2[i] * cos[i] + x1[i] * sin[i]

    queryRot=torch.cat((o1,o2),dim=−1)queryRot = torch.cat((o1, o2), dim=-1)

    query=torch.cat((queryRot,queryPass),dim=−1)query = torch.cat((queryRot, queryPass), dim=-1)

    (2)rotate_interleaved(GPT-J style)计算模式:

    x1=queryRot[...,::2]x1 = queryRot[..., ::2]

    x2=queryRot[...,1::2]x2 = queryRot[..., 1::2]

    o1[i]=x1[i]∗cos[i]−x2[i]∗sin[i]o1[i] = x1[i] * cos[i] - x2[i] * sin[i]

    o2[i]=x2[i]∗cos[i]+x1[i]∗sin[i]o2[i] = x2[i] * cos[i] + x1[i] * sin[i]

    queryRot=torch.stack((o1,o2),dim=−1)queryRot = torch.stack((o1, o2), dim=-1)

    query=torch.cat((queryRot,queryPass),dim=−1)query = torch.cat((queryRot, queryPass), dim=-1)

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
positions 输入 Device侧的aclTensor,输入索引。 INT32、INT64 ND
queryIn 输入 Device侧的aclTensor,表示要执行旋转位置编码的第一个张量,公式中的`query`。 BFLOAT16、FLOAT16、FLOAT32 ND
keyIn 输入 Device侧的aclTensor,表示要执行旋转位置编码的第二个张量。 BFLOAT16、FLOAT16、FLOAT32 ND
cosSinCache 输入 Device侧的aclTensor,表示参与计算的位置编码张量。 BFLOAT16、FLOAT16、FLOAT32 ND
mropeSection 输入 mrope模式下用于整合输入的位置编码张量信息,公式中的`mropeSection`。 INT64 -
headSize 输入 表示每个注意力头维度大小。 INT64 -
isNeoxStyle 输入 true表示rotate\_half(GPT-NeoX style)计算模式,false表示rotate\_interleaved(GPT-J style)计算模式。 BOOL -
queryOut 输出 输出query执行旋转位置编码后的结果。 FLOAT、FLOAT16、BFLOAT16 ND
keyOut 输出 输出key执行旋转位置编码后的结果。 FLOAT、FLOAT16、BFLOAT16 ND
  • Kirin X90/Kirin 9030 处理器系列产品: 不支持 BFLOAT16。

约束说明

  • queryIn、keyIn、cosSinCache只支持2维shape输入。
  • headSize: 数据类型为BFLOAT16或FLOAT16时为32的倍数,数据类型为FLOAT32时为16的倍数。
  • rotaryDim: 始终小于等于headSize;数据类型为BFLOAT16或FLOAT16时为32的倍数,数据类型为FLOAT32时为16的倍数;mrope模式下应满足rotaryDim = mropeSection[0] + mropeSection[1] + mropeSection[2]。
  • 输入tensor positions的取值应小于cosSinCache的0维maxSeqLen。
  • aclnnRopeWithSinCosCache默认确定性实现。
  • mropeSection:取值限制为[16, 24, 24]。

调用说明

调用方式 样例代码 说明
aclnn接口 test_aclnn_rope_with_sin_cos_cache 通过aclnnRopeWithSinCosCache接口方式调用RopeWithSinCosCache算子。