ScQ-Cloud / pyquafu

PyQuafu is designed for users to construct, compile, and execute quantum circuits on quantum devices on Quafu using Python.
Apache License 2.0
63 stars 21 forks source link

BUG: In some virtual machines that do not support AVX, it can cause Illegal instruction (core dumped). #178

Open lucky9-cyou opened 1 week ago

lucky9-cyou commented 1 week ago
root@8bd8a1bafbf6:/quafu_runtime# python runtime-agent.py 
WARNING: Token 'CHANNEL' defined, but not used
WARNING: Token 'INCLUDE' defined, but not used
WARNING: Token 'NONE' defined, but not used
WARNING: Token 'OPAQUE' defined, but not used
WARNING: Token 'UNIT' defined, but not used
WARNING: /usr/local/lib/python3.10/site-packages/pyquafu-0.4.1-py3.10-linux-x86_64.egg/quafu/qfasm/qfasm_parser.py:1248: Rule 'ignore' defined, but not used
WARNING: /usr/local/lib/python3.10/site-packages/pyquafu-0.4.1-py3.10-linux-x86_64.egg/quafu/qfasm/qfasm_parser.py:1254: Rule 'empty' defined, but not used
WARNING: There are 5 unused tokens
WARNING: There are 2 unused rules
WARNING: Symbol 'ignore' is unreachable
WARNING: Symbol 'empty' is unreachable
Illegal instruction (core dumped)
root@8bd8a1bafbf6:/quafu_runtime# lscpu
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Byte Order:                           Little Endian
Address sizes:                        40 bits physical, 48 bits virtual
CPU(s):                               4
On-line CPU(s) list:                  0-3
Thread(s) per core:                   1
Core(s) per socket:                   4
Socket(s):                            1
NUMA node(s):                         1
Vendor ID:                            GenuineIntel
CPU family:                           15
Model:                                107
Model name:                           QEMU Virtual CPU version 2.5+
Stepping:                             1
CPU MHz:                              2194.842
BogoMIPS:                             4389.68
Hypervisor vendor:                    KVM
Virtualization type:                  full
L1d cache:                            128 KiB
L1i cache:                            128 KiB
L2 cache:                             16 MiB
L3 cache:                             16 MiB
NUMA node0 CPU(s):                    0-3
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          KVM: Mitigation: VMX unsupported
Vulnerability L1tf:                   Mitigation; PTE Inversion
Vulnerability Mds:                    Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Meltdown:               Mitigation; PTI
Vulnerability Mmio stale data:        Unknown: No mitigations
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Vulnerable
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Retpolines; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Retpoline
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Flags:                                fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht 
                                      syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni ssse3 cx16 sse4_1 sse4_2 x2api
                                      c popcnt aes hypervisor lahf_lm cpuid_fault pti

Some methods: Use library to detect the CPU features: https://github.com/nihui/ruapu

Related Code: https://github.com/ScQ-Cloud/pyquafu/blob/d603352190c466521e9f49760d4028a684883d50/CMakeLists.txt#L70C9-L73C5

Zhaoyilunnn commented 1 week ago

Thanks for opening this issue, I believe we need to resolve this issue. As some users may also have machine witout AVX: https://github.com/ScQ-Cloud/pyquafu/issues/130