Skip to content

Fix incorrect sorting of activation_files causing improper FFN offload #247

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

Open
3 tasks done
prisem123 opened this issue Mar 11, 2025 · 1 comment
Open
3 tasks done
Labels
bug-unconfirmed Unconfirmed bugs

Comments

@prisem123
Copy link

Prerequisites

Before submitting your issue, please ensure the following:

  • I am running the latest version of PowerInfer. Development is rapid, and as of now, there are no tagged versions.
  • I have carefully read and followed the instructions in the README.md.
  • I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).

Current Behavior

Hi! First of all, I want to thank you for your great work! I was reviewing some code and noticed an implementation that seems to behave differently from what was likely intended.

Specifically, in the powerinfer-py/powerinfer/export_split.py file, the load_activation_weights function appears to have an issue with sorting the activation_files array.

Image

When printing the activation_files array using ReluLLaMA-7B model, I observed the following output:
['activation_0.pt', 'activation_1.pt', 'activation_10.pt', 'activation_11.pt', 'activation_12.pt', 'activation_13.pt', 'activation_14.pt', 'activation_15.pt', 'activation_16.pt', 'activation_17.pt', 'activation_18.pt', 'activation_19.pt', 'activation_2.pt', 'activation_20.pt', 'activation_21.pt', 'activation_22.pt', 'activation_23.pt', 'activation_24.pt', 'activation_25.pt', 'activation_26.pt', 'activation_27.pt', 'activation_28.pt', 'activation_29.pt', 'activation_3.pt', 'activation_30.pt', 'activation_31.pt', 'activation_4.pt', 'activation_5.pt', 'activation_6.pt', 'activation_7.pt', 'activation_8.pt', 'activation_9.pt']
It looks like the files might not be sorted correctly, which could lead to improper FFN offloading.

Proposed Solution

I tried modifying the function as follows:

Image

With this change, the activation_files array is now printed as follows:

['activation_0.pt', 'activation_1.pt', 'activation_2.pt', 'activation_3.pt', 'activation_4.pt', 'activation_5.pt', 'activation_6.pt', 'activation_7.pt', 'activation_8.pt', 'activation_9.pt', 'activation_10.pt', 'activation_11.pt', 'activation_12.pt', 'activation_13.pt', 'activation_14.pt', 'activation_15.pt', 'activation_16.pt', 'activation_17.pt', 'activation_18.pt', 'activation_19.pt', 'activation_20.pt', 'activation_21.pt', 'activation_22.pt', 'activation_23.pt', 'activation_24.pt', 'activation_25.pt', 'activation_26.pt', 'activation_27.pt', 'activation_28.pt', 'activation_29.pt', 'activation_30.pt', 'activation_31.pt']

After this adjustment, I noticed a decrease in eval time.

If I've made any mistakes in my observations, I'd appreciate any corrections!
I've submitted a pull request with this change--please take a look when you have time :)
link to pull request

Environment and Context

Please provide detailed information about your computer setup. This is important in case the issue is not reproducible except for under certain specific conditions.

  • Physical (or virtual) hardware you are using, e.g. for Linux:
$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Address sizes:       46 bits physical, 48 bits virtual
Byte Order:          Little Endian
CPU(s):              16
On-line CPU(s) list: 0-15
Vendor ID:           GenuineIntel
Model name:          12th Gen Intel(R) Core(TM) i7-12700K
CPU family:          6
Model:               151
Thread(s) per core:  2
Core(s) per socket:  8
Socket(s):           1
Stepping:            2
CPU max MHz:         5000.0000
CPU min MHz:         800.0000
BogoMIPS:            7219.20
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaves xgetbv1 xsavec xsaveopt xsaves split_lock_detect user_shstk avx_vnni dth erm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities

  • Operating System, e.g. for Linux:
$ uname -a
Linux (my server) 6.8.0-52-generic #53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 19:18:46 UTC 2 x86_64 x86_64 GNU/Linux
  • SDK version, e.g. for Linux:
$ python3 --veresion
Python 3.9.21

$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@prisem123 prisem123 added the bug-unconfirmed Unconfirmed bugs label Mar 11, 2025
@Yuan-Allen
Copy link

I agree with you. That might be a critical mistake that can cause improper offloading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed Unconfirmed bugs
Projects
None yet
Development

No branches or pull requests

2 participants