Repository navigation
Optimize AVX2/VNNI inference with channel-major projections and gated quantize4 - #23
Open
varyagnord wants to merge 7 commits into
Open
varyagnord wants to merge 7 commits into
varyagnord wants to merge 7 commits into
Conversation
Quantize eight frequency positions directly and transpose outputs in registers, avoiding sixteen full float transposes per graph. Preserve exact arithmetic, AVX2/FMA requirements, original fallback paths, weights and state ABI. Add guarded FP-mode and all-mask regression coverage, and preserve the paired measurement records for the precision repeats and rejected optimization trials.
Compare the pre-i7 baseline with the final runtime in 288 paired blocks per model and power condition. Preserve SD, SE, adjusted intervals, A/A discrepancies, raw block observations and isolation verification.
- Share exact channel-major quantization and output stores across AVX2/VNNI for both models. - Reuse matrix ISA selection and retain bounded-shape/overlap fallback guards without extra context state. - Add guarded VNNI CM oracles and an object-code contract rejecting accidental EVEX requirements. Checks: Release/PGO/ASan/static/AVX2 contracts; 130 bitwise model-stream comparisons; CPU-mask and VEX/negative-EVEX checks; unchanged weights/public ABI. All temporary CPU/IRQ settings restored. Measured on one Ryzen HX 470 high-frequency core: continuous-call reductions 2.765%/1.545%; paced 10-ms gains were not confirmed. No general-platform or cumulative VNNI claim.
- Retain channel-major projections for both models and legacy AVX2 batching. - Keep exact range-reuse and VNNI four-row experiments disabled by default. - Reuse ranges, bypass all-empty divisions and safely neutralize mixed lanes. - Preserve an independent oracle across masks, rounding, FTZ/DAZ and guards. - Add reversible L3/SMT isolation, hardware frequency checks and paired studies. - Record conditional gains without promoting noisy or unqualified outcomes. Checks: - Fresh default PGO: 43 contracts pass; library byte-identical to measured CM. - Ready refined candidates: 42 native and 32 AVX2 contracts pass. - All 17 unprivileged laboratory behavioral tests pass. - Full regenerated streams/PCM and red AVX2 portability pass for both models. - 811008 unprofiled calls, 288 separate PMU jobs; restoration verified.
- Publish all 1728 primary A/A and A/B process pairs with input/order and SD. - Independently reproduce all 144 adjusted intervals from portable evidence. - Distinguish legacy AVX2 batching from disabled quantize4 refinements. - Describe qualified CM/model8 gains and retain noisy Boost outcomes honestly. - Record fresh default PGO identity, 43 passing contracts and restored settings. Checks: - Portable paired intervals match published summaries within 1e-10. - Fresh selected PGO SO matches the measured SHA-256 byte for byte. - git diff --cached --check.
Keep the validation summary and link to the preserved reports at the original branch revision. Runtime and test sources are unchanged. Verified with a Release build and CTest.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eligible INT8 K64N64 pointwise projections now execute directly in channel-major layout on AVX2 and optional VEX-encoded AVX-VNNI. Retain the accepted exact AVX2 four-row quantizer, and make the new range-reuse/empty-row refinement an explicitly opt-in experiment. This PR targets
ceva-ip/DPDFNet:optimized-inference, refreshed against98df765; it includes the previously unpublished AVX2 batching/CM commits and their direct cumulative evidence.Relationship to earlier pull requests
#20 (automatic VNNI dispatch) and #21 (per-model runtime optimizations) are already merged into the target branch. #22 (AVX2 four-row quantization and channel-major kernels) is still open. This branch contains every commit from #22, then adds VNNI CM, the gated refinement, reusable laboratory tooling and the latest qualification evidence. Thus #23 is a cumulative superset of #22, not a competing implementation. No earlier PR is closed or merged by this publication.
Runtime behavior and defaults
DPDF_ENABLE_AVX_VNNI=ONbuilds hardware-dispatched VNNI when supported by the compiler. AVX2/FMA remains the fallback; no AVX-512 requirement is introduced.DPDF_ENABLE_QUANTIZE4_REFINEMENT=OFFandDPDF_ENABLE_VNNI_QUANTIZE4=OFFare the selected defaults for both models. The VNNI experiment requires the refinement option. Disabling four-row VNNI quantization does not disable ordinary model quantization.Why quantize4 remains experimental
The new native model-8 implementation has a confirmed incremental benefit in specific workloads. That does not establish a universal benefit for model 2, AVX2, complete audio callbacks, or dynamic Boost operation. Preserve positive and negative observations and failed A/A precision gates rather than promote a global switch from selected favorable conditions.
The following six conditions pass every preregistered precision, useful-effect and operational gate in the final study. All are on the fast Ryzen core at a verified steady nominal 2 GHz. These isolate the VNNI CM increment and the further quantize4 increment; they are not cumulative speedups against this PR's upstream base, and their percentages must not be added.
Only 10/72 A/A conditions meet the predefined 0.5% precision limit. No quantize4 model-2, AVX2 or complete-audio condition passes every superiority gate. Compact-core/Boost native model-8 continuous passes the separate 0.5% practical noninferiority margin, not useful superiority. An unqualified condition is inconclusive; neither absence of benefit nor absence of harm is asserted. Earlier power/layout cohorts are retained separately without pooling. Secondary direct cumulative comparisons are explicitly exploratory reconstructions of existing nonadjacent block observations, not additional primary acceptance tests.
Reproducible measurement tools
Add repository-root
justrecipes and a laboratory controller/worker/study split. Discover and reserve the complete L3 domain, put ordinary work on a separate domain, park the worker's SMT sibling, steer movable IRQ/workqueues, and verify actual CPPC frequency under load. Save settings before mutation, arm an independent restoration timer, run workers unprivileged with zero capabilities/no-new-privileges, and verify rollback even on failure. Unsupported isolation/frequency backends fail explicitly. Residual kernel/package interference is recorded, not claimed eliminated.The final fixed plan spans 72 contrasts: both models, three code contrasts, fast/compact Ryzen cores, steady/Boost profiles, and continuous spectral/paced spectral/full FFT-inference-IFFT callbacks. Each condition has eight identical-binary A/A pairs and sixteen A/B pairs with balanced input/order and fresh processes. Inference uses paired process log ratios and family-72 adjusted Student intervals; serial calls are not independent replicates. Fixed process layout is checked without changing global ASLR. Retain call/process sample SD, tails, frequency, faults, switches, every slow call and input/order diagnostics.
Total: 3,456 unprofiled processes / 811,008 calls, plus 288 separate warmed PMU jobs with fully scheduled user-event groups and counter mean/SD normalized per call. Profiled durations never enter speed estimates. Observed maximum was 2.787454 ms, with no 10 ms deadline misses, late completions or major faults. All four sessions and independent final readback verify restored CPU/power/idle/IRQ/workqueue/watchdog settings, active irqbalance, no temporary cgroup/workers, inactive restoration timer and unchanged global ASLR. Preparation-only failures and recovery are retained; no measured samples were recollected or extended. A separately tested post-study error-path fix preserves controller failure/rollback JSON in future logs.
Correctness and publication verification
26efac06d424e8907a680cbda0ce61ac30a18a557b11cdb3f27f29466288c7ae.The original historical reference corpus was unavailable; these checks certify the regenerated public/stress corpus. No new perceptual scores, WCET bound, arbitrary-CPU speedup or production device/audio-server/service-concurrency result is claimed. Per-call arrays and complete infrastructure journals remain in the local archive rather than being bundled. No private backlog, weight changes, service deployment or GitHub Release is included.
Review references
Most diff volume is machine-readable validation evidence; the runtime selection remains deliberately conservative.
Verified CI for published head
Both the fork push workflow and the upstream PR workflow completed successfully for head
6a078955909c29d857d8ad2bf02bdc01c9aa0a57. Every job log was inspected. Counts below distinguish passed contracts from explicit CPU-feature skips; skipped VNNI tests are not presented as execution coverage.The nine explicit skips are VNNI-specific contracts on hosts without the required instruction. All VNNI contracts execute successfully in the fork plain-static job and the upstream sanitizer job, as well as in the local fresh default build. Both PGO generation/use phases pass, shared/static consumers link correctly, and each workflow retains configuration/CTest logs as artifacts. CI verifies compatibility/correctness, not the reported Ryzen speedups.