Skip to content

Commit

Permalink
Sync Mlperf inference (#627)
Browse files Browse the repository at this point in the history
* Support input conf_file for mlperf-power-server

* Support num_analyzers input

* Don't save console log for mlperf power, revisit later

* Update format.yml

* [Automated Commit] Format Codebase

---------
  • Loading branch information
arjunsuresh authored Nov 29, 2024
1 parent 5f206aa commit 5bb0c7e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: "Code formatting"
on:
push:
branches: [ "main", "mlperf-inference" ]
branches:
- "**"

env:
python_version: "3.9"

jobs:
format-code:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'mlcommons' }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 1 addition & 0 deletions script/benchmark-program-mlperf/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ variations:
power:
env:
CM_MLPERF_POWER: 'yes'
CM_SAVE_CONSOLE_LOG: 'no'
group: power-mode
new_env_keys:
- CM_MLPERF_*
Expand Down
7 changes: 5 additions & 2 deletions script/benchmark-program-mlperf/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ def postprocess(i):
CM_MLPERF_RUN_COUNT=\$(cat \${CM_RUN_DIR}/count.txt);
echo \${CM_MLPERF_RUN_COUNT};
CM_MLPERF_RUN_COUNT=\$((CM_MLPERF_RUN_COUNT+1));
echo \${CM_MLPERF_RUN_COUNT} > \${CM_RUN_DIR}/count.txt &&
echo \${CM_MLPERF_RUN_COUNT} > \${CM_RUN_DIR}/count.txt;
if [ \${CM_MLPERF_RUN_COUNT} -eq 1 ]; then
export CM_MLPERF_USER_CONF="${CM_MLPERF_RANGING_USER_CONF}";
else
export CM_MLPERF_USER_CONF="${CM_MLPERF_TESTING_USER_CONF}";
fi &&
fi
;
""" + env.get('CM_RUN_CMD', '').strip()
else:
env['CM_MLPERF_RUN_CMD'] = r"""
Expand Down
2 changes: 2 additions & 0 deletions script/run-mlperf-power-server/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ input_mapping:
device_type: CM_MLPERF_POWER_DEVICE_TYPE
interface_flag: CM_MLPERF_POWER_INTERFACE_FLAG
ntp_server: CM_MLPERF_POWER_NTP_SERVER
conf_file: CM_MLPERF_POWER_SERVER_CONF_FILE
screen: CM_MLPERF_POWER_SERVER_USE_SCREEN
num_analyzers: CM_MLPERF_POWER_NUM_ANALYZERS
tags:
- run
- mlc
Expand Down
44 changes: 23 additions & 21 deletions script/run-mlperf-power-server/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ def preprocess(i):
# Initialize ConfigParser
config = configparser.ConfigParser()

# Define the server config file path
server_config_file = os.path.join(
env.get('CM_MLPERF_POWER_SOURCE', ''),
'ptd_client_server',
'server.template.conf'
)
if env.get('CM_MLPERF_POWER_SERVER_CONF_FILE', '') != '':
server_config_file = env['CM_MLPERF_POWER_SERVER_CONF_FILE']
else:
server_config_file = os.path.join(
env.get('CM_MLPERF_POWER_SOURCE', ''),
'ptd_client_server',
'server.template.conf'
)

# Read the configuration file with error handling
if not os.path.exists(server_config_file):
Expand All @@ -40,29 +42,29 @@ def preprocess(i):
8888))

# Ensure 'ptd' section exists
if 'ptd' in config:
config.remove_section('ptd')
if 'ptd' not in config:
config.add_section('ptd')

config.add_section('ptd')
config['ptd']['ptd'] = str(env.get('CM_MLPERF_PTD_PATH', ''))
config['ptd']['analyzercount'] = str(num_analyzers)

# Add analyzers to the configuration
for aid in range(1, num_analyzers + 1):
analyzer_section = f'analyzer{aid}'
if analyzer_section not in config:
config.add_section(analyzer_section)

# Add the analyzer subsection as keys under the 'ptd' section
config[f'{analyzer_section}']['interfaceFlag'] = str(
env.get('CM_MLPERF_POWER_INTERFACE_FLAG', ''))
config[f'{analyzer_section}']['deviceType'] = str(
env.get('CM_MLPERF_POWER_DEVICE_TYPE', ''))
config[f'{analyzer_section}']['devicePort'] = str(
env.get('CM_MLPERF_POWER_DEVICE_PORT', ''))
config[f'{analyzer_section}']['networkPort'] = str(
network_port_start + aid - 1)

with open('power-server.conf', 'w') as configfile:
# Add the analyzer subsection as keys under the 'ptd' section
config[f'{analyzer_section}']['interfaceFlag'] = str(
env.get('CM_MLPERF_POWER_INTERFACE_FLAG', ''))
config[f'{analyzer_section}']['deviceType'] = str(
env.get('CM_MLPERF_POWER_DEVICE_TYPE', ''))
config[f'{analyzer_section}']['devicePort'] = str(
env.get('CM_MLPERF_POWER_DEVICE_PORT', ''))
config[f'{analyzer_section}']['networkPort'] = str(
network_port_start + aid - 1)

with open('tmp-power-server.conf', 'w') as configfile:
config.write(configfile)

print({section: dict(config[section]) for section in config.sections()})
Expand All @@ -75,7 +77,7 @@ def preprocess(i):
cmd = env['CM_PYTHON_BIN_WITH_PATH'] + ' ' + os.path.join(
env['CM_MLPERF_POWER_SOURCE'],
'ptd_client_server',
'server.py') + ' -c power-server.conf'
'server.py') + ' -c tmp-power-server.conf'
if env.get('CM_MLPERF_POWER_SERVER_USE_SCREEN', 'no') == 'yes':
cmd = cmd_prefix + ' screen -d -m ' + cmd + ' '
else:
Expand Down

0 comments on commit 5bb0c7e

Please sign in to comment.