Skip to content

Instantly share code, notes, and snippets.

@jmcook1186
Last active April 29, 2025 13:26
Show Gist options
  • Select an option

  • Save jmcook1186/12f7569576bf4b2a84bcc85d0c40b1e3 to your computer and use it in GitHub Desktop.

Select an option

Save jmcook1186/12f7569576bf4b2a84bcc85d0c40b1e3 to your computer and use it in GitHub Desktop.
Preprocessing of raw power data into IF inputs
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