Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
predtuner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
predtuner
Commits
617927d5
Commit
617927d5
authored
3 years ago
by
Yifan Zhao
Browse files
Options
Downloads
Patches
Plain Diff
PipedBin tuner handles device of knobs
parent
1af19c83
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
predtuner/pipedbin.py
+23
-17
23 additions, 17 deletions
predtuner/pipedbin.py
with
23 additions
and
17 deletions
predtuner/pipedbin.py
+
23
−
17
View file @
617927d5
...
...
@@ -37,19 +37,16 @@ class PipedBinaryApp(ModeledApp):
self
.
base_dir
=
(
self
.
binary_path
.
parent
if
base_dir
is
None
else
Path
(
base_dir
).
absolute
()
)
metadata_file
=
Path
(
metadata_path
)
self
.
qos_file
=
self
.
base_dir
/
qos_relpath
with
metadata_file
.
open
()
as
f
:
(
self
.
op_costs
,
op_knobs
,
self
.
knob_speedups
,
self
.
baseline_knob
,
self
.
tune_labels
,
self
.
conf_file
,
self
.
fifo_r_file
,
self
.
fifo_w_file
,
)
=
self
.
_parse_metadata
(
json
.
load
(
f
))
(
self
.
op_costs
,
op_knobs
,
self
.
knob_speedup
,
self
.
tune_labels
,
self
.
conf_file
,
self
.
fifo_r_file
,
self
.
fifo_w_file
,
)
=
self
.
_read_metadata
(
metadata_path
)
self
.
_op_order
=
{
v
:
i
for
i
,
v
in
enumerate
(
op_knobs
.
keys
())}
self
.
model_storage
=
(
Path
(
model_storage_folder
)
if
model_storage_folder
else
None
...
...
@@ -106,7 +103,7 @@ class PipedBinaryApp(ModeledApp):
p1_storage
=
self
.
model_storage
/
"
p1.pkl
"
if
self
.
model_storage
else
None
p2_storage
=
self
.
model_storage
/
"
p2.json
"
if
self
.
model_storage
else
None
return
[
LinearPerfModel
(
self
,
self
.
op_costs
,
self
.
knob_speedup
s
),
LinearPerfModel
(
self
,
self
.
op_costs
,
self
.
knob_speedup
),
QoSModelP1
(
self
,
lambda
conf
:
self
.
_run_on_knobs
(
conf
,
False
)[
0
],
...
...
@@ -162,15 +159,23 @@ class PipedBinaryApp(ModeledApp):
)
@staticmethod
def
_parse_metadata
(
metadata
:
dict
):
def
_read_metadata
(
metadata_path
:
PathLike
):
metadata_file
=
Path
(
metadata_path
)
with
metadata_file
.
open
()
as
f
:
metadata
=
json
.
load
(
f
)
op_costs
=
metadata
[
"
op_cost
"
]
op_knobs
=
metadata
[
"
op_knobs
"
]
knob_speedup
=
metadata
[
"
knob_speedup
"
]
knob_devices
=
metadata
[
"
knob_devices
"
]
baseline_knob
=
metadata
[
"
baseline_knob
"
]
# Check sanity
if
set
(
op_costs
.
keys
())
!=
set
(
op_knobs
.
keys
()):
raise
ValueError
(
"
Operators listed in layer_cost and knobs_of_layer don
'
t agree
"
"
Operators listed in layer_cost and knobs_of_layer mismatch
"
)
if
set
(
knob_speedup
.
keys
())
!=
set
(
knob_devices
.
keys
()):
raise
ValueError
(
"
Knobs listed in knob_speedup and knob_devices mismatch
"
)
knobs_used
=
set
().
union
(
*
[
set
(
knobs
)
for
knobs
in
op_knobs
.
values
()])
knobs_defined
=
set
(
knob_speedup
.
keys
())
...
...
@@ -183,7 +188,7 @@ class PipedBinaryApp(ModeledApp):
raise
ValueError
(
f
"
baseline_knob
{
baseline_knob
}
is undefined
"
)
# Create actual knob object from knob names
name2knob
=
{
s
:
ApproxKnob
(
s
,
baseline_priority
=
(
0
if
s
==
baseline_knob
else
None
))
s
:
ApproxKnob
(
s
,
knob_devices
[
s
],
(
0
if
s
==
baseline_knob
else
None
))
for
s
in
knobs_used
}
op_knobs
=
{
op
:
[
name2knob
[
k
]
for
k
in
knobs
]
for
op
,
knobs
in
op_knobs
.
items
()}
...
...
@@ -197,7 +202,6 @@ class PipedBinaryApp(ModeledApp):
op_costs
,
op_knobs
,
knob_speedup
,
baseline_knob
,
tune_labels
,
conf_file
,
fifo_r_file
,
...
...
@@ -268,6 +272,8 @@ class HPVMConfigBuilder:
knob_name_to_range
=
{
"
fp32
"
:
range
(
11
,
12
),
"
fp16
"
:
range
(
12
,
13
),
"
perf
"
:
range
(
121
,
158
+
1
),
"
samp
"
:
range
(
231
,
239
+
1
),
"
perf_fp16
"
:
range
(
151
,
168
+
1
),
"
samp_fp16
"
:
range
(
261
,
269
+
1
),
}
...
...
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