diff --git a/pkg/bpf/kepler_bpfeb.o b/pkg/bpf/kepler_bpfeb.o index be2eedd1df..0482fe5156 100644 Binary files a/pkg/bpf/kepler_bpfeb.o and b/pkg/bpf/kepler_bpfeb.o differ diff --git a/pkg/bpf/kepler_bpfel.o b/pkg/bpf/kepler_bpfel.o index 7f61cec6f9..742b1af3b4 100644 Binary files a/pkg/bpf/kepler_bpfel.o and b/pkg/bpf/kepler_bpfel.o differ diff --git a/pkg/bpftest/test_bpfeb.o b/pkg/bpftest/test_bpfeb.o index f190a3ab7b..4d3fc92995 100644 Binary files a/pkg/bpftest/test_bpfeb.o and b/pkg/bpftest/test_bpfeb.o differ diff --git a/pkg/bpftest/test_bpfel.o b/pkg/bpftest/test_bpfel.o index 5c8972722c..8a869941eb 100644 Binary files a/pkg/bpftest/test_bpfel.o and b/pkg/bpftest/test_bpfel.o differ diff --git a/pkg/config/config.go b/pkg/config/config.go index 6e0cf39f27..f8d95bd4ba 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -247,8 +247,18 @@ func setModelServerReqEndpoint() string { // return local path to power model weight // e.g., /var/lib/kepler/data/model_weight/acpi_AbsPowerModel.json -func GetDefaultPowerModelURL(modelOutputType, energySource string) string { - return fmt.Sprintf(`/var/lib/kepler/data/model_weight/%s_%sModel.json`, energySource, modelOutputType) +func GetDefaultPowerModelURL(modelOutputType, energySource, cpuArch string) string { + // strip white space or new line from cpuArch + cpuArch = strings.TrimSuffix(cpuArch, "\n") + cpuArch = strings.TrimSpace(cpuArch) + fullPath := fmt.Sprintf(`/var/lib/kepler/data/%s/model_weight/%s_%sModel.json`, cpuArch, energySource, modelOutputType) + // if the model does not exist, return the default model + if _, err := os.Stat(fullPath); os.IsNotExist(err) { + klog.Warningf("model %s does not exist, using default model", fullPath) + return fmt.Sprintf(`/var/lib/kepler/data/model_weight/%s_%sModel.json`, energySource, modelOutputType) + } + // otherwise, return the full path + return fullPath } func logBoolConfigs() { diff --git a/pkg/model/estimator/local/regressor/regressor_test.go b/pkg/model/estimator/local/regressor/regressor_test.go index 8f2d24eb77..1b7facfc37 100644 --- a/pkg/model/estimator/local/regressor/regressor_test.go +++ b/pkg/model/estimator/local/regressor/regressor_test.go @@ -33,6 +33,7 @@ import ( "github.com/sustainable-computing-io/kepler/pkg/config" "github.com/sustainable-computing-io/kepler/pkg/model/types" + "github.com/sustainable-computing-io/kepler/pkg/node" "github.com/sustainable-computing-io/kepler/pkg/sensors/components/source" ) @@ -142,7 +143,7 @@ func genRegressor(outputType types.ModelOutputType, energySource, modelServerEnd func GetNodePlatformPowerFromDummyServer(handler http.HandlerFunc, trainer string) (power []uint64) { testServer := httptest.NewServer(handler) - modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.PlatformEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.PlatformEnergySource, node.CPUArchitecture()) r := genRegressor(types.AbsPower, types.PlatformEnergySource, testServer.URL, "", modelWeightFilepath, trainer) err := r.Start() Expect(err).To(BeNil()) @@ -156,7 +157,7 @@ func GetNodePlatformPowerFromDummyServer(handler http.HandlerFunc, trainer strin func GetNodeComponentsPowerFromDummyServer(handler http.HandlerFunc, trainer string) (compPowers []source.NodeComponentsEnergy) { testServer := httptest.NewServer(handler) - modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.ComponentEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.ComponentEnergySource, node.CPUArchitecture()) r := genRegressor(types.AbsPower, types.ComponentEnergySource, testServer.URL, "", modelWeightFilepath, trainer) err := r.Start() Expect(err).To(BeNil()) @@ -184,7 +185,7 @@ var _ = Describe("Test Regressor Weight Unit (default trainer)", func() { It("Get Process Platform Power By Default Regression Estimator with ModelServerEndpoint", func() { testServer := httptest.NewServer(DummyWeightHandler) - modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.PlatformEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.PlatformEnergySource, node.CPUArchitecture()) r := genRegressor(types.DynPower, types.PlatformEnergySource, testServer.URL, "", modelWeightFilepath, "") err := r.Start() Expect(err).To(BeNil()) @@ -205,7 +206,7 @@ var _ = Describe("Test Regressor Weight Unit (default trainer)", func() { It("Get Process Components Power By Default Regression Estimator with ModelServerEndpoint", func() { testServer := httptest.NewServer(DummyWeightHandler) - modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.ComponentEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.ComponentEnergySource, node.CPUArchitecture()) r := genRegressor(types.DynPower, types.ComponentEnergySource, testServer.URL, "", modelWeightFilepath, "") err := r.Start() Expect(err).To(BeNil()) @@ -229,7 +230,7 @@ var _ = Describe("Test Regressor Weight Unit (default trainer)", func() { Context("without model server", func() { It("Get Node Platform Power By Default Regression Estimator without ModelServerEndpoint", func() { /// Estimate Node Components Power using Linear Regression - modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.ComponentEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.ComponentEnergySource, node.CPUArchitecture()) initModelURL := "https://raw.githubusercontent.com/sustainable-computing-io/kepler-model-db/main/models/v0.6/nx12/std_v0.6/acpi/AbsPower/BPFOnly/SGDRegressorTrainer_1.json" r := genRegressor(types.AbsPower, types.PlatformEnergySource, "", initModelURL, modelWeightFilepath, "") err := r.Start() @@ -242,7 +243,7 @@ var _ = Describe("Test Regressor Weight Unit (default trainer)", func() { It("Get Node Components Power By Default Regression Estimator without ModelServerEndpoint", func() { /// Estimate Node Components Power using Linear Regression - modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.ComponentEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.AbsPower.String(), types.ComponentEnergySource, node.CPUArchitecture()) initModelURL := "https://raw.githubusercontent.com/sustainable-computing-io/kepler-model-db/main/models/v0.6/nx12/std_v0.6/rapl/AbsPower/BPFOnly/SGDRegressorTrainer_1.json" r := genRegressor(types.AbsPower, types.ComponentEnergySource, "", initModelURL, modelWeightFilepath, "") err := r.Start() @@ -255,7 +256,7 @@ var _ = Describe("Test Regressor Weight Unit (default trainer)", func() { It("Get Process Components Power By Default Regression Estimator without ModelServerEndpoint", func() { // Estimate Process Components Power using Linear Regression - modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.ComponentEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.ComponentEnergySource, node.CPUArchitecture()) initModelURL := "https://raw.githubusercontent.com/sustainable-computing-io/kepler-model-db/main/models/v0.6/nx12/std_v0.6/acpi/DynPower/BPFOnly/SGDRegressorTrainer_1.json" r := genRegressor(types.DynPower, types.PlatformEnergySource, "", initModelURL, modelWeightFilepath, "") err := r.Start() @@ -270,7 +271,7 @@ var _ = Describe("Test Regressor Weight Unit (default trainer)", func() { It("Get Process Components Power By Default Regression Estimator without ModelServerEndpoint", func() { // Estimate Process Components Power using Linear Regression - modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.ComponentEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.ComponentEnergySource, node.CPUArchitecture()) initModelURL := "https://raw.githubusercontent.com/sustainable-computing-io/kepler-model-db/main/models/v0.6/nx12/std_v0.6/rapl/DynPower/BPFOnly/SGDRegressorTrainer_1.json" r := genRegressor(types.DynPower, types.ComponentEnergySource, "", initModelURL, modelWeightFilepath, "") err := r.Start() @@ -288,7 +289,7 @@ var _ = Describe("Test Regressor Weight Unit (default trainer)", func() { DescribeTable("Test core ratio computation", func(discoveredCore, modelCores int, expectedCoreRatio float64) { ModelCores = modelCores testServer := httptest.NewServer(DummyWeightHandler) - modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.PlatformEnergySource) + modelWeightFilepath := config.GetDefaultPowerModelURL(types.DynPower.String(), types.PlatformEnergySource, node.CPUArchitecture()) r := genRegressor(types.DynPower, types.PlatformEnergySource, testServer.URL, "", modelWeightFilepath, "") r.DiscoveredMachineSpec = &config.MachineSpec{ Cores: discoveredCore, diff --git a/pkg/model/node_component_energy.go b/pkg/model/node_component_energy.go index d5e78992f2..aaf1ff88f2 100644 --- a/pkg/model/node_component_energy.go +++ b/pkg/model/node_component_energy.go @@ -37,7 +37,7 @@ func createNodeComponentPowerModelConfig(nodeFeatureNames []string) *types.Model systemMetaDataFeatureValues := node.MetadataFeatureValues() modelConfig := CreatePowerModelConfig(config.NodeComponentsPowerKey()) if modelConfig.InitModelURL == "" { - modelConfig.InitModelFilepath = config.GetDefaultPowerModelURL(modelConfig.ModelOutputType.String(), types.ComponentEnergySource) + modelConfig.InitModelFilepath = config.GetDefaultPowerModelURL(modelConfig.ModelOutputType.String(), types.ComponentEnergySource, node.CPUArchitecture()) } modelConfig.NodeFeatureNames = nodeFeatureNames modelConfig.SystemMetaDataFeatureNames = systemMetaDataFeatureNames diff --git a/pkg/model/node_platform_energy.go b/pkg/model/node_platform_energy.go index 346f82266b..dc3680b84a 100644 --- a/pkg/model/node_platform_energy.go +++ b/pkg/model/node_platform_energy.go @@ -40,7 +40,7 @@ func CreateNodePlatformPoweEstimatorModel(nodeFeatureNames []string) { if !platform.IsSystemCollectionSupported() { modelConfig := CreatePowerModelConfig(config.NodePlatformPowerKey()) if modelConfig.InitModelURL == "" { - modelConfig.InitModelFilepath = config.GetDefaultPowerModelURL(modelConfig.ModelOutputType.String(), types.PlatformEnergySource) + modelConfig.InitModelFilepath = config.GetDefaultPowerModelURL(modelConfig.ModelOutputType.String(), types.PlatformEnergySource, node.CPUArchitecture()) } modelConfig.NodeFeatureNames = nodeFeatureNames modelConfig.SystemMetaDataFeatureNames = systemMetaDataFeatureNames diff --git a/pkg/model/process_energy.go b/pkg/model/process_energy.go index 32b22cfa3d..0112a77b47 100644 --- a/pkg/model/process_energy.go +++ b/pkg/model/process_energy.go @@ -44,7 +44,7 @@ func createProcessPowerModelConfig(powerSourceTarget string, processFeatureNames return nil } if modelConfig.InitModelURL == "" { - modelConfig.InitModelFilepath = config.GetDefaultPowerModelURL(modelConfig.ModelOutputType.String(), energySource) + modelConfig.InitModelFilepath = config.GetDefaultPowerModelURL(modelConfig.ModelOutputType.String(), energySource, node.CPUArchitecture()) } modelConfig.ProcessFeatureNames = processFeatureNames modelConfig.SystemMetaDataFeatureNames = systemMetaDataFeatureNames