feat(CRITICAL): 从 GitHub 扫描搬运 ixformer SDK + xllm 完整 GDN/MoE 代码
来源:
1. Chranos/ixformer (GitHub) → ixformer_sdk/ (230 files, 70K lines)
- inference/functions/vllm.py: vllm_moe_topk_softmax 完整实现 (2033 lines)
- inference/functions/moe.py: MoE ops 完整实现 (1380 lines)
- contrib/vllm_flash_attn/: FA2 Python 接口 (1018 lines)
- contrib/tgi/fused_moe.py: TGI fused MoE (429 lines)
- csrc/include/ixformer/: C++ kernel headers + cmake
2. Deep-Spark/xllm (GitHub) → upstream_ref/xllm_latest/ (+15 files)
- npu_torch/qwen3_5_decoder_layer_impl.cpp/.h
- npu_torch/qwen3_5_gated_delta_net.cpp/.h
- npu_torch/qwen3_next_*.cpp/.h (6 files)
- npu_torch/attention.cpp/.h + fused_moe.cpp/.h + CMakeLists.txt
- models/llm/qwen3_5.h + qwen3_5_mtp.h + qwen3_next.h
- models/vlm/qwen3_5.h
调用链完整性:
ixformer_sdk/inference/functions/vllm.py
→ ops.infer.moe_topk_softmax() (C++ 层)
→ 这就是 base 镜像 libixformer.so 里的实现
upstream_ref/xllm_latest/core/layers/ilu/fused_moe.cpp
→ ixformer::infer::topk_softmax() (直接 C++ 调用)
→ ixformer::infer::group_gemm() → 完整 7-step MoE pipeline
This commit is contained in:
22
ixformer_sdk/csrc/include/ixformer/kernels/error.h
Normal file
22
ixformer_sdk/csrc/include/ixformer/kernels/error.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "status.h"
|
||||
|
||||
namespace ixformer::kernels {
|
||||
|
||||
class KernelError : public std::runtime_error {
|
||||
public:
|
||||
template<class ERROR_STR>
|
||||
KernelError(KernelStatus error, const ERROR_STR str) : error_{error}, std::runtime_error(str) {}
|
||||
|
||||
KernelStatus status() {
|
||||
return error_;
|
||||
}
|
||||
|
||||
private:
|
||||
KernelStatus error_;
|
||||
};
|
||||
|
||||
}// namespace ixformer::kernels
|
||||
2520
ixformer_sdk/csrc/include/ixformer/kernels/kernels.h
Normal file
2520
ixformer_sdk/csrc/include/ixformer/kernels/kernels.h
Normal file
File diff suppressed because it is too large
Load Diff
20
ixformer_sdk/csrc/include/ixformer/kernels/status.h
Normal file
20
ixformer_sdk/csrc/include/ixformer/kernels/status.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ixformer::kernels {
|
||||
|
||||
enum KernelStatus {
|
||||
kernelSuccess,
|
||||
kernelFail,
|
||||
kernelCudaError,
|
||||
kernelInvalidArgument,
|
||||
kernelCuinferError,
|
||||
kernelUnsupported,
|
||||
};
|
||||
|
||||
|
||||
std::string to_string(KernelStatus status);
|
||||
|
||||
|
||||
}// namespace ixformer::kernels
|
||||
92
ixformer_sdk/csrc/include/ixformer/kernels/tensor.h
Normal file
92
ixformer_sdk/csrc/include/ixformer/kernels/tensor.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ixformer::kernels {
|
||||
|
||||
const uint8_t MAX_TENSOR_NDIM = 8;
|
||||
|
||||
// align with at::ScalarType
|
||||
enum DType {
|
||||
Byte = 0,
|
||||
Char = 1,
|
||||
Short = 2,
|
||||
Int = 3,
|
||||
Long = 4,
|
||||
Half = 5,
|
||||
Float = 6,
|
||||
Double = 7,
|
||||
ComplexHalf = 8,
|
||||
ComplexFloat = 9,
|
||||
ComplexDoubl = 10,
|
||||
Bool = 11,
|
||||
QInt8 = 12,
|
||||
QUInt8 = 13,
|
||||
QInt32 = 14,
|
||||
BFloat16 = 15,
|
||||
QUInt4x2 = 16,
|
||||
QUInt2x4 = 17,
|
||||
Bits1x8 = 18,
|
||||
Bits2x4 = 19,
|
||||
Bits4x2 = 20,
|
||||
Bits8 = 21,
|
||||
Bits16 = 22,
|
||||
Float8_e5m2 = 23,
|
||||
Float8_e4m3fn = 24,
|
||||
Undefined = 25,
|
||||
NumOptions = 26
|
||||
};
|
||||
|
||||
struct TensorDesc {
|
||||
|
||||
public:
|
||||
// delete default constructor
|
||||
TensorDesc() = delete;
|
||||
// All information must be (should be) prepared when constructing a TensorDesc object.
|
||||
TensorDesc(DType scalar_type, void *data_ptr, int64_t numel, int64_t dim, const int64_t *size, const int64_t *stride, bool is_contiguous, bool is_cuda)
|
||||
: dtype(scalar_type), ptr(data_ptr), nnumel(numel), ndim(dim), sizes(size), strides(stride), contiguous(is_contiguous), cuda(is_cuda) {}
|
||||
|
||||
inline DType scalar_type() const {
|
||||
return dtype;
|
||||
}
|
||||
|
||||
inline void *data_ptr() const {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline int64_t numel() const {
|
||||
return nnumel;
|
||||
}
|
||||
|
||||
inline int64_t dim() const {
|
||||
return ndim;
|
||||
}
|
||||
|
||||
inline int64_t size(int64_t dim) const {
|
||||
return dim < 0 ? sizes[ndim - dim] : sizes[dim];
|
||||
}
|
||||
|
||||
inline int64_t stride(int64_t dim) const {
|
||||
return dim < 0 ? strides[ndim - dim] : strides[dim];
|
||||
}
|
||||
|
||||
inline bool is_contiguous() const {
|
||||
return contiguous;
|
||||
}
|
||||
|
||||
inline bool is_cuda() const {
|
||||
return cuda;
|
||||
}
|
||||
|
||||
private:
|
||||
void *ptr{nullptr};
|
||||
DType dtype;
|
||||
int64_t nnumel{0};
|
||||
int64_t ndim{0};
|
||||
const int64_t *sizes{nullptr};
|
||||
const int64_t *strides{nullptr};
|
||||
bool contiguous{false};
|
||||
bool cuda{false};
|
||||
};
|
||||
|
||||
}// namespace ixformer::kernels
|
||||
Reference in New Issue
Block a user