Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
622e6106
Unverified
Commit
622e6106
authored
Nov 13, 2025
by
Michael Goin
Committed by
GitHub
Nov 14, 2025
Browse files
[CPU][Bugfix] Fix Apple Silicon M1 compilation failure (#28681)
Signed-off-by:
mgoin
<
mgoin64@gmail.com
>
parent
2aa75c75
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
csrc/cpu/cpu_attn_impl.hpp
csrc/cpu/cpu_attn_impl.hpp
+28
-0
No files found.
csrc/cpu/cpu_attn_impl.hpp
View file @
622e6106
...
...
@@ -5,6 +5,10 @@
#include <type_traits>
#include <cstddef>
#if defined(__APPLE__)
#include <sys/sysctl.h>
#endif
#include "cpu_types.hpp"
#include "scratchpad_manager.h"
#include "cpu_attn_macros.h"
...
...
@@ -741,9 +745,21 @@ class AttentionScheduler {
static
int64_t
get_available_l2_size
()
{
static
int64_t
size
=
[]()
{
#if defined(__APPLE__)
// macOS doesn't have _SC_LEVEL2_CACHE_SIZE. Use sysctlbyname.
int64_t
l2_cache_size
=
0
;
size_t
len
=
sizeof
(
l2_cache_size
);
if
(
sysctlbyname
(
"hw.l2cachesize"
,
&
l2_cache_size
,
&
len
,
NULL
,
0
)
==
0
&&
l2_cache_size
>
0
)
{
return
l2_cache_size
>>
1
;
// use 50% of L2 cache
}
// Fallback if sysctlbyname fails
return
128
*
1024
>>
1
;
// use 50% of 128KB
#else
long
l2_cache_size
=
sysconf
(
_SC_LEVEL2_CACHE_SIZE
);
TORCH_CHECK_NE
(
l2_cache_size
,
-
1
);
return
l2_cache_size
>>
1
;
// use 50% of L2 cache
#endif
}();
return
size
;
}
...
...
@@ -816,10 +832,14 @@ struct VecTypeTrait<float> {
using
vec_t
=
vec_op
::
FP32Vec16
;
};
// ARM only supports BF16 with ARMv8.6-A extension
#if (defined(__aarch64__) && !defined(ARM_BF16_SUPPORT))
#else
template
<
>
struct
VecTypeTrait
<
c10
::
BFloat16
>
{
using
vec_t
=
vec_op
::
BF16Vec16
;
};
#endif
#if !defined(__powerpc__)
template
<
>
...
...
@@ -1588,9 +1608,17 @@ class AttentionMainLoop {
if
(
use_sink
)
{
alignas
(
64
)
float
s_aux_fp32
[
16
];
#if defined(__aarch64__) && !defined(ARM_BF16_SUPPORT)
// ARM without native BF16 support: manual conversion
for
(
int
i
=
0
;
i
<
16
;
++
i
)
{
s_aux_fp32
[
i
]
=
static_cast
<
float
>
(
curr_s_aux
[
i
]);
}
#else
// All other platforms have BF16Vec16 available
vec_op
::
BF16Vec16
vec_bf16
(
curr_s_aux
);
vec_op
::
FP32Vec16
vec_fp32
(
vec_bf16
);
vec_fp32
.
save
(
s_aux_fp32
);
#endif
float
*
__restrict__
curr_sum_buffer
=
sum_buffer
;
float
*
__restrict__
curr_max_buffer
=
max_buffer
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment