Skip to content
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

Migrate to config for Int8DynamicActivationIntxWeightConfig #1836

Merged
merged 9 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/torchao_experimental_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
pip install torch --index-url "https://download.pytorch.org/whl/nightly/cpu"
pip install numpy
pip install pytest
pip install parameterized
USE_CPP=1 pip install .
- name: Run python tests
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#pragma once
#include <cpuinfo.h>
// #include <glog/logging.h>
#include <torchao/experimental/ops/linear_8bit_act_xbit_weight/linear_8bit_act_xbit_weight.h>
#include <torchao/experimental/ops/packed_weights_header.h>

Expand Down Expand Up @@ -121,6 +120,21 @@ void check_format(PackedWeightsFormat format,
}
}

void log_registration(PackedWeightsFormat format, std::string description) {
// Logging is only supported in ATen mode
#ifdef USE_ATEN
LOG(INFO) << "Registering ukernel config for linear_8bit_act_xbit_weight" << std::endl
<< "\tDescription: " << description << std::endl
<< "\tformat.type=" << static_cast<int>(format.type) << std::endl
<< "\tformat.weight_nbit=" << format.weight_nbit << std::endl
<< "\tformat.has_weight_zeros=" << format.has_weight_zeros << std::endl
<< "\tformat.has_bias=" << format.has_bias << std::endl
<< "\tformat.nr=" << format.nr << std::endl
<< "\tformat.kr=" << format.kr << std::endl
<< "\tformat.sr=" << format.sr << std::endl;
#endif // USE_ATEN
}

template <int weight_nbit, bool has_weight_zeros, bool has_bias, bool has_clamp>
void register_ukernel_config_universal(UKernelConfigRegistrationTable &table,
PackedWeightsFormat format,
Expand All @@ -135,6 +149,7 @@ void register_ukernel_config_universal(UKernelConfigRegistrationTable &table,
if (format.nr == 8 && format.kr == 16 && format.sr == 2) {
#if defined(TORCHAO_BUILD_CPU_AARCH64)
if (cpuinfo_has_arm_neon_dot()) {
log_registration(format, "universal");
namespace kernel = torchao::kernels::cpu::aarch64::linear::
channelwise_8bit_activation_groupwise_lowbit_weight_1x8x16_f32_neondot;
table.register_ukernel_config(
Expand Down Expand Up @@ -211,6 +226,7 @@ void register_ukernel_config_kleidi(UKernelConfigRegistrationTable &table,
#if defined(TORCHAO_ENABLE_ARM_I8MM)
if (cpuinfo_has_arm_i8mm()) {
constexpr int n_step = 8;
log_registration(format, "kleidiai: matmul_clamp_f32_qai8dxp4x8_qsi4c32p8x8_4x8x32_neon_i8mm");
table.register_ukernel_config(
format, uarch,
UKernelConfig{
Expand All @@ -228,6 +244,7 @@ void register_ukernel_config_kleidi(UKernelConfigRegistrationTable &table,

if (cpuinfo_has_arm_neon_dot()) {
constexpr int n_step = 8;
log_registration(format, "kleidiai: matmul_clamp_f32_qai8dxp1x8_qsi4c32p8x8_1x8x32_neon_dotprod");
table.register_ukernel_config(
format, uarch,
UKernelConfig{
Expand All @@ -249,6 +266,7 @@ void register_ukernel_config_kleidi(UKernelConfigRegistrationTable &table,
constexpr int sr = 2;
if (cpuinfo_has_arm_neon_dot()) {
constexpr int n_step = 4;
log_registration(format, "kleidiai: matmul_clamp_f32_qai8dxp1x8_qsi4c32p4x8_1x4x32_neon_dotprod");
table.register_ukernel_config(
format, uarch,
UKernelConfig{
Expand Down
Loading
Loading