<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>power &#8211; Huahua&#8217;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/power/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 05 Feb 2026 17:19:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.4</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>power &#8211; Huahua&#8217;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>避坑指南：给模型训练加点速度，顺便聊聊 MBP 的电源模式</title>
		<link>https://zxi.mytechroad.com/blog/hardware/mbp-high-power-vs-low-power/</link>
					<comments>https://zxi.mytechroad.com/blog/hardware/mbp-high-power-vs-low-power/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Thu, 05 Feb 2026 17:17:49 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[mbp]]></category>
		<category><![CDATA[power]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=10581</guid>

					<description><![CDATA[最近在折腾一个模型训练任务，结果发现了一个挺有意思的现象。我的 16&#8243; M1 Max MBP 插着电源线，电量竟然还在嗖嗖往下掉。查了一下才发现，随手抓的那个苹果 67W 充电器在模型训练面前简直是“入不敷出”。 为了看看到底差多少，我针对 Low Power Mode（低电量模式） 和 High Power Mode（高功率模式） 做了一组对比测试。数据非常直观，分享给大家参考。 注：高功率模式 (High Power Mode) 最早是在 2021 年 10&#8230;]]></description>
										<content:encoded><![CDATA[
<p>最近在折腾一个模型训练任务，结果发现了一个挺有意思的现象。我的 16&#8243; M1 Max MBP 插着电源线，电量竟然还在嗖嗖往下掉。查了一下才发现，随手抓的那个苹果 67W 充电器在模型训练面前简直是“入不敷出”。</p>



<p>为了看看到底差多少，我针对 <strong>Low Power Mode（低电量模式）</strong> 和 <strong>High Power Mode（高功率模式）</strong> 做了一组对比测试。数据非常直观，分享给大家参考。<br><br>注：<strong>高功率模式 (High Power Mode)</strong> 最早是在 <strong>2021 年 10 月</strong> 随 macOS Monterey 发布的，当时仅限配备 <strong>M1 Max</strong> 芯片的 <strong>16 英寸</strong> MacBook Pro 使用。</p>



<h3 class="wp-block-heading">性能实测：低功耗 vs 高功率</h3>



<p>在模型训练压测下，我记录了 CPU、GPU 以及 ANE（神经网络引擎）的功耗表现：</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>指标</strong></td><td><strong>低电量模式 (Low Power)</strong></td><td><strong>高功率模式 (High Power)</strong></td><td><strong>增幅 / 差异</strong></td></tr></thead><tbody><tr><td><strong>CPU Power</strong></td><td>4,038 mW</td><td>6,903 mW</td><td>+70.9%</td></tr><tr><td><strong>GPU Power</strong></td><td>13,524 mW</td><td>26,947 mW</td><td>+99.2%</td></tr><tr><td><strong>ANE Power</strong></td><td>0 mW</td><td>0 mW</td><td>&#8211;</td></tr><tr><td><strong>总功耗 (Combined)</strong></td><td>17,619 mW</td><td>33,849 mW</td><td>+92.1%</td></tr><tr><td><strong>GPU 主频 (Avg)</strong></td><td>871 MHz</td><td>1,282 MHz</td><td>+47.1%</td></tr><tr><td><strong>GPU 空闲率</strong></td><td>8.57%</td><td>1.19%</td><td>负载更饱和</td></tr><tr><td><strong>训练速度</strong></td><td>650ms/step</td><td>475ms/step</td><td>-36.8%</td></tr></tbody></table></figure>



<h3 class="wp-block-heading">深度发现</h3>



<ol start="1" class="wp-block-list">
<li><strong>GPU 功耗几乎翻倍</strong>：在高功率模式下，GPU 的功耗从 13.5W 直接跳到了近 27W。观察频率分布可以发现，低功耗模式下 GPU 频率最高只到了 972 MHz (占比 29%)，而高功率模式下 <strong>95% 的时间都顶在 1296 MHz</strong> 运行。训练速度提高了不到40%，比频率提升47.1%稍低一些。</li>



<li><strong>风扇策略的差异</strong>：高功率模式不仅仅是放开了功耗墙，更重要的是它优化了散热策略。这也是为什么 16 寸 M1 Max 专享这个功能的原因——得有足够的散热模组才能压得住这额外的十几瓦发热。</li>



<li><strong>电源适配器的重要性</strong>：测试数据显示，单单 SoC 部分的功耗就达到了 34W 左右。如果再加上屏幕亮度、内存读写以及其他硬件开销，整机功耗轻轻松松突破 50W。难怪 67W 的头充不进电，以后出门干重活，还是得带上原装的 140W 大头。</li>
</ol>



<h3 class="wp-block-heading">总结</h3>



<p>macOS 的电源模式确实不是摆设。<strong>低电量模式</strong>适合出门在外写写代码、浏览网页，能显著延长续航；但如果你和我一样需要<strong>训练模型</strong>或者<strong>高强度渲染</strong>，一定要手动开启<strong>高功率模式</strong>。</p>



<p>虽然这会让风扇声大一点，但节省下来的训练时间才是最宝贵的。顺便提醒一句：<strong>工欲善其事，必先带好那个 140W 的适配器！</strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/hardware/mbp-high-power-vs-low-power/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 1922. Count Good Numbers</title>
		<link>https://zxi.mytechroad.com/blog/math/leetcode-1922-count-good-numbers/</link>
					<comments>https://zxi.mytechroad.com/blog/math/leetcode-1922-count-good-numbers/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 26 Dec 2021 03:12:43 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[power]]></category>
		<category><![CDATA[powmod]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=9241</guid>

					<description><![CDATA[A digit string is&#160;good&#160;if the digits&#160;(0-indexed)&#160;at&#160;even&#160;indices are&#160;even&#160;and the digits at&#160;odd&#160;indices are&#160;prime&#160;(2,&#160;3,&#160;5, or&#160;7). For example,&#160;"2582"&#160;is good because the digits (2&#160;and&#160;8) at even positions are even and&#8230;]]></description>
										<content:encoded><![CDATA[
<p>A digit string is&nbsp;<strong>good</strong>&nbsp;if the digits&nbsp;<strong>(0-indexed)</strong>&nbsp;at&nbsp;<strong>even</strong>&nbsp;indices are&nbsp;<strong>even</strong>&nbsp;and the digits at&nbsp;<strong>odd</strong>&nbsp;indices are&nbsp;<strong>prime</strong>&nbsp;(<code>2</code>,&nbsp;<code>3</code>,&nbsp;<code>5</code>, or&nbsp;<code>7</code>).</p>



<ul class="wp-block-list"><li>For example,&nbsp;<code>"2582"</code>&nbsp;is good because the digits (<code>2</code>&nbsp;and&nbsp;<code>8</code>) at even positions are even and the digits (<code>5</code>&nbsp;and&nbsp;<code>2</code>) at odd positions are prime. However,&nbsp;<code>"3245"</code>&nbsp;is&nbsp;<strong>not</strong>&nbsp;good because&nbsp;<code>3</code>&nbsp;is at an even index but is not even.</li></ul>



<p>Given an integer&nbsp;<code>n</code>, return&nbsp;<em>the&nbsp;<strong>total</strong>&nbsp;number of good digit strings of length&nbsp;</em><code>n</code>. Since the answer may be large,&nbsp;<strong>return it modulo&nbsp;</strong><code>10<sup>9</sup>&nbsp;+ 7</code>.</p>



<p>A&nbsp;<strong>digit string</strong>&nbsp;is a string consisting of digits&nbsp;<code>0</code>&nbsp;through&nbsp;<code>9</code>&nbsp;that may contain leading zeros.</p>



<p><strong>Example 1:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 1
<strong>Output:</strong> 5
<strong>Explanation:</strong> The good numbers of length 1 are "0", "2", "4", "6", "8".
</pre>



<p><strong>Example 2:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 4
<strong>Output:</strong> 400
</pre>



<p><strong>Example 3:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 50
<strong>Output:</strong> 564908303
</pre>



<p><strong>Constraints:</strong></p>



<ul class="wp-block-list"><li><code>1 &lt;= n &lt;= 10<sup>15</sup></code></li></ul>



<h2 class="wp-block-heading"><strong>Solution: Fast Power</strong></h2>



<p>Easy to see that f(n) = (4 + (n &amp; 1)) * f(n &#8211; 1), f(1) = 5</p>



<p>However, since n is huge, we need to rewrite f(n) as 4<sup>n/2</sup> * 5<sup>(n+1)/2</sup> and use fast power to compute it.</p>



<p>Time complexity: O(logn)<br>Space complexity: O(1)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="urvanov-syntax-highlighter-plain-tag">// Author: Huahua
constexpr int kMod = 1e9 + 7;
long long modPow(long long base, long long n) {
  long long ans = 1;
  while (n) {
    if (n &amp; 1) ans = (ans * base) % kMod;
    base = (base * base) % kMod;
    n &gt;&gt;= 1;
  }
  return ans;
}
class Solution {
public:
  int countGoodNumbers(long long n) {
    return (modPow(4, n / 2) * modPow(5, (n + 1) / 2)) % kMod;
  }
};</pre>
</div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/math/leetcode-1922-count-good-numbers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
