Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
66 stars 23 forks source link

CPU Parameters for Xeon don't seem correct #155

Closed ajagann closed 1 year ago

ajagann commented 1 year ago

Bug description

Calling the API to retrieve the component CPU characteristics for different Xeon CPUs results in identical information.

To Reproduce

Selected two Xeon models from the result of calling /v1/utils/cpu_model_range. I chose Xeon Platinum and Xeon Gold.

curl -X 'POST' \
  'https://api.boavizta.org/v1/component/cpu?verbose=true&allocation=TOTAL' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "xeon platinum"
}'

produces an identical output to

curl -X 'POST' \
  'https://api.boavizta.org/v1/component/cpu?verbose=true&allocation=TOTAL' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "xeon gold"
}'

Expected behavior

I'm expecting to see at least see these differences in parameter values which are listed in the Boadvizta documentation (https://doc.api.boavizta.org/Explanations/components/cpu/)

Model a b c d
Xeon Platinum 342.3624349628362 0.034750819765533035 36.89522616719806 -16.402219089443307
Xeon Gold 71.13767381183924 0.2280562153242743 9.66939980437224 6.266004455550223

JSON OUTPUT

Output for Xeon Gold

{
  "impacts": {
    "gwp": {
      "manufacture": 21.7,
      "use": 610,
      "unit": "kgCO2eq"
    },
    "pe": {
      "manufacture": 325,
      "use": 20550,
      "unit": "MJ"
    },
    "adp": {
      "manufacture": 0.02,
      "use": 0.000102,
      "unit": "kgSbeq"
    }
  },
  "verbose": {
    "units": 1,
    "manufacture_impacts": {
      "gwp": {
        "value": 21.7,
        "unit": "kgCO2eq"
      },
      "pe": {
        "value": 325,
        "unit": "MJ"
      },
      "adp": {
        "value": 0.02,
        "unit": "kgSbeq"
      }
    },
    "core_units": {
      "value": 24,
      "unit": "none",
      "status": "DEFAULT",
      "source": null
    },
    "die_size_per_core": {
      "value": 0.245,
      "unit": "mm2",
      "status": "DEFAULT",
      "source": null
    },
    "USAGE": {
      "usage_impacts": {
        "gwp": {
          "value": 610,
          "unit": "kgCO2eq"
        },
        "pe": {
          "value": 20550,
          "unit": "MJ"
        },
        "adp": {
          "value": 0.000102,
          "unit": "kgSbeq"
        }
      },
      "hours_electrical_consumption": {
        "value": 182.23,
        "unit": "W",
        "status": "COMPLETED",
        "source": null
      },
      "time_workload": {
        "value": 50,
        "unit": "%",
        "status": "DEFAULT",
        "source": null
      },
      "usage_location": {
        "value": "EEE",
        "unit": "CodSP3 - NCS Country Codes - NATO",
        "status": "DEFAULT",
        "source": null
      },
      "adp_factor": {
        "value": 6.42e-8,
        "unit": "KgSbeq/kWh",
        "status": "COMPLETED",
        "source": "ADEME BASE IMPACT"
      },
      "gwp_factor": {
        "value": 0.38,
        "unit": "kgCO2e/kWh",
        "status": "COMPLETED",
        "source": "https://www.sciencedirect.com/science/article/pii/S0306261921012149 : \nAverage of 27 european countries"
      },
      "pe_factor": {
        "value": 12.874,
        "unit": "MJ/kWh",
        "status": "COMPLETED",
        "source": "ADPf / (1-%renewable_energy)"
      },
      "use_time": {
        "value": 8760,
        "unit": "hours",
        "status": "DEFAULT",
        "source": null
      },
      "params": {
        "value": {
          "a": 171.2,
          "b": 0.0354,
          "c": 36.89,
          "d": -10.13
        },
        "unit": "none",
        "status": "DEFAULT",
        "source": null
      }
    }
  }
}

Output for Xeon Platinum

{
  "impacts": {
    "gwp": {
      "manufacture": 21.7,
      "use": 610,
      "unit": "kgCO2eq"
    },
    "pe": {
      "manufacture": 325,
      "use": 20550,
      "unit": "MJ"
    },
    "adp": {
      "manufacture": 0.02,
      "use": 0.000102,
      "unit": "kgSbeq"
    }
  },
  "verbose": {
    "units": 1,
    "manufacture_impacts": {
      "gwp": {
        "value": 21.7,
        "unit": "kgCO2eq"
      },
      "pe": {
        "value": 325,
        "unit": "MJ"
      },
      "adp": {
        "value": 0.02,
        "unit": "kgSbeq"
      }
    },
    "core_units": {
      "value": 24,
      "unit": "none",
      "status": "DEFAULT",
      "source": null
    },
    "die_size_per_core": {
      "value": 0.245,
      "unit": "mm2",
      "status": "DEFAULT",
      "source": null
    },
    "USAGE": {
      "usage_impacts": {
        "gwp": {
          "value": 610,
          "unit": "kgCO2eq"
        },
        "pe": {
          "value": 20550,
          "unit": "MJ"
        },
        "adp": {
          "value": 0.000102,
          "unit": "kgSbeq"
        }
      },
      "hours_electrical_consumption": {
        "value": 182.23,
        "unit": "W",
        "status": "COMPLETED",
        "source": null
      },
      "time_workload": {
        "value": 50,
        "unit": "%",
        "status": "DEFAULT",
        "source": null
      },
      "usage_location": {
        "value": "EEE",
        "unit": "CodSP3 - NCS Country Codes - NATO",
        "status": "DEFAULT",
        "source": null
      },
      "adp_factor": {
        "value": 6.42e-8,
        "unit": "KgSbeq/kWh",
        "status": "COMPLETED",
        "source": "ADEME BASE IMPACT"
      },
      "gwp_factor": {
        "value": 0.38,
        "unit": "kgCO2e/kWh",
        "status": "COMPLETED",
        "source": "https://www.sciencedirect.com/science/article/pii/S0306261921012149 : \nAverage of 27 european countries"
      },
      "pe_factor": {
        "value": 12.874,
        "unit": "MJ/kWh",
        "status": "COMPLETED",
        "source": "ADPf / (1-%renewable_energy)"
      },
      "use_time": {
        "value": 8760,
        "unit": "hours",
        "status": "DEFAULT",
        "source": null
      },
      "params": {
        "value": {
          "a": 171.2,
          "b": 0.0354,
          "c": 36.89,
          "d": -10.13
        },
        "unit": "none",
        "status": "DEFAULT",
        "source": null
      }
    }
  }
}

Additional context

da-ekchajzer commented 1 year ago

Thanks for your bug report !

You use the field CPU name, but you provide a model range. If you want to use the xeon gold or xeon platinum please use the model_range field. What happens is that the API is trying to retrieve a cpu named xeon gold, don't find it and use the default parameters.

If you want to provide the CPU name, the API will complete the model_range for you. Here is a list of the CPU names we support : https://github.com/Boavizta/boaviztapi/blob/main/boaviztapi/data/components/cpu_index.csv

example

{
  "model_range": "xeon gold"
}
{
  "impacts": {
    "gwp": {
      "manufacture": 21.7,
      "use": 310,
      "unit": "kgCO2eq"
    },
    "pe": {
      "manufacture": 325,
      "use": 10670,
      "unit": "MJ"
    },
    "adp": {
      "manufacture": 0.02,
      "use": 0.0000532,
      "unit": "kgSbeq"
    }
  },
  "verbose": {
    "units": 1,
    "manufacture_impacts": {
      "gwp": {
        "value": 21.7,
        "unit": "kgCO2eq"
      },
      "pe": {
        "value": 325,
        "unit": "MJ"
      },
      "adp": {
        "value": 0.02,
        "unit": "kgSbeq"
      }
    },
    "core_units": {
      "value": 24,
      "unit": "none",
      "status": "DEFAULT",
      "source": null
    },
    "die_size_per_core": {
      "value": 0.245,
      "unit": "mm2",
      "status": "DEFAULT",
      "source": null
    },
    "model_range": {
      "value": "xeon gold",
      "unit": "none",
      "status": "INPUT",
      "source": null
    },
    "USAGE": {
      "usage_impacts": {
        "gwp": {
          "value": 310,
          "unit": "kgCO2eq"
        },
        "pe": {
          "value": 10670,
          "unit": "MJ"
        },
        "adp": {
          "value": 0.0000532,
          "unit": "kgSbeq"
        }
      },
      "hours_electrical_consumption": {
        "value": 94.624,
        "unit": "W",
        "status": "COMPLETED",
        "source": null
      },
      "time_workload": {
        "value": 50,
        "unit": "%",
        "status": "DEFAULT",
        "source": null
      },
      "usage_location": {
        "value": "EEE",
        "unit": "CodSP3 - NCS Country Codes - NATO",
        "status": "DEFAULT",
        "source": null
      },
      "adp_factor": {
        "value": 6.42e-8,
        "unit": "KgSbeq/kWh",
        "status": "COMPLETED",
        "source": "ADEME BASE IMPACT"
      },
      "gwp_factor": {
        "value": 0.38,
        "unit": "kgCO2e/kWh",
        "status": "COMPLETED",
        "source": "https://www.sciencedirect.com/science/article/pii/S0306261921012149 : \nAverage of 27 european countries"
      },
      "pe_factor": {
        "value": 12.874,
        "unit": "MJ/kWh",
        "status": "COMPLETED",
        "source": "ADPf / (1-%renewable_energy)"
      },
      "use_time": {
        "value": 8760,
        "unit": "hours",
        "status": "DEFAULT",
        "source": null
      },
      "params": {
        "value": {
          "a": 35.5688,
          "b": 0.2438,
          "c": 9.6694,
          "d": -0.6087
        },
        "unit": "none",
        "status": "COMPLETED",
        "source": "From CPU model range"
      }
    }
  }
}

Documentation

I believe the documentation is not explicit enough. Please feel free to point out what was unclear for you.

You remind me that I should update documentation with the last version of the parameters (https://github.com/Boavizta/boaviztapi/blob/main/boaviztapi/data/consumption_profile/cpu/cpu_profile.csv)

ajagann commented 1 year ago

Thank you for clarifying! Where I went wrong was that I didn't quite understand the difference between how model_range and name were to be used. In the documentation, all the examples use the 'name' field, so I suppose I assumed that was the key I needed to use. It might help to add an API call to retrieve CPU names. Right now, I only see a call to retrieve all the possible model ranges.