How to Enable and Tune Power Management to Reduce GPU Heat and Fan Noise in DwarfStar (ds4)
Use the --power N flag (where N is 1–100) to cap GPU duty-cycle and insert sleep intervals after each work unit, lowering temperature and fan speed without changing model outputs.
DwarfStar, the ds4 inference engine, provides a built-in power-management feature that lets you throttle GPU usage by specifying a target percentage of GPU duty-cycle. This article explains how to enable and tune this feature across all ds4 tools, based on the actual source code implementation in the antirez/ds4 repository.
Understanding the Power Management Architecture
The power-management system in ds4 is lightweight by design. It does not modify model weights, quantization, or inference logic—instead, it throttles the GPU by inserting calculated sleep intervals after completing work units (layers during prefill, tokens during generation).
The core mechanism works in three stages:
- Configuration storage: The target percentage is stored in
engine.power_percentorcfg.power_percent - Runtime measurement: The scheduler tracks elapsed GPU time per work unit
- Proportional sleeping: After each unit completes, the engine sleeps to maintain the requested average duty-cycle
This approach preserves deterministic outputs while trading latency for thermal headroom.
Enabling Power Management Across All Tools
The --power flag is uniformly available in every ds4 front-end. Here's how to use it with each tool:
Basic Inference with ds4
# Cap GPU usage at 50% to halve power consumption and heat
./ds4 --power 50 -p "Summarize the latest AI research."
# Lower power for extended background tasks
./ds4 --power 30 -p "Translate this technical documentation" --ctx 128000
Running the HTTP Server
# Run headless server with reduced power budget
./ds4-server --power 40 --ctx 100000
# Useful for always-on deployments where fan noise matters
./ds4-server --power 25 --host 0.0.0.0 --port 8080
Native Coding Agent
# Run the coding agent at reduced power for quieter development sessions
./ds4-agent --power 70
# Minimum viable power for interactive coding (may increase latency)
./ds4-agent --power 35
Benchmarking with Power Constraints
# Measure throughput trade-offs at 30% power
./ds4-bench --power 30 -m ds4flash.gguf --prompt-file speed-bench/promessi_sposi.txt
# Compare baseline vs. throttled performance
./ds4-bench --power 100 -m ds4flash.gguf && ./ds4-bench --power 50 -m ds4flash.gguf
How the Power Management Code Works
CLI Flag Definition
The --power option is declared in ds4_help.c for all tools:
// ds4_help.c lines 69-78
{"power", required_argument, 0, OPT_POWER},
This definition ensures consistent help text and argument parsing across the entire ds4 suite.
Argument Parsing and Validation
Each tool validates the power percentage range. In ds4_cli.c (lines 1283-1290), the main binary parses and validates:
c.engine.power_percent = atoi(optarg);
if (c.engine.power_percent < 1 || c.engine.power_percent > 100) {
fprintf(stderr, "Invalid power percentage: %s\n", optarg);
exit(1);
}
The agent in ds4_agent.c (lines 477-485) performs identical validation for c.power_percent.
Runtime Throttling Implementation
The actual throttling logic resides in ds4_agent.c (lines 8930-8980). Two key functions handle power management:
ds4_session_set_power: Updates the target power percentage for a sessionworker_apply_pending_power: Applies pending power changes to worker threads during execution
The scheduler measures GPU time spent on each layer (prefill) or token (generation), then calculates the required sleep duration to achieve the target duty-cycle. For example, at --power 50, the engine sleeps for approximately as long as it worked, yielding a 50% duty-cycle.
Model-Specific Compatibility
Power management support varies by model architecture:
| Model | Power Management Support |
|---|---|
| DeepSeek V4 Flash/PRO | Full support for 1-100% |
| GLM 5.2 | --power 100 only (default, full speed) |
As noted in the README.md (lines 66-78), GLM 5.2 models currently ignore throttling requests and always run at maximum power. Check your model documentation before relying on power management for thermal control.
Tuning Guidelines for Different Scenarios
Find the right balance for your use case:
- Maximum quiet operation:
--power 20-30— suitable for overnight batch jobs where latency is irrelevant - Balanced desktop use:
--power 50-60— halves heat output with acceptable interactive latency - Performance-critical coding:
--power 70-85— reduces fan noise while maintaining responsiveness - Benchmarking/comparison:
--power 100— baseline measurement, no throttling
Monitor GPU temperature with nvidia-smi or rocm-smi while adjusting. The actual thermal reduction scales non-linearly with duty-cycle due to idle-state power draw.
Summary
- Use
--power Nwhere N is 1-100 to set GPU duty-cycle percentage across all ds4 tools - The feature is implemented via sleep insertion after work units, preserving output correctness
- Configuration happens in
ds4_help.c, parsing in tool-specific files likeds4_cli.c, and throttling inds4_agent.c - DeepSeek V4 Flash/PRO supports full range; GLM 5.2 requires
--power 100 - Lower percentages reduce heat and fan noise proportionally while increasing latency
Frequently Asked Questions
Does power management affect model accuracy or output?
No. The --power flag only inserts sleep delays between computation steps. All mathematical operations remain identical—only timing changes. Results are deterministic given the same random seed and inputs.
Why doesn't my GPU temperature drop linearly with the power percentage?
GPUs have baseline power draw even when idle. At --power 50, you might see 40-45% power reduction rather than 50%. Additionally, thermal mass and cooling system efficiency affect observed temperatures. Use --power 20-30 for maximum thermal benefit.
Can I change power settings during an active session?
Power changes are applied through worker_apply_pending_power in ds4_agent.c, but most ds4 tools set power at startup. For dynamic adjustment, use ds4-server and restart with new parameters, or implement a custom client using the session API.
What happens if I specify --power above 100 or below 1?
The argument parser in ds4_cli.c and ds4_agent.c validates the range and exits with an error message. Valid values are strictly 1-100 inclusive.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →