Skip to content

fix: add metax videonsa native operators - #1062

Open
wooway777 wants to merge 1 commit into
masterfrom
fix/metax-videonsa-ops
Open

wooway777 wants to merge 1 commit into
masterfrom
fix/metax-videonsa-ops

Conversation

@wooway777

Copy link
Copy Markdown
Contributor

Summary

Motivation

Closes #

Type of Change

  • feat — new feature / new operator / new platform
  • fix — bug fix
  • perf — performance improvement (no behavioral change)
  • refactor — code restructuring without behavior change
  • test — adding or fixing tests only
  • docs — documentation only
  • build / ci — build system or CI configuration
  • chore — tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

paste smoke test output here

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA
Iluvatar
MetaX
Cambricon
Moore
Ascend
Full `pytest` output (optional)
paste here

Benchmark / Performance Impact

Notes for Reviewers

@wooway777
wooway777 requested a review from a team December 4, 2026 02:42
Comment thread src/native/cuda/metax/ops/cat/kernel.h Outdated
namespace infini::ops {

template <>
class Operator<Cat, Device::Type::kMetax, 0> : public Cat {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cat和take算子是不是可以先加类cuda算子(src/native/cuda/ops),然后metax继承啊?
sum算子在src/native/cuda/ops 下面已经有实现了,看看是不是可以直接继承。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

已按这个方向处理:

  • cat、take 新增了通用 CUDA-style 实现,分别在 src/native/cuda/ops/cat/kernel.h 和 src/native/cuda/ops/take/kernel.h,MetaX wrapper 现在直接继承它们。
  • sum 原来的 src/native/cuda/ops/sum/kernel.cuh 只是 NVIDIA kernel 片段,不能直接继承;我补了通用 CudaSum 和 sum_kernel.cuh,MetaX wrapper 也改为继承通用实现。

验证结果:pytest tests/test_cat.py --devices metax 30 passed,另外 sum/take/cat 的最小对比脚本也和 PyTorch 参考一致。

float dropout_p, float softmax_scale, bool zero_tensors, bool causal,
int window_size_left, int window_size_right, float softcap,
bool return_softmax, std::optional<at::Generator> generator,
std::optional<at::Tensor>& flash_attn_mars_ext, bool return_max_logit);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

我对照了 #1033 的改动。这里不是直接把 return_max_logit 删掉,而是把底层 required_symbols 对齐到当前 flash-attn 库实际导出的 23 参数符号,同时保留了一个 24 参数 inline overload,让上层旧写法继续编译并转发到 23 参数实现。

也就是说,return_max_logit 只是被兼容层吞掉,不会影响现有上层调用;当前调用本来传的是 false,行为不变。

@wooway777
wooway777 force-pushed the fix/metax-videonsa-ops branch from f06918f to 3fab2ca Compare December 4, 2026 10:09

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants