Last active
April 29, 2025 13:26
-
-
Save jmcook1186/12f7569576bf4b2a84bcc85d0c40b1e3 to your computer and use it in GitHub Desktop.
Preprocessing of raw power data into IF inputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| root = './neuralwatt/' | |
| in_data = 'inference.nvidia_smi_log.none_h100_llama3.3_20250316_230401.csv' | |
| # clean and prep data | |
| data = pd.read_csv(root+in_data) | |
| data = data[['timestamp', 'power.draw(W)']] # extract relevant features | |
| data.replace(' ', 'T', regex=True, inplace=True) # format timestamp | |
| data.replace('/', '-', regex=True, inplace=True) # format timestamp | |
| # timestamp strings to Pandas TimeStamp objects | |
| timestamps= [] | |
| for timestamp in data['timestamp']: | |
| timestamps.append(pd.Timestamp(timestamp)) | |
| data['timestamp']= timestamps | |
| # make timestamp the df index | |
| data.set_index(['timestamp'], inplace=True) | |
| # resample to 1 second intervals | |
| resampled = data[['power.draw(W)']].resample('s').sum() | |
| # create IF formatted input data from resampled dataframe | |
| inputs = [] | |
| for idx in range(0, len(resampled), 1): | |
| inputs.append(f"- timestamp: {resampled.index[idx]}") | |
| inputs.append(" duration: 1") | |
| inputs.append(f" cpu-power: {resampled['power.draw(W)'][idx]}") | |
| # write inputs to text file | |
| with open(root+"if-inputs.txt", "w") as txt_file: | |
| for line in inputs: | |
| txt_file.write(line + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment