* v3.8 update x

* fix blackwell gg

* doc change

* doc change

* doc change

---------

Co-authored-by: yuzhai <yuzhai@nvidia.com>
Co-authored-by: Haicheng Wu <haichengw@nvidia.com>
Co-authored-by: Haicheng Wu <57973641+hwu36@users.noreply.github.com>
This commit is contained in:
Yujia Zhai
2025-03-21 01:52:23 -04:00
committed by GitHub
co-authored by yuzhai Haicheng Wu Haicheng Wu
parent 8c4d1dc47d
commit 62750a2b75
334 changed files with 91517 additions and 2656 deletions
@@ -275,7 +275,7 @@ private:
};
// In the mainloop, PRMT selects 1 byte from only 8 bytes so the sign bit is handled in an extra PRMT.
// Here the encodings of positive values and negative values are unified (except for the sign bit).
// Here the encodings of positive values and negative values are unified (except for the sign bit).
// For instance, 1 becomes 0b0111, which is the same encoding as -1 (0b1111).
static bool unified_encode_int4b(cutlass::int4b_t const *block_in, cutlass::int4b_t *block_out, const size_t block_size) {
@@ -430,7 +430,7 @@ void reorder_tensor(
};
static_assert(has_major_mode(stride<0>(LayoutDst{})) ^ has_major_mode(stride<1>(LayoutDst{})),
"Could not find stride-1 mode in destination layout");
constexpr int N = shape_div(Int<8>{}, sizeof_bits<T>{});
constexpr int N = shape_div(Int<8>{}, Int<sizeof_bits_v<T>>{});
auto val_layout = conditional_return<has_major_mode(stride<0>(LayoutDst{}))>(
make_layout(make_shape(Int<N>{}, Int<1>{}), GenColMajor{}),
make_layout(make_shape(Int<1>{}, Int<N>{}), GenRowMajor{}));
@@ -55,6 +55,124 @@ namespace host {
namespace detail {
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
struct TensorGreatestErrorFunc {
//
// Data members
//
TensorView<Element, Layout> lhs;
TensorView<Element, Layout> rhs;
double result;
/// Ctor
TensorGreatestErrorFunc(
TensorView<Element, Layout> const &lhs_,
TensorView<Element, Layout> const &rhs_
) :
lhs(lhs_),
rhs(rhs_),
result(0.0) { }
/// Visits a coordinate
void operator()(Coord<Layout::kRank> const &coord) {
Element lhs_ = lhs.at(coord);
Element rhs_ = rhs.at(coord);
result = std::max(result, std::abs(double(lhs_) - double(rhs_)));
}
/// Returns true if equal
operator double() const {
return result;
}
};
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
struct TensorMREFunc {
//
// Data members
//
TensorView<Element, Layout> lhs;
TensorView<Element, Layout> rhs;
double sum;
uint64_t count;
static constexpr double epsilon = 1e-6;
/// Ctor
TensorMREFunc(
TensorView<Element, Layout> const &lhs_,
TensorView<Element, Layout> const &rhs_
) :
lhs(lhs_),
rhs(rhs_),
sum(0.0),
count(0) { }
/// Visits a coordinate
void operator()(Coord<Layout::kRank> const &coord) {
Element lhs_ = lhs.at(coord);
Element rhs_ = rhs.at(coord);
sum += std::abs(double(lhs_) - double(rhs_) / (double(rhs_) + epsilon));
++count;
}
/// Returns true if equal
operator double() const {
return sum / double(count);
}
};
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
struct TensorMSEFunc {
//
// Data members
//
TensorView<Element, Layout> lhs;
TensorView<Element, Layout> rhs;
double sum;
uint64_t count;
/// Ctor
TensorMSEFunc(
TensorView<Element, Layout> const &lhs_,
TensorView<Element, Layout> const &rhs_
) :
lhs(lhs_),
rhs(rhs_),
sum(0.0),
count(0) { }
/// Visits a coordinate
void operator()(Coord<Layout::kRank> const &coord) {
Element lhs_ = lhs.at(coord);
Element rhs_ = rhs.at(coord);
sum += std::pow((double(lhs_) - double(rhs_)), 2);
++count;
}
/// Returns true if equal
operator double() const {
return sum / double(count);
}
};
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
@@ -144,6 +262,81 @@ struct TensorRelativelyEqualsFunc {
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Returns the Mean Squared Error between two tensors.
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
double TensorMSE(
TensorView<Element, Layout> const &lhs,
TensorView<Element, Layout> const &rhs) {
// Extents must be identical
if (lhs.extent() != rhs.extent()) {
return -1;
}
detail::TensorMSEFunc<Element, Layout> func(lhs, rhs);
TensorForEach(
lhs.extent(),
func
);
return double(func);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Returns the Mean Relative Error between two tensors.
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
double TensorMRE(
TensorView<Element, Layout> const &lhs,
TensorView<Element, Layout> const &rhs) {
// Extents must be identical
if (lhs.extent() != rhs.extent()) {
return -1;
}
detail::TensorMREFunc<Element, Layout> func(lhs, rhs);
TensorForEach(
lhs.extent(),
func
);
return double(func);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Returns the greatest error between two tensors.
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
double TensorGreatestError(
TensorView<Element, Layout> const &lhs,
TensorView<Element, Layout> const &rhs) {
// Extents must be identical
if (lhs.extent() != rhs.extent()) {
return -1;
}
detail::TensorGreatestErrorFunc<Element, Layout> func(lhs, rhs);
TensorForEach(
lhs.extent(),
func
);
return double(func);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Returns true if two tensor views are equal.
template <
typename Element, ///< Element type