Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
bbbcac26
"git@developer.sourcefind.cn:OpenDAS/colossalai.git" did not exist on "19d153057efebf65259fdc21f582ff2e55dbe2ec"
Unverified
Commit
bbbcac26
authored
Sep 27, 2023
by
Tong Li
Committed by
GitHub
Sep 27, 2023
Browse files
fix format (#4815)
parent
fb46d05c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
22 deletions
+26
-22
op_builder/gptq.py
op_builder/gptq.py
+26
-22
No files found.
op_builder/gptq.py
View file @
bbbcac26
import
os
import
torch
import
re
import
re
import
torch
from
.builder
import
Builder
from
.builder
import
Builder
from
.utils
import
append_nvcc_threads
,
get_cuda_cc_flag
from
.utils
import
append_nvcc_threads
class
GPTQBuilder
(
Builder
):
class
GPTQBuilder
(
Builder
):
NAME
=
"cu_gptq"
NAME
=
"cu_gptq"
PREBUILT_IMPORT_PATH
=
"colossalai._C.cu_gptq"
PREBUILT_IMPORT_PATH
=
"colossalai._C.cu_gptq"
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
(
name
=
GPTQBuilder
.
NAME
,
super
().
__init__
(
name
=
GPTQBuilder
.
NAME
,
prebuilt_import_path
=
GPTQBuilder
.
PREBUILT_IMPORT_PATH
)
prebuilt_import_path
=
GPTQBuilder
.
PREBUILT_IMPORT_PATH
)
def
include_dirs
(
self
):
def
include_dirs
(
self
):
ret
=
[
self
.
csrc_abs_path
(
"gptq"
),
self
.
get_cuda_home_include
()]
ret
=
[
self
.
csrc_abs_path
(
"gptq"
),
self
.
get_cuda_home_include
()]
...
@@ -21,32 +19,38 @@ class GPTQBuilder(Builder):
...
@@ -21,32 +19,38 @@ class GPTQBuilder(Builder):
def
sources_files
(
self
):
def
sources_files
(
self
):
ret
=
[
ret
=
[
self
.
csrc_abs_path
(
fname
)
for
fname
in
[
self
.
csrc_abs_path
(
fname
)
'gptq/linear_gptq.cpp'
,
for
fname
in
[
'gptq/column_remap.cu'
,
"gptq/linear_gptq.cpp"
,
'gptq/cuda_buffers.cu'
,
"gptq/column_remap.cu"
,
'gptq/q4_matmul.cu'
,
"gptq/cuda_buffers.cu"
,
'gptq/q4_matrix.cu'
"gptq/q4_matmul.cu"
,
"gptq/q4_matrix.cu"
,
]
]
]
]
return
ret
return
ret
def
cxx_flags
(
self
):
def
cxx_flags
(
self
):
return
[
'
-O3
'
]
+
self
.
version_dependent_macros
return
[
"
-O3
"
]
+
self
.
version_dependent_macros
def
nvcc_flags
(
self
):
def
nvcc_flags
(
self
):
extra_cuda_flags
=
[
'-v'
,
extra_cuda_flags
=
[
'-std=c++14'
,
'-U__CUDA_NO_HALF_OPERATORS__'
,
'-U__CUDA_NO_HALF_CONVERSIONS__'
,
"-v"
,
'-U__CUDA_NO_HALF2_OPERATORS__'
,
'-DTHRUST_IGNORE_CUB_VERSION_CHECK'
,
"-lcublas"
,
"-std=c++17"
"-std=c++14"
,
"-U__CUDA_NO_HALF_OPERATORS__"
,
"-U__CUDA_NO_HALF_CONVERSIONS__"
,
"-U__CUDA_NO_HALF2_OPERATORS__"
,
"-DTHRUST_IGNORE_CUB_VERSION_CHECK"
,
"-lcublas"
,
"-std=c++17"
,
]
]
for
arch
in
torch
.
cuda
.
get_arch_list
():
for
arch
in
torch
.
cuda
.
get_arch_list
():
res
=
re
.
search
(
r
'
sm_(\d+)
'
,
arch
)
res
=
re
.
search
(
r
"
sm_(\d+)
"
,
arch
)
if
res
:
if
res
:
arch_cap
=
res
[
1
]
arch_cap
=
res
[
1
]
if
int
(
arch_cap
)
>=
80
:
if
int
(
arch_cap
)
>=
80
:
extra_cuda_flags
.
extend
([
'
-gencode
'
,
f
'
arch=compute_
{
arch_cap
}
,code=
{
arch
}
'
])
extra_cuda_flags
.
extend
([
"
-gencode
"
,
f
"
arch=compute_
{
arch_cap
}
,code=
{
arch
}
"
])
ret
=
[
'-O3'
,
'--use_fast_math'
]
+
self
.
version_dependent_macros
+
extra_cuda_flags
ret
=
[
"-O3"
,
"--use_fast_math"
]
+
self
.
version_dependent_macros
+
extra_cuda_flags
return
append_nvcc_threads
(
ret
)
return
append_nvcc_threads
(
ret
)
\ No newline at end of file
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