Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Recipes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
meta-llama
Llama Recipes
Commits
564ef2f6
Commit
564ef2f6
authored
1 year ago
by
Hamid Shojanazeri
Browse files
Options
Downloads
Patches
Plain Diff
remove padding logic
parent
277a292f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inference/code-llama/code_completion_example.py
+1
-10
1 addition, 10 deletions
inference/code-llama/code_completion_example.py
inference/code-llama/code_infilling_example.py
+1
-9
1 addition, 9 deletions
inference/code-llama/code_infilling_example.py
with
2 additions
and
19 deletions
inference/code-llama/code_completion_example.py
+
1
−
10
View file @
564ef2f6
...
@@ -33,7 +33,6 @@ def main(
...
@@ -33,7 +33,6 @@ def main(
enable_azure_content_safety
:
bool
=
False
,
# Enable safety check with Azure content safety api
enable_azure_content_safety
:
bool
=
False
,
# Enable safety check with Azure content safety api
enable_sensitive_topics
:
bool
=
False
,
# Enable check for sensitive topics using AuditNLG APIs
enable_sensitive_topics
:
bool
=
False
,
# Enable check for sensitive topics using AuditNLG APIs
enable_salesforce_content_safety
:
bool
=
True
,
# Enable safety check with Salesforce safety flan t5
enable_salesforce_content_safety
:
bool
=
True
,
# Enable safety check with Salesforce safety flan t5
max_padding_length
:
int
=
None
,
# the max padding length to be used with tokenizer padding the prompts.
use_fast_kernels
:
bool
=
True
,
# Enable using SDPA from PyTroch Accelerated Transformers, make use Flash Attention and Xformer memory-efficient kernels
use_fast_kernels
:
bool
=
True
,
# Enable using SDPA from PyTroch Accelerated Transformers, make use Flash Attention and Xformer memory-efficient kernels
**
kwargs
**
kwargs
):
):
...
@@ -70,14 +69,6 @@ def main(
...
@@ -70,14 +69,6 @@ def main(
print
(
"
Module
'
optimum
'
not found. Please install
'
optimum
'
it before proceeding.
"
)
print
(
"
Module
'
optimum
'
not found. Please install
'
optimum
'
it before proceeding.
"
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
)
tokenizer
.
add_special_tokens
(
{
"
pad_token
"
:
"
<PAD>
"
,
}
)
model
.
resize_token_embeddings
(
model
.
config
.
vocab_size
+
1
)
safety_checker
=
get_safety_checker
(
enable_azure_content_safety
,
safety_checker
=
get_safety_checker
(
enable_azure_content_safety
,
enable_sensitive_topics
,
enable_sensitive_topics
,
enable_salesforce_content_safety
,
enable_salesforce_content_safety
,
...
@@ -98,7 +89,7 @@ def main(
...
@@ -98,7 +89,7 @@ def main(
print
(
"
Skipping the inference as the prompt is not safe.
"
)
print
(
"
Skipping the inference as the prompt is not safe.
"
)
sys
.
exit
(
1
)
# Exit the program with an error status
sys
.
exit
(
1
)
# Exit the program with an error status
batch
=
tokenizer
(
user_prompt
,
padding
=
'
max_length
'
,
truncation
=
True
,
max_length
=
max_padding_length
,
return_tensors
=
"
pt
"
)
batch
=
tokenizer
(
user_prompt
,
return_tensors
=
"
pt
"
)
batch
=
{
k
:
v
.
to
(
"
cuda
"
)
for
k
,
v
in
batch
.
items
()}
batch
=
{
k
:
v
.
to
(
"
cuda
"
)
for
k
,
v
in
batch
.
items
()}
start
=
time
.
perf_counter
()
start
=
time
.
perf_counter
()
...
...
This diff is collapsed.
Click to expand it.
inference/code-llama/code_infilling_example.py
+
1
−
9
View file @
564ef2f6
...
@@ -33,7 +33,6 @@ def main(
...
@@ -33,7 +33,6 @@ def main(
enable_azure_content_safety
:
bool
=
False
,
# Enable safety check with Azure content safety api
enable_azure_content_safety
:
bool
=
False
,
# Enable safety check with Azure content safety api
enable_sensitive_topics
:
bool
=
False
,
# Enable check for sensitive topics using AuditNLG APIs
enable_sensitive_topics
:
bool
=
False
,
# Enable check for sensitive topics using AuditNLG APIs
enable_salesforce_content_safety
:
bool
=
True
,
# Enable safety check with Salesforce safety flan t5
enable_salesforce_content_safety
:
bool
=
True
,
# Enable safety check with Salesforce safety flan t5
max_padding_length
:
int
=
None
,
# the max padding length to be used with tokenizer padding the prompts.
use_fast_kernels
:
bool
=
True
,
# Enable using SDPA from PyTroch Accelerated Transformers, make use Flash Attention and Xformer memory-efficient kernels
use_fast_kernels
:
bool
=
True
,
# Enable using SDPA from PyTroch Accelerated Transformers, make use Flash Attention and Xformer memory-efficient kernels
**
kwargs
**
kwargs
):
):
...
@@ -70,13 +69,6 @@ def main(
...
@@ -70,13 +69,6 @@ def main(
print
(
"
Module
'
optimum
'
not found. Please install
'
optimum
'
it before proceeding.
"
)
print
(
"
Module
'
optimum
'
not found. Please install
'
optimum
'
it before proceeding.
"
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
)
tokenizer
.
add_special_tokens
(
{
"
pad_token
"
:
"
<PAD>
"
,
}
)
model
.
resize_token_embeddings
(
model
.
config
.
vocab_size
+
1
)
safety_checker
=
get_safety_checker
(
enable_azure_content_safety
,
safety_checker
=
get_safety_checker
(
enable_azure_content_safety
,
enable_sensitive_topics
,
enable_sensitive_topics
,
...
@@ -98,7 +90,7 @@ def main(
...
@@ -98,7 +90,7 @@ def main(
print
(
"
Skipping the inference as the prompt is not safe.
"
)
print
(
"
Skipping the inference as the prompt is not safe.
"
)
sys
.
exit
(
1
)
# Exit the program with an error status
sys
.
exit
(
1
)
# Exit the program with an error status
batch
=
tokenizer
(
user_prompt
,
padding
=
'
max_length
'
,
truncation
=
True
,
max_length
=
max_padding_length
,
return_tensors
=
"
pt
"
)
batch
=
tokenizer
(
user_prompt
,
return_tensors
=
"
pt
"
)
batch
=
{
k
:
v
.
to
(
"
cuda
"
)
for
k
,
v
in
batch
.
items
()}
batch
=
{
k
:
v
.
to
(
"
cuda
"
)
for
k
,
v
in
batch
.
items
()}
start
=
time
.
perf_counter
()
start
=
time
.
perf_counter
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment