Skip to content

Commit 978b399

Browse files
author
benoit-cty
committed
Put DRAM=False as default
1 parent 8868148 commit 978b399

7 files changed

Lines changed: 23 additions & 23 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Then run opened test with this button:
224224
<!-- TOC --><a name="coding-style-linting"></a>
225225
### Coding style && Linting
226226

227-
The coding style and linting rules are automatically applied and enforced by [pre-commit](https://pre-commit.com/). This tool helps to maintain the same code style across the code-base such to ease the review and collaboration process. Once installed ([https://pre-commit.com/#installation](https://pre-commit.com/#installation)), you can install a Git hook to automatically run pre-commit (and all configured linters/auto-formatters) before doing a commit with `uv run precommit-install`. Then once you tried to commit, the linters/formatters will run automatically. It should display something similar to:
227+
The coding style and linting rules are automatically applied and enforced by [pre-commit](https://pre-commit.com/). This tool helps to maintain the same code style across the code-base such to ease the review and collaboration process. Once installed ([https://pre-commit.com/#installation](https://pre-commit.com/#installation)), you can install a Git hook to automatically run pre-commit (and all configured linters/auto-formatters) before doing a commit with `uv run task precommit-install`. Then once you tried to commit, the linters/formatters will run automatically. It should display something similar to:
228228

229229
```log
230230
[INFO] Initializing environment for https://github.com/psf/black.

codecarbon/core/cpu.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ class IntelRAPL:
367367
_rapl_files (List[RAPLFile]): A list of RAPLFile objects representing the files to read energy data from.
368368
_cpu_details (Dict): A dictionary storing the latest CPU energy details.
369369
_last_mesure (int): Placeholder for storing the last measurement time.
370-
rapl_include_dram (bool): Whether to include DRAM power in measurements (default: True for complete hardware measurement).
370+
rapl_include_dram (bool): Whether to include DRAM power in measurements (default: False for complete hardware measurement).
371371
rapl_prefer_psys (bool): Whether to prefer psys domain over package domains (default: False).
372372
When True, uses psys (platform/system) domain which includes CPU + platform components.
373373
When False (default), uses package domains which are more reliable and match CPU TDP specs.
374374
375375
Args:
376376
rapl_dir (str): Path to RAPL directory (default: "/sys/class/powercap/intel-rapl/subsystem")
377-
rapl_include_dram (bool): Include DRAM domain for complete hardware measurement (default: True).
377+
rapl_include_dram (bool): Include DRAM domain for complete hardware measurement (default: False).
378378
Set to False to measure only CPU package power.
379379
rapl_prefer_psys (bool): Prefer psys (platform) domain over package domains (default: False).
380380
Set to True to measure total platform power (CPU + chipset + PCIe).
@@ -395,7 +395,7 @@ class IntelRAPL:
395395
def __init__(
396396
self,
397397
rapl_dir="/sys/class/powercap/intel-rapl/subsystem",
398-
rapl_include_dram=True,
398+
rapl_include_dram=False,
399399
rapl_prefer_psys=False,
400400
):
401401
self._lin_rapl_dir = rapl_dir
@@ -427,8 +427,8 @@ def _fetch_rapl_files(self) -> None:
427427
"""
428428
Fetches RAPL files from the RAPL directory.
429429
430-
By default, reads CPU package + DRAM domains for complete hardware power measurement.
431-
Set rapl_include_dram=False to measure only CPU package power.
430+
By default, reads CPU package only
431+
Set rapl_include_dram=True to measure CPU package + DRAM domains
432432
"""
433433
# We'll scan common powercap locations and look for domain directories
434434
# that expose an `energy_uj` file. We try to be tolerant to permission

codecarbon/emissions_tracker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def __init__(
293293
self._set_from_conf(pue, "pue", 1.0, float)
294294
self._set_from_conf(wue, "wue", 0, float)
295295
self._set_from_conf(force_mode_cpu_load, "force_mode_cpu_load", False, bool)
296-
self._set_from_conf(rapl_include_dram, "rapl_include_dram", True, bool)
296+
self._set_from_conf(rapl_include_dram, "rapl_include_dram", False, bool)
297297
self._set_from_conf(rapl_prefer_psys, "rapl_prefer_psys", False, bool)
298298
self._set_from_conf(
299299
experiment_id, "experiment_id", "5b0fa12a-3dd7-45bb-9766-cc326314d9f1"
@@ -1189,7 +1189,7 @@ def track_emissions(
11891189
:param pue: PUE (Power Usage Effectiveness) of the datacenter.
11901190
:param wue: WUE (Water Usage Effectiveness) of the datacenter, L/kWh.
11911191
:param allow_multiple_runs: Prevent multiple instances of codecarbon running. Defaults to False.
1192-
:param rapl_include_dram: Include DRAM domain for RAPL measurements (default: True).
1192+
:param rapl_include_dram: Include DRAM domain for RAPL measurements (default: False).
11931193
:param rapl_prefer_psys: Prefer psys (platform) domain over package domains for RAPL (default: False).
11941194
11951195
:return: The decorated function

codecarbon/external/hardware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def __init__(
168168
tdp: int,
169169
rapl_dir: str = "/sys/class/powercap/intel-rapl/subsystem",
170170
tracking_mode: str = "machine",
171-
rapl_include_dram: bool = True,
171+
rapl_include_dram: bool = False,
172172
rapl_prefer_psys: bool = False,
173173
):
174174
assert tracking_mode in ["machine", "process"]
@@ -337,7 +337,7 @@ def from_utils(
337337
model: Optional[str] = None,
338338
tdp: Optional[int] = None,
339339
tracking_mode: str = "machine",
340-
rapl_include_dram: bool = True,
340+
rapl_include_dram: bool = False,
341341
rapl_prefer_psys: bool = False,
342342
) -> "CPU":
343343
if model is None:

docs/edit/parameters.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ Input Parameters
5353
| *RAM power in W = Number of RAM Slots * 5 Watts*
5454
* - rapl_include_dram
5555
- | Boolean variable indicating if DRAM (memory) power should be included
56-
| in RAPL measurements on Linux systems, defaults to ``True``.
56+
| in RAPL measurements on Linux systems, defaults to ``False``.
5757
| When ``True``, measures complete hardware power (CPU package + DRAM).
5858
| Set to ``False`` to measure only CPU package power.
5959
| Note: Only affects systems where RAPL exposes separate DRAM domains.
60+
| In a future version DRAM power will probably be included in RAM.
6061
* - rapl_prefer_psys
6162
- | Boolean variable indicating if psys (platform/system) RAPL domain should be
6263
| preferred over package domains on Linux systems, defaults to ``False``.

docs/edit/rapl.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Different CPUs expose different domains. Common domains include:
6060
- Ring interconnect between cores
6161
- Integrated GPU (if present)
6262

63-
- **dram**: Memory controller power (rare on consumer hardware, more common on servers)
63+
- **dram**: Memory controller power, rare on consumer hardware, more common on servers. We still have to figure out if it is accurate.
6464

6565
- **gpu**: Discrete or integrated GPU (when available)
6666

@@ -111,7 +111,7 @@ CodeCarbon implements intelligent domain selection to provide reliable and consi
111111

112112
4. **Subdomain filtering**: Excludes ``core`` and ``uncore`` subdomains when ``package`` is available to avoid double-counting
113113

114-
5. **DRAM inclusion**: By default (``include_dram=True``), adds DRAM domain to package for complete hardware power measurement
114+
5. **DRAM exclusion**: By default (``include_dram=False``), don't adds DRAM domain to package. As DRAM is supposed to be in RAM power, not CPU in a future version of CodeCarbon.
115115

116116
Platform-Specific Behavior
117117
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -334,17 +334,17 @@ Key Takeaways for RAPL Measurements
334334

335335
5. **Interface deduplication**: The same domain may appear in both ``intel-rapl`` (MSR) and ``intel-rapl-mmio`` interfaces. CodeCarbon automatically deduplicates, preferring MMIO.
336336

337-
6. **DRAM measurement**: CodeCarbon includes DRAM domains by default (``include_dram=True``) for complete hardware measurement (CPU package + memory). Set ``include_dram=False`` to measure only CPU package.
337+
6. **DRAM measurement**: CodeCarbon does not include DRAM domains by default (``include_dram=False``) for CPU hardware measurement. Set ``include_dram=True`` to measure CPU package + DRAM domains.
338338

339339
7. **Platform-specific behavior**:
340340

341-
- Intel modern: package + dram (default) or psys (with prefer_psys=True)
341+
- Intel modern: package or psys (with prefer_psys=True)
342342
- Intel older: package-0 for CPU only
343343
- AMD: Sum all package-X-die-Y for multi-die CPUs
344344

345345
8. **Limitations**: RAPL does NOT measure:
346346

347347
- Discrete GPUs (use nvidia-smi/rocm-smi)
348348
- SSDs, peripherals, fans
349-
- Actual DRAM chips (only memory controller on CPU)
349+
- Actual DRAM chips, we still have to investigate on this point
350350
- Complete system power (use wall meter for accuracy)

tests/test_rapl_parameters.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212

1313
@pytest.mark.skipif(not sys.platform.lower().startswith("lin"), reason="requires Linux")
14-
def test_rapl_include_dram_default_true(tmp_path):
14+
def test_rapl_include_dram_default_false(tmp_path):
1515
"""
16-
Verify that rapl_include_dram defaults to True and includes DRAM domains.
16+
Verify that rapl_include_dram defaults to False and excludes DRAM domains.
1717
"""
1818
base = tmp_path
1919
rapl_provider = base / "intel-rapl"
@@ -36,13 +36,12 @@ def test_rapl_include_dram_default_true(tmp_path):
3636
# Create IntelRAPL with default parameters
3737
rapl = IntelRAPL(rapl_dir=str(base))
3838

39-
# Should have 2 RAPL files: package-0 + dram
40-
assert len(rapl._rapl_files) == 2, f"Expected 2 files, got {len(rapl._rapl_files)}"
39+
# Should have 1 RAPL files: package-0
40+
assert len(rapl._rapl_files) == 1, f"Expected 1 files, got {len(rapl._rapl_files)}"
4141

4242
# Verify both package and dram are present
4343
names = [f.name for f in rapl._rapl_files]
4444
assert any("Processor Energy" in name for name in names), "Missing package domain"
45-
assert any("dram" in name.lower() for name in names), "Missing DRAM domain"
4645

4746

4847
@pytest.mark.skipif(not sys.platform.lower().startswith("lin"), reason="requires Linux")
@@ -457,8 +456,8 @@ def test_rapl_parameters_stored_correctly(tmp_path):
457456
# Test default values
458457
rapl_default = IntelRAPL(rapl_dir=str(base))
459458
assert (
460-
rapl_default.rapl_include_dram is True
461-
), "Default rapl_include_dram should be True"
459+
rapl_default.rapl_include_dram is False
460+
), "Default rapl_include_dram should be False"
462461
assert (
463462
rapl_default.rapl_prefer_psys is False
464463
), "Default rapl_prefer_psys should be False"

0 commit comments

Comments
 (0)