Skip to content
Open
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
6 changes: 6 additions & 0 deletions optimized_inference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ foreach(size IN ITEMS 2 8)
if(size EQUAL 8)
target_sources(backend8 PRIVATE src/models/dpdfnet2_48khz_hr/qaffine4pair64_fused_avx2.S)
target_compile_definitions(backend8 PRIVATE DPDF_QBATCH_FUSED64_AVX2)
if(DPDF_ENABLE_AVX_VNNI AND DPDF_COMPILER_HAS_AVX_VNNI)
target_compile_definitions(backend8 PRIVATE DPDF_MODEL8_VNNI_FUSION)
target_sources(backend8 PRIVATE src/models/dpdfnet2_48khz_hr/qaffine4pair64_fused_vnni.S)
endif()
endif()
target_compile_options(backend${size} PRIVATE $<$<COMPILE_LANGUAGE:C>:-fno-math-errno>)
# Only model 8 had a confirmed incremental branch-alignment benefit.
Expand Down Expand Up @@ -228,6 +232,8 @@ if(BUILD_TESTING)
set(vnni_contracts fused_contract pair_contract)
if(size EQUAL 2)
list(APPEND vnni_contracts wide_contract pair_fused_contract)
else()
list(APPEND vnni_contracts pair_fused_contract)
endif()
foreach(test IN LISTS vnni_contracts)
set(target "model${size}_${test}_vnni")
Expand Down
15 changes: 15 additions & 0 deletions optimized_inference/docs/PERFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ The current defaults were selected separately for models 2 and 8 on an
Intel Core i7-7700T. The older i7-8700 latency/quality records below describe
the historical package baseline; they were not remeasured for these defaults.

## Model 8 AVX-VNNI fused K64 projections

On CPUs selected by the existing AVX-VNNI dispatch, model 8 reuses the
four-row fused kernel for eligible K64 batch and paired projections. It
combines the packed integer dot products with the existing floating-point
scale and bias. The existing shape guards, quantization arithmetic, and
model weights and public ABI are preserved. Model 2 and the AVX2 path keep
their existing kernel selection.

In the [paired Ryzen qualification on the channel-major baseline](https://github.com/varyagnord/DPDFNet/blob/bd4138752e2c100ced0a59ecf78e4b203b4901f3/optimized_inference/docs/MODEL8_VNNI_EXPERIMENTS.md),
six model-8 workloads passed the useful-gain, precision, and operational
gates, with 0.80–1.21% lower inference or callback time in those conditions.
This range describes that measured configuration. Other conditions were
inconclusive, including the full-audio Boost runs.

## i7-7700T final per-model selection (2026-10-27)

G replaces depthwise gather with bounded loads/permutations; V combines an
Expand Down
16 changes: 11 additions & 5 deletions optimized_inference/src/common/int8_kernels.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
_mm256_maddubs_epi16(a,w),_mm256_set1_epi16(1)))
#endif

#if defined(DPDF_QPAIR_FUSED64) || (defined(DPDF_QBATCH_FUSED64_AVX2) && !defined(DPDF_INT8_VNNI))
#if defined(DPDF_QPAIR_FUSED64) || (defined(DPDF_QBATCH_FUSED64_AVX2) && !defined(DPDF_INT8_VNNI)) || (defined(DPDF_MODEL8_VNNI_FUSION) && defined(DPDF_INT8_VNNI))
#define DPDF_USE_QBATCH_FUSED64
#endif
#if defined(DPDF_QPAIR_FUSED64) || (defined(DPDF_MODEL8_VNNI_FUSION) && defined(DPDF_INT8_VNNI))
#define DPDF_USE_QPAIR_FUSED64
#endif
#if defined(DPDF_USE_QBATCH_FUSED64) || defined(DPDF_USE_QPAIR_FUSED64)
#define DPDF_USE_FUSED4
#endif

static void quantize(const float *x,int8_t *out,int k,float *scale,int *zp) {
__m256 lo=_mm256_setzero_ps(),hi=lo;
Expand Down Expand Up @@ -256,9 +262,9 @@ static __attribute__((noinline)) void qdot4pair(const int8_t *activation,
qdot4pair_generic(activation,packed0,packed1,k,out);
}

#if DPDF_MODEL_SIZE == 2 || defined(DPDF_USE_QPAIR_FUSED64)
#if DPDF_MODEL_SIZE == 2 || defined(DPDF_USE_FUSED4)

#ifdef DPDF_USE_QPAIR_FUSED64
#ifdef DPDF_USE_FUSED4
#include "pair_fused_args.h"
static inline __attribute__((always_inline)) void qpair_fused4(
const dpdf_qmatrix *q0,const dpdf_qmatrix *q1,const int8_t *activation,
Expand Down Expand Up @@ -289,7 +295,7 @@ static void qaffine_batch_tiled(const dpdf_qmatrix *q,const float *x,const float
#else
for (int r=0;r<m;++r) quantize(x+r*k,activation+r*k,k,scales+r,zp+r);
#endif
#ifdef DPDF_USE_QPAIR_FUSED64
#ifdef DPDF_USE_QBATCH_FUSED64
if (k==64) {
for (int r=0;r<m;r+=4) for (int c=0;c<n;c+=16)
qpair_fused4(q,q,activation+r*64,scales+r,zp+r,bias,bias,
Expand Down Expand Up @@ -433,7 +439,7 @@ void DPDF_QPAIR_IMPL(const dpdf_qmatrix *q0,const dpdf_qmatrix *q1,const float *
#else
for (int r=0;r<m;++r) quantize(x+r*k,activation+r*k,k,scales+r,zp+r);
#endif
#ifdef DPDF_QPAIR_FUSED64
#ifdef DPDF_USE_QPAIR_FUSED64
if (k==64) {
for (int r=0;r<m;r+=4) for (int c=0;c<n;c+=8)
qpair_fused4(q0,q1,activation+r*64,scales+r,zp+r,bias0,bias1,
Expand Down
6 changes: 3 additions & 3 deletions optimized_inference/tests/pair_fused_contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ int main(void) {
CHECK(fegetenv(&saved)==0);
unsigned original_mxcsr=_mm_getcsr();
int calls=0,outputs=0;
for (int rounding=0;rounding<4;++rounding) for (int denorm=0;denorm<2;++denorm) {
for (int rounding=0;rounding<4;++rounding) for (int denorm=0;denorm<4;++denorm) {
CHECK(fesetround(modes[rounding])==0);
_mm_setcsr((_mm_getcsr()&~0x8040u)|(denorm?0x8040u:0u));
_mm_setcsr((_mm_getcsr()&~0x8040u)|((denorm&1)?0x8000u:0u)|((denorm&2)?0x40u:0u));
unsigned controls=_mm_getcsr()&0xffc0u;
for (int stride_index=0;stride_index<3;++stride_index) {
int stride=strides[stride_index];
Expand Down Expand Up @@ -212,7 +212,7 @@ int main(void) {
}
CHECK(fesetenv(&saved)==0); _mm_setcsr(original_mxcsr);
printf("{\"passed\":true,\"k\":64,\"rows\":4,\"tiles\":2,\"calls_checked\":%d,\"float_outputs_checked\":%d,"
"\"rounding_modes\":4,\"ftz_daz_modes\":2,\"output_strides\":[8,16,192],"
"\"rounding_modes\":4,\"ftz_daz_modes\":4,\"output_strides\":[8,16,192],"
"\"independent_and_adjacent_outputs\":true,\"guarded_placements\":3,\"patterns\":32,"
"\"input_and_argument_pages_read_only\":true,\"padding_canaries\":true,"
"\"caller_controls_preserved\":true,\"separate_fp32_scale_product\":true}\n",calls,outputs);
Expand Down
Loading