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
text-generation-inference
Commits
b5f1c9de
"docs/vscode:/vscode.git/clone" did not exist on "14dd917ec60fa69ce3f7c6e3f2eaf520e67928b5"
Unverified
Commit
b5f1c9de
authored
May 17, 2024
by
fxmarty
Committed by
GitHub
May 17, 2024
Browse files
Fix TunableOp bug (#1920)
cc @Narsil
parent
422bf1f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
1 deletion
+47
-1
docs/source/basic_tutorials/monitoring.md
docs/source/basic_tutorials/monitoring.md
+1
-1
server/text_generation_server/models/flash_mistral.py
server/text_generation_server/models/flash_mistral.py
+22
-0
server/text_generation_server/models/mamba.py
server/text_generation_server/models/mamba.py
+24
-0
No files found.
docs/source/basic_tutorials/monitoring.md
View file @
b5f1c9de
server/text_generation_server/models/flash_mistral.py
View file @
b5f1c9de
...
...
@@ -391,6 +391,28 @@ class BaseFlashMistral(FlashCausalLM):
def
batch_type
(
self
)
->
Type
[
FlashMistralBatch
]:
return
FlashMistralBatch
def
tunableop_warmup
(
self
,
seqlen
:
int
):
input_ids
=
torch
.
zeros
(
seqlen
,
dtype
=
torch
.
int64
,
device
=
self
.
device
)
position_ids
=
torch
.
zeros
(
seqlen
,
dtype
=
torch
.
int32
,
device
=
self
.
device
)
slots
=
torch
.
arange
(
seqlen
,
dtype
=
torch
.
int64
,
device
=
self
.
device
)
kv_cache
=
get_cache_manager
().
kv_cache
# We pass a `cu_seqlen_prefill` in order not to have to deal with paged attention cache allocation/deallocation.
self
.
model
.
forward
(
input_ids
=
input_ids
,
position_ids
=
position_ids
,
cu_seqlen_prefill
=
torch
.
tensor
(
[
0
,
seqlen
],
device
=
self
.
device
,
dtype
=
torch
.
int32
),
kv_cache
=
get_cache_manager
().
kv_cache
,
block_tables
=
None
,
input_lengths
=
None
,
slots
=
slots
,
max_s
=
seqlen
,
lm_head_indices
=
None
,
prefill_cache_indices
=
None
,
)
def
cuda_graph_warmup
(
self
,
bs
:
int
,
max_s
:
int
,
max_bt
:
int
):
input_ids
=
torch
.
zeros
(
bs
,
dtype
=
torch
.
int64
,
device
=
self
.
device
)
position_ids
=
torch
.
zeros
(
bs
,
dtype
=
torch
.
int32
,
device
=
self
.
device
)
...
...
server/text_generation_server/models/mamba.py
View file @
b5f1c9de
...
...
@@ -522,6 +522,30 @@ class Mamba(Model):
}
self
.
cuda_graphs
[
batch_size
]
=
graph_dict
def
tunableop_warmup
(
self
,
seqlen
:
int
):
input_ids
=
torch
.
zeros
((
batch_size
,
1
),
dtype
=
torch
.
int64
,
device
=
self
.
device
)
n_blocks
=
len
(
self
.
model
.
blocks
)
d_state
=
self
.
model
.
config
.
d_state
d_conv
=
self
.
model
.
config
.
d_conv
# Inner takes the expand multiplication
d_inner
=
self
.
model
.
config
.
d_inner
# Important seqlen_offset to go through the update mecanism with the state
seqlen_offset
=
1
inference_params
=
new_inference_params
(
n_blocks
=
n_blocks
,
batch_size
=
seqlen
,
d_state
=
d_state
,
d_conv
=
d_conv
,
d_inner
=
d_inner
,
seqlen_offset
=
seqlen_offset
,
device
=
self
.
device
,
dtype
=
self
.
dtype
,
)
self
.
model
.
forward
(
input_ids
=
input_ids
,
inference_params
=
inference_params
)
def
forward
(
self
,
input_ids
:
torch
.
Tensor
,
inference_params
:
Any
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
]:
...
...
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