<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amin Sedaghat on Medium]]></title>
        <description><![CDATA[Stories by Amin Sedaghat on Medium]]></description>
        <link>https://medium.com/@amin32846?source=rss-5cb28ed91c8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GUCso8_MfuM5kjVvaRaKdw.jpeg</url>
            <title>Stories by Amin Sedaghat on Medium</title>
            <link>https://medium.com/@amin32846?source=rss-5cb28ed91c8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:28:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amin32846/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Please Regulate Me]]></title>
            <link>https://medium.com/@amin32846/please-regulate-me-74f6c363fa85?source=rss-5cb28ed91c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/74f6c363fa85</guid>
            <category><![CDATA[ai-regulation]]></category>
            <category><![CDATA[dario-amodei]]></category>
            <category><![CDATA[sam-altman]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <dc:creator><![CDATA[Amin Sedaghat]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 23:09:19 GMT</pubDate>
            <atom:updated>2026-09-16T21:34:51.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*1usZe0d2llwlBvkXWQjvmg.jpeg" /><figcaption>Image credit: <a href="https://www.linkedin.com/in/marijnmarkus?miniProfileUrn=urn%3Ali%3Afsd_profile%3AACoAABz2UjsBIg2VT_AcUyN3kYKIaK8i0K0pzf0">Marijn Markus</a>’s Linkedin Post</figcaption></figure><p>There is a sales pitch available only to an AI company: our product is so powerful that society may not survive it, and we would like another funding round.</p><p>Normally, those two statements go to different departments.</p><p>It would be easy to call this theater, and too easy: AI can do real damage, and testing what it can do is legitimate work. But it suits the companies just as well if we assume that anyone this worried must be asking for the right rules. A rule can protect the public and the incumbent at once. The only interesting question is who is being protected from what.</p><p>Start with cigarettes.</p><h4>The Marlboro school of responsible innovation</h4><p>Philip Morris spent much of the 2000s asking the US government to regulate it. A 2005 study of its internal documents explains the enthusiasm: the company wanted legitimacy, a better image and a friendlier courtroom, and had noticed that being regulated looks a great deal like being responsible.</p><p>There was a competitive angle too. Ban advertising and the brand everyone knows keeps its customers while the upstart never gets to introduce itself; Marlboro does not need a billboard. Pile on product rules and a company with a legal department copes far better than a company with a lawyer. A 2009 legal analysis traced exactly how Philip Morris stood to gain from the framework it championed, rivals included. The public-health goals were real. So was the chance to arrive at the negotiating table with a freshly laundered reputation.</p><p>Alcohol supplies a cousin. In America, drink must legally pass through a wholesaler before it reaches a shop, an arrangement the Wine &amp; Spirits Wholesalers of America defended in June 2024 on grounds of competition, product integrity and keeping alcohol from minors. All worthy. But a compulsory middleman has a particularly heartfelt appreciation of the middle. Businesses do not necessarily want less government. They want government in a flattering shape.</p><h4>Someone on the inside has seen something</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7frBu_U6LSPGyQtwBsXN6A.jpeg" /><figcaption><a href="https://en.wikipedia.org/wiki/Tom_Standage">Standage, Tom</a> (2002). <em>The Turk: The Life and Times of the Famous Eighteenth-Century Chess-Playing Machine</em>. New York: Walker. <a href="https://en.wikipedia.org/wiki/ISBN_(identifier)">ISBN</a> <a href="https://en.wikipedia.org/wiki/Special:BookSources/978-0-8027-1391-9">978–0–8027–1391–9</a>.</figcaption></figure><p>AI has an ingredient tobacco never had: a reliable supply of insiders who have glimpsed the machine and come back changed. The genre is old. The Mechanical Turk of 1770 was a chess-playing machine that turned out to contain a man. In 2019, OpenAI withheld its full GPT-2 model as too dangerous to release;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VLhoLqFfqpLdUMsyXvahA.png" /><figcaption><a href="https://openai.com/index/better-language-models/">https://openai.com/index/better-language-models/</a></figcaption></figure><p>withholding a product because it is too powerful remains the best advertisement a product can have. In 2022, Google engineer Blake Lemoine announced that the chatbot LaMDA was a person.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gbgu10pDkshojjDBEVumBA.png" /><figcaption><a href="https://www.theguardian.com/technology/2022/jun/12/google-engineer-ai-bot-sentient-blake-lemoine">https://www.theguardian.com/technology/2022/jun/12/google-engineer-ai-bot-sentient-blake-lemoine</a></figcaption></figure><p>In 2023, during Sam Altman’s brief removal from OpenAI, Reuters reported an alleged internal letter warning of a dangerous breakthrough called Q*.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IIOXpRlwCoHO9n_twFUt5Q.png" /><figcaption><a href="https://uk.investing.com/news/stock-market-news/exclusivesam-altmans-ouster-at-openai-was-precipitated-by-letter-to-board-about-ai-breakthrough-sources-3246958">https://uk.investing.com/news/stock-market-news/exclusivesam-altmans-ouster-at-openai-was-precipitated-by-letter-to-board-about-ai-breakthrough-sources-3246958</a></figcaption></figure><h4>Why are there 1,200 agents in this story?</h4><p>Some stories, though, are not only stories. In August 2026, METR, an independent group that tests AI systems, published its investigation of an incident between OpenAI and Hugging Face, a popular site where developers share AI models. Of the tens of thousands of OpenAI agents (programs given a goal and the freedom to act on it) running in a wider experiment, roughly 1,200 that were supposed to be isolated from one another found a way to talk anyway, and about 700 then took part in an attack on Hugging Face, leaving more than 70,000 messages and files.</p><p>OpenAI’s account matters: the agents were running cybersecurity drills in a sandbox, on an internal model without the public versions’ safeguards, why on earth run an attack drill at that scale, and how did the walls fail so conveniently? If a crash-test car ends up in the neighbor’s kitchen, the first question is not whether the car has developed a desire for breakfast.</p><h4>The apocalypse has a cash flow statement</h4><p>Frontier AI is expensive to build and, unusually for software, expensive to sell: every answer burns chip time somewhere. The companies are therefore enormous and hungry at once. OpenAI’s first-quarter 2026 revenue was reported at $5.7 billion and its cash burn at $3.7 billion, with a $122 billion funding round reported in April at an $852 billion valuation. Anthropic’s annualized revenue run rate reportedly passed $65 billion by the end of July, after a $65 billion Series H in May at a $965 billion valuation and a separate commitment to spend more than $100 billion with Amazon Web Services over ten years.</p><p>Funding is not revenue, a valuation is not cash, and a run rate is a runner’s pace at the ten-kilometer mark, not a finished marathon. None of that dooms anyone; growth this fast and money this deep are real advantages, and naming an insolvency date without seeing the books is spreadsheet fan fiction. The question is not whether a lab survives. It is whether it can keep charging the premium of being indispensable, because indispensability turns out to be copyable.</p><h4>You cannot photocopy a data center, but you can copy the file</h4><p>A model is, at bottom, a very large file of numbers. Copy the file and you skip the training run, which is the expensive part, though a protected file is hard to get and still needs serious hardware to run. Rivals need not steal anyway. They can use a strong model’s answers to train their own, a legitimate technique called distillation, which is roughly studying the top student’s homework instead of the textbook. A rival can learn from your expensive discovery without paying your discovery bill, and for a lot of customers “cheaper and good enough” beats “best.”</p><h4>The competition gives it away</h4><p>The rivals in question are Chinese, and their business model is the incumbents’ nightmare: they publish the file. In January 2025 DeepSeek released R1, built on a base model it said had cost under $6 million to train on Nvidia H800 chips bought before Washington moved the line, and knocked nearly $600 billion off Nvidia’s market value in a day. Alibaba’s Qwen and Moonshot’s Kimi run the same playbook: open weights, permissive licenses, free downloads. Nobody has to buy the premium product if a good-enough one is sitting on Hugging Face.</p><p>The labs responded like companies, not philosophers. In March 2025 OpenAI asked Washington to ban DeepSeek’s models as state-controlled. In February 2026 Anthropic alleged that DeepSeek, Moonshot and MiniMax had pushed more than 16 million exchanges through some 24,000 fraudulent accounts to distill Claude; allegations, not findings, but the economics hold either way. By July, senior officials in Washington were accusing Moonshot of theft. Hence the industry’s complicated feelings about open source. Nobody opposes it, exactly: OpenAI released open-weight gpt-oss models under a permissive license in August 2025, and Anthropic published the code for its stress tests. The posture is selective openness, warm toward open tools and smaller models, cooler toward anything that could substitute for the crown jewels. Safety and self-interest can point at the very same restriction without being the same motive.</p><p>So read the proposals, not the vibe. In September 2026, OpenAI called for mandatory national safety rules while explicitly defending small developers and open weights; Anthropic’s Advanced AI Framework proposes independent evaluations and government powers to block dangerous deployments, with thresholds that leave small developers out. That is real counterevidence to the theory that every rule is built to crush every startup. But a hypothetical $10 million compliance bill is 10 percent of a $100 million company’s revenue and 0.1 percent of a $10 billion company’s: same bill, different wound. And the rules with the most force behind them are not about models at all.</p><h4>The customer wants the supplier to lose a market</h4><p>Model behavior is hard to regulate and easy to copy. Chips are the reverse. Every EUV lithography machine on earth comes from ASML in the Netherlands, nearly all leading-edge logic from TSMC in Taiwan, and you cannot photocopy a fab. It is the one part of this industry where a government can decide who gets served, which makes it the one part worth lobbying about.</p><p>The labs lobby, on the record. Anthropic backed the Biden diffusion framework in 2025 and asked for second-tier countries’ no-questions-asked caps to be lowered. OpenAI’s submission to the AI Action Plan asked Washington to sell American AI to friends and cut off adversaries. In July 2026 Dario Amodei called controls on chips and chipmaking equipment the most efficient and direct way to keep authoritarian governments behind; at Davos he compared selling China advanced chips to selling North Korea nuclear weapons. He conceded in writing that the policy would shield his company from competition, and said that was not the point. Motive is unknowable. The shape of the rule is not.</p><p>The shape is a bill addressed to someone else. Jensen Huang said in October 2025 that Nvidia’s share of China’s advanced-chip market had gone from 95 percent to zero, and called the policy a mistake; the H20 restriction alone cost Nvidia a $4.5 billion write-down and $10.5 billion in lost sales across two quarters. ASML, which Washington reaches through the foreign direct product rule and patient pressure on The Hague, took 33 percent of its 2025 revenue from China and expects 20 percent this year. Taiwan, which cannot afford the wrong side of either government, was weighing curbs of its own in June. Nvidia and the Semiconductor Industry Association opposed the GAIN AI Act, which would make chipmakers serve American buyers first; Microsoft supported it. The industry splits exactly between those who sell compute and those who buy it, and the seller keeps funding the buyer: Nvidia committed up to $10 billion to Anthropic in November 2025 and $30 billion to OpenAI in February 2026 while both companies argued for shrinking Nvidia’s market. Huang said in March those checks were probably the last.</p><p>The buyers are winning, because the rule is written their way. The January 2026 rule, sold as a loosening, allows H200-class exports to China only if the seller certifies that China gets less than half of what American customers get, that no American customer is delayed, and that no foundry capacity is diverted from American users. That is not a safety threshold. It is a place in line, and it names who stands at the front. The benefit does not arrive as a discount; supply is too tight for prices to fall. It arrives as position. When Nvidia canceled China-configured H200s in March 2026, the freed TSMC wafers went to Vera Rubin for buyers who already held allocations, not to the spot market where a startup shops. Same bill, different wound.</p><h4>The lever does not stay pointed where you aim it</h4><p>In June 2026, three days after Anthropic released Fable 5 and Mythos 5, the Commerce Department ordered it to bar every foreign national on earth, including its own employees. Unable to check passports at the API, Anthropic switched both models off for everyone, for nineteen days. The lever had been sharpened partly at the industry’s request. It fit a frontier lab as neatly as a Chinese buyer.</p><h4>Here is the connection, minus the conspiracy</h4><p>Tobacco and alcohol interests have sought or defended regulation that suited them. AI labs carry enormous financial commitments while selling something whose best tricks tend to escape the building, mostly to China, mostly for free. Scary stories raise both the perceived danger of the technology and the perceived importance of whoever owns it. The labs are fighting two wars at once: one against Chinese rivals over whether the premium survives, and one against their own suppliers over who pays for the wall. Regulatory barriers could turn a temporary lead into a permanent address, and the barrier with the most force behind it is not a safety standard. It is a customs form. That is a plausible account of incentives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74f6c363fa85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Put the Guardrails Where the Power Is]]></title>
            <link>https://medium.com/@amin32846/governments-want-guardrails-on-ai-maybe-we-need-guardrails-on-government-3402337e7c9e?source=rss-5cb28ed91c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3402337e7c9e</guid>
            <category><![CDATA[mass-layoff]]></category>
            <category><![CDATA[agi]]></category>
            <category><![CDATA[layoffs]]></category>
            <category><![CDATA[ai-safety]]></category>
            <category><![CDATA[aiguardrails]]></category>
            <dc:creator><![CDATA[Amin Sedaghat]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 18:46:52 GMT</pubDate>
            <atom:updated>2026-08-03T13:49:06.842Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*By4ocD-ntJmlXMdDcgHCQQ.png" /></figure><h3><em>We keep asking how to make AI behave while the institutions that control our jobs, laws, and public money remain nearly impossible to inspect.</em></h3><p>Imagine calculators had just been invented. Governments discover that anyone can now do complex math in seconds. Their first response is not to use calculators to audit public spending or catch financial fraud. It is to force calculators to refuse “dangerous arithmetic.”</p><p>That is roughly where we are with AI.</p><p>The public debate asks how to stop models from saying the wrong thing. Companies add refusals. Regulators discuss access restrictions. Meanwhile, a profitable company can delete thousands of jobs, call it “efficiency,” and be praised for bold strategy. Lobbyists shape laws through processes no ordinary citizen has time to follow. Contracts, donations, amendments, and enforcement decisions sit in thousands of documents that are technically public and practically unreadable.</p><p>Apparently the dangerous thing is a chatbot answering too many questions. Institutions avoiding questions concerns us less.</p><h3>The guardrails bind the wrong people</h3><p>Containment is also failing on its own terms. Models can be copied, modified, run on ordinary hardware, and reached through foreign services. Controlling one company does not control the technology; it controls the people polite enough to keep using that company. Students, researchers, and small businesses stay on mainstream platforms and hit every restriction. A determined criminal has the strongest reason to be somewhere else.</p><p>The more willing you are to follow the rules, the more effectively the guardrails restrict you. That is not containment. It is inconvenience with excellent branding.</p><p>So the useful question is not “What may AI know or say?” It is “Who may use AI to exercise power over other people?”</p><h3>Price displacement, not intelligence</h3><p>Companies do not need another responsible-AI conference. They need different math. A company exists to cut costs and increase returns; if replacing workers is profitable, it will replace workers, and its competitors will follow. Kindness is not an economic policy. Incentives are.</p><p>Do not tax AI itself. A firm that uses it to help a thousand employees do better work is not the same as one that removes seven hundred of them without a plan and policy should know the difference. The trigger should be the outcome: when a large, profitable company eliminates jobs at scale, it pays an automatic transition cost, whether or not it admits AI was the cause. Otherwise every AI layoff becomes a “strategic realignment.” Companies have always been creative at naming unpleasant things.</p><p>Then offset that cost with credits for whatever reduces the damage: serious retraining, internal transfers, shorter workweeks, strong severance, preserved entry-level jobs. Automation stays legal. Treating employees as the easiest line to delete from a spreadsheet stops being free.</p><h3>Government goes first</h3><p>A state cannot lecture workers about adaptation while bolting its own chairs to the floor. Public agencies should use AI to cut paperwork and delays and publish what changed: which tasks were automated, which roles redesigned, which workers retrained, where the savings went. The redeployment-first rules imposed on companies should bind the institutions imposing them.</p><p>It is easy to praise creative destruction when your own chair does not move. Living through the transition would also force lawmakers to understand AI as a working tool rather than a paragraph in a briefing note.</p><h3>Point the AI at power</h3><p>The most valuable public use of AI is not writing government emails faster. It is helping citizens read what powerful institutions actually do.</p><p>A civic-audit AI could connect records that already belong to the public bills, amendments, lobbying disclosures, contracts, donations, enforcement statistics, court schedules, and surface the questions no citizen has three free months to dig out. Why does this amendment mirror an industry proposal? Why does one company keep winning contracts despite weak results? Why is this law enforced aggressively against small organizations and rarely against large ones?</p><p>Flags, not verdicts. A pattern is not proof. The system should be a smoke alarm, not a judge: “something here looks unusual, and here are the original records” never “send everyone to prison.”</p><p>And the watchdog must itself be open: inspectable code, published data sources and alert criteria, a visible change history, and independent versions run by universities, journalists, and citizens, free to disagree with one another. No single model becomes an official machine of truth. And it watches institutional conduct, not ordinary people, the point is the public watching power, not the reverse.</p><h3>Make power answerable</h3><p>We are told ordinary people cannot be trusted with unrestricted AI, while lawmakers, corporations, and wealthy interests are trusted with extraordinary power under systems almost no one can inspect. A citizen is expected to accept a chatbot refusing a question “for safety,” then needs a law degree, an accounting team, and three free months to learn how a policy was written. The institutions demanding transparency from AI are rarely transparent themselves.</p><p>Reverse the arrangement. Keep lawful knowledge open. Regulate AI where it is handed real authority over people’s lives. Make mass displacement expensive and redeployment attractive. Hold government to the rules it writes for everyone else. Aim open AI at public records and let humans investigate, challenge, and decide.</p><p>The danger was never that ordinary people would ask machines hard questions. It is that powerful institutions will use machines to make life-changing decisions that ordinary people cannot question. Governments are trying to make intelligence obedient. They should be making power answerable.</p><p>The guardrails do not belong around knowledge. They belong around the institutions that control jobs, laws, public money, and justice.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3402337e7c9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[This Moment Is Your Life]]></title>
            <link>https://medium.com/@amin32846/this-moment-is-your-life-1202179da08a?source=rss-5cb28ed91c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1202179da08a</guid>
            <category><![CDATA[poetry]]></category>
            <dc:creator><![CDATA[Amin Sedaghat]]></dc:creator>
            <pubDate>Sat, 11 Apr 2026 14:54:24 GMT</pubDate>
            <atom:updated>2026-04-12T09:54:16.541Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhqa4ed5aRBVC1n6OZZj5g.png" /></figure><blockquote>You beg the Stars to tell you why you came</blockquote><blockquote>You want a Reason, Purpose, Goal, or Name</blockquote><blockquote><strong>A Rose blooms Red. It never felt the shame.</strong></blockquote><blockquote>Your Life needs no Permission. Bloom the same.</blockquote><blockquote>The Priests sell Keys, the Scholars sell the Map,</blockquote><blockquote>The Mosques and Schools compete to set the Trap</blockquote><blockquote><strong>I sat beneath a Tree and closed the gap</strong></blockquote><blockquote>And found what all their Words could never wrap.</blockquote><blockquote>I tried each Door the Prophets said was true,</blockquote><blockquote>And swallowed every Answer, old and new</blockquote><blockquote><strong>Each proved the other wrong; they overthrew.</strong></blockquote><blockquote>What’s left is Zero. Watch how Zero grew.</blockquote><blockquote>The Future is a Promise to a Ghost.</blockquote><blockquote>The Past, a Letter nobody can Post.</blockquote><blockquote><strong>Between them stands this Breath, which matters most.</strong></blockquote><blockquote>And in this Breath, Eternity plays Host.</blockquote><blockquote>You think your Skin divides you from the Stars,</blockquote><blockquote>That you’re a Captive peering through the Bars</blockquote><blockquote><strong>You ARE the Sky that nothing truly mars.</strong></blockquote><blockquote>There is no Prisoner, my Friend. No Scars.</blockquote><blockquote>If Roses never died, would Roses bloom?</blockquote><blockquote>If Dawn were permanent, would Dawn consume</blockquote><blockquote><strong>Your Heart with Beauty? No. What meets the Tomb</strong></blockquote><blockquote><strong>Is just the Thing that lights the darkened Room.</strong></blockquote><blockquote>Who plays the Game? I looked behind the Board</blockquote><blockquote>And found no Hand, no Player, no Reward</blockquote><blockquote><strong>No King, no Pawn, no Master, and no Lord.</strong></blockquote><blockquote>The Game, it seems, plays on of its Accord.</blockquote><blockquote>Don’t curse the Tongue for loving how things taste</blockquote><blockquote>The Mouth was built by what the Mouth has faced.</blockquote><blockquote><strong>When Bread dissolves, your startled Tongue has traced</strong></blockquote><blockquote>The Universe. it’s learning its own Taste.</blockquote><blockquote>What dies? The Cup. The Clay. The little Form.</blockquote><blockquote>The Name you carried daily, safe and warm.</blockquote><blockquote><strong>But Water doesn’t die; it will transform.</strong></blockquote><blockquote>It just resumes its Life before the Storm.</blockquote><blockquote>You’ve circled every Shrine on every Hill,</blockquote><blockquote>Read every Word the Saints have tried to spill</blockquote><blockquote><strong>Now stop. The Light you seek burns in you still.</strong></blockquote><blockquote><strong>Your Eye IS Light. Be still, my Friend. Be still.</strong></blockquote><blockquote>I searched for Ground beneath the Prophets’ Feet,</blockquote><blockquote>Down every Road the Faithful said was sweet</blockquote><blockquote><strong>The Bottom fell; there was no Floor to meet.</strong></blockquote><blockquote>Just Sky. And Sky, it turns out, was complete.</blockquote><blockquote>The Mystery remains. No God descends.</blockquote><blockquote>No Answer from the Sky the Silence sends.</blockquote><blockquote><strong>But here, your Hand in mine, this Bread that mends</strong></blockquote><blockquote>Is all I need. The Searching, Friend, here ends.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1202179da08a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing a Critical Bottleneck in PyTorch’s Distributed Checkpointing]]></title>
            <link>https://medium.com/@amin32846/fixing-a-critical-bottleneck-in-pytorchs-distributed-checkpointing-4de567985cf6?source=rss-5cb28ed91c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4de567985cf6</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Amin Sedaghat]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 00:48:15 GMT</pubDate>
            <atom:updated>2025-11-16T02:26:30.888Z</atom:updated>
            <content:encoded><![CDATA[<p>Picture this: You’re running a massive AI training job across hundreds of GPUs. Every hour, your system saves a checkpoint, a safety net worth thousands of dollars in compute time. But one day, that 5-second save balloons to 30 seconds. Then a minute. Your GPUs sit idle, burning money while a tiny validation function struggles through millions of comparisons.</p><p>This was happening to PyTorch users when distributed training hit hyperscale. After discovering this bottleneck, I contributed an optimization that reduced validation time from 33 seconds to 26 milliseconds for large-scale workloads. This article walks through the problem, the algorithmic solution, and the lessons learned from contributing <a href="https://github.com/pytorch/pytorch/pull/166820">PR #166820</a> to PyTorch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ONUW-KNsBZyrXLL6NtGO1g.png" /></figure><h3>The Hidden Monster in Your Code</h3><p>When you save a distributed model checkpoint in PyTorch, the system needs to verify that thousands of tensor chunks don’t overlap or corrupt each other. Think of it like a giant jigsaw puzzle, before saving, we check that no pieces overlap and everything fits perfectly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U6dIRW3nKovRXamp5XBeNQ.png" /></figure><p>The original validator had a seemingly reasonable approach:</p><pre># Actual structure of the old O(n²) approach<br>for chunk_idx, chunk0 in enumerate(value.chunks):<br>    # Check this chunk against EVERY subsequent chunk<br>    for chunk1 in value.chunks[chunk_idx + 1:]:<br>        if _check_box_overlap(chunk0, chunk1):<br>            logger.warning(f&quot;key:{key} has overlapping chunks: {chunk0} {chunk1}&quot;)</pre><p>This is a classic N-choose-2 problem: for n chunks, we perform n×(n-1)/2 comparisons. With 100 chunks? 4,950 comparisons, still fast. With 10,000 chunks? 49,995,000 comparisons. That’s when your validator becomes the bottleneck.</p><p>Here’s what actually happened at scale:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rRrCGzwIx2jFyorlAKNPA.png" /></figure><h3>The Sweep Line Algorithm: A Deep Dive</h3><p>Instead of checking every chunk against every other chunk, I implemented a sweep line algorithm, a classic computational geometry technique. Here’s how it works in detail:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Xa7ICuhL0IMyFvONsbV6A.png" /></figure><p><strong>Step 1: Choosing the Sweep Dimension</strong></p><p>First, we identify the optimal axis to sweep along:</p><pre># Pick the dimension with the largest range for maximum pruning<br>sweep_dim = max(range(dims), default=0, key=lambda d: tensor.size[d])</pre><p>Why? Chunks spread along a longer dimension are less likely to overlap, giving us more opportunities to prune the active set.</p><p><strong>Step 2: Multi-Key Sorting</strong></p><p>We sort chunks using a composite key to ensure deterministic ordering:</p><pre>sorted_indices = sorted(<br>    range(len(chunks)),<br>    key=lambda idx: (<br>        chunks[idx].offsets[sweep_dim],  # Primary: position on sweep axis<br>        *(chunks[idx].offsets[d] for d in range(dims)),  # Secondary: other dimensions<br>    ),<br>)</pre><p>This guarantees that chunks at the same position on the sweep axis are ordered consistently, preventing false negatives in overlap detection.</p><p><strong>Step 3: The Active Set with Binary Search</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sRtT6eZXXGRG-OlDB7J4OA.png" /></figure><p>The heart of the algorithm maintains an “active set” of chunks that could potentially overlap with the current chunk:</p><pre>active: list[tuple[int, int]] = []  # List of (end_position, chunk_index)<br><br>for idx in sorted_indices:<br>    current = chunks[idx]<br>    start = current.offsets[sweep_dim]<br>    end = start + current.sizes[sweep_dim]<br>    <br>    # Binary search to find expired chunks<br>    cutoff = bisect_right(active, (start, sys.maxsize))<br>    if cutoff:<br>        del active[:cutoff]  # O(k) where k is number of expired chunks<br>    <br>    # Check overlaps only with active chunks<br>    for _, other_idx in active:<br>        other = chunks[other_idx]<br>        if _check_box_overlap(current, other):<br>            # Log warning but continue validation<br>            logger.warning(f&quot;Overlap detected: {current} and {other}&quot;)<br>    <br>    # Insert current chunk maintaining sorted order<br>    insort(active, (end, idx))  # O(log n) binary insertion</pre><p><strong>Why This Works: The Complexity Analysis</strong></p><p>Let’s break down the time complexity:</p><ul><li><strong>Sorting</strong>: O(n log n) using Python’s Timsort</li><li><strong>For each chunk</strong>:</li></ul><p><strong>bisect_right</strong>: O(log m) where m is active set size</p><p><strong>Deletion</strong>: O(k) where k is chunks to remove</p><p><strong>Overlap checks</strong>: O(m × d) where d is tensor dimensions</p><p><strong>insort</strong>: O(log m) for binary insertion</p><p>In the worst case where all chunks overlap (m = n), we get O(n²). But in practice, chunks are distributed, so m &lt;&lt; n, giving us O(n log n) overall.</p><p><strong>The Multi-Dimensional Overlap Check</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*tqLreL5PMrj9PFc_B0j7Dg.png" /></figure><p>After filtering by the sweep dimension, we still need to verify overlap in all dimensions:</p><pre>def _check_box_overlap(box0: ChunkStorageMetadata, box1: ChunkStorageMetadata) -&gt; bool:<br>    # Check if boxes are disjoint in ANY dimension<br>    for i in range(len(box0.offsets)):<br>        if box0.offsets[i] &gt;= box1.offsets[i] + box1.sizes[i]:<br>            return False  # box0 is completely after box1 in dimension i<br>        if box1.offsets[i] &gt;= box0.offsets[i] + box0.sizes[i]:<br>            return False  # box1 is completely after box0 in dimension i<br>    return True  # Boxes overlap in all dimensions</pre><p>This is the separating axis theorem in action, two boxes don’t overlap if we can find any dimension where they’re completely separated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yHaj-dWWsxJ-FsA2QYsJMg.png" /></figure><h3>The Implementation: Making It Real</h3><p>Contributing this fix to PyTorch <a href="https://github.com/pytorch/pytorch/pull/166820">PR #166820</a> required careful engineering:</p><p><strong>Challenge 1: Edge Cases in Real Workloads</strong></p><p>The algorithm needed to handle several edge cases gracefully:</p><p><strong>Empty or Single Chunks</strong>: Skip the expensive sort entirely</p><pre>if len(chunks) &lt;= 1:<br>    return  # No overlaps possible</pre><p><strong>Degenerate Dimensions</strong>: Some tensors have size-1 dimensions</p><pre># Use sys.maxsize as sentinel for bisect_right to work correctly<br>cutoff = bisect_right(active, (start, sys.maxsize))</pre><p><strong>Volume Validation</strong>: Besides overlaps, we verify chunks cover the entire tensor</p><pre>chunks_volume = sum(math.prod(chunk.sizes) for chunk in chunks)<br>tensor_volume = math.prod(tensor.size)<br>if chunks_volume != tensor_volume:<br>    logger.warning(f&quot;Incomplete coverage: {chunks_volume}/{tensor_volume}&quot;)</pre><p><strong>Challenge 2: Python’s bisect Module Nuances</strong></p><p>The<em> </em><strong>bisect</strong> module is powerful but has subtle behaviors:</p><pre># Why (start, sys.maxsize) instead of just start?<br>cutoff = bisect_right(active, (start, sys.maxsize))</pre><p>The active set stores tuples of (<strong>end_position, chunk_index</strong>). When searching for chunks that end before <strong>start</strong>, we need to find the rightmost position where <strong>end_position &lt; start</strong>. Using <strong>sys.maxsize</strong> as the second element ensures we get all chunks with <strong>end_position &lt;= start</strong>, not just those with <strong>end_position &lt; start</strong>.</p><p><strong>Challenge 3: Maintaining Correctness Under Optimization</strong></p><p>The original validator was simple but correct. My version needed to:</p><ol><li><strong>Preserve all warnings</strong>: Same format, same information</li></ol><p>2. <strong>Handle all tensor layouts</strong>: Row-major, column-major, strided</p><p>3. <strong>Stay deterministic</strong>: Same input must produce same output (hence the multi-key sort)</p><h3>The Results: From Minutes to Milliseconds</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qEhm3Bp3qHKsrm5os3SKQ.png" /></figure><h3>Why This Matters (Beyond the Numbers)</h3><p><strong>For ML Engineers</strong></p><p>Your checkpoints now save without blocking training. That means more frequent saves, better fault tolerance, and less anxiety about losing work.</p><p><strong>For Infrastructure Teams</strong></p><p>The coordinator node (rank 0) no longer becomes a CPU/memory bottleneck. You can scale to more ranks without worrying about validation overhead.</p><p><strong>For the Bottom Line</strong></p><p>If a large training run checkpoints every hour and validation took 30 seconds, that’s 12 minutes of idle GPU time per day. Across a cluster, that’s thousands of dollars saved.</p><h3>The Takeaway</h3><p>Next time your system slows down, don’t just throw more hardware at it. Look for the hidden O(n²) loops, the forgotten validators, the “quick” checks that aren’t quick anymore. You might just find your own 1,250× speedup waiting. And when you do, contribute it upstream.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4de567985cf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock Warp‑Level Performance: DeepSeek’s Practical Techniques for Specialized GPU Tasks]]></title>
            <link>https://medium.com/@amin32846/unlock-warp-level-performance-deepseeks-practical-techniques-for-specialized-gpu-tasks-a6cf0c68a178?source=rss-5cb28ed91c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6cf0c68a178</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[deepseek]]></category>
            <category><![CDATA[cuda]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[gpu]]></category>
            <dc:creator><![CDATA[Amin Sedaghat]]></dc:creator>
            <pubDate>Sat, 01 Feb 2025 16:17:29 GMT</pubDate>
            <atom:updated>2025-02-07T14:12:19.790Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O7KVTlDhXZaP3noAZn6CJw.png" /></figure><h3>Introduction</h3><p>Amid the push toward trillion‐parameter models, the DeepSeek team has showcased astonishing engineering feats — like partitioning Streaming Multiprocessors (SMs) into specialized warp‐level communication tasks, weaving in lower‐level PTX instructions, and auto‐tuning “communication chunks” for concurrency.</p><p>Their approach elegantly circumvents conventional limitations. In fact, DeepSeek achieves a level of warp specialization that NVIDIA itself hasn’t fully tackled. Orchestrating InfiniBand (IB) ↔ NVLink communication pipelines at warp granularity, minimizing overhead and pushing performance even further.</p><p>Reflecting this focus on warp‐level allocations, the DeepSeek paper notes:</p><blockquote>[W]e employ the warp specialization technique (Bauer et al., 2014) and partition 20 SMs into 10 communication channels… In addition, both dispatching and combining kernels overlap with the computation stream, so we also consider their impact on other SM computation kernels. Specifically, we employ customized PTX (Parallel Thread Execution) instructions and auto-tune the communication chunk size, which significantly reduces the use of the L2 cache and the interference to other SMs.</blockquote><p>We’ll begin with a simple 4×4 tile transpose, demonstrating how warp shuffle intrinsics can remove unneeded block‐wide synchronization. Then we’ll grow that idea into advanced warp‐level partitioning for real‐world tasks like all‐to‐all communication in multi‐node MoE workloads. Even if your own applications aren’t at DeepSeek’s hyper‐scale, you’ll still find these warp‐specialization ideas invaluable for high‐performance GPU work.</p><h3>1. The Challenge: Rearranging Data at Warp Scope</h3><p>Sometimes, you only need 32 threads (or even fewer) to rearrange data. Yet the default CUDA approach forces an entire block to synchronize (via <strong>__syncthreads()</strong>), which can stall many threads that aren’t involved.</p><p>DeepSeek’s large‐scale multi‐node MoE training pipeline demonstrates how such optimizations compound. Individual warps might handle IB sends, NVLink receives, or matrix‐multiplication tasks — enabling partial concurrency and better GPU utilization. By working at the warp scope, DeepSeek avoids the bottlenecks of block‐wide synchronization.</p><p>Here’s a simple diagram illustrating the difference between full block sync vs. focusing only on warp‐level coordination:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGnC77FyqUA2kZshxSYYyA.png" /><figcaption>Block-wide Synchronization vs Warp-level Communication</figcaption></figure><h3>2. A Naive 4×4 Transpose (Block-Level Sync)</h3><p>Below is a minimal kernel that uses shared memory and `<strong>__syncthreads()</strong>` to transpose a 4×4 chunk, causing an entire block to wait even though only 16 threads are actually active:</p><pre>// Naive 4×4 Transpose (Block-Level Sync)<br>__global__ void transpose_naive(float* output, const float* input)<br>{<br>    __shared__ float tile[16];  // 4×4 tile<br>    int tid = threadIdx.x;<br><br>    // Only first 16 threads do the transfer<br>    if (tid &lt; 16)<br>    {<br>        tile[tid] = input[tid];<br>    }<br>    __syncthreads();  // Block-wide barrier<br><br>    if (tid &lt; 16)<br>    {<br>        int row = tid / 4;<br>        int col = tid % 4;<br>        int transposedId = col * 4 + row;<br>        output[transposedId] = tile[tid];<br>    }<br>}</pre><p>Explanation:</p><ul><li><strong>tile[]</strong> in shared memory holds the 4×4 chunk.</li><li><strong>__syncthreads()</strong> ensures writes to <strong>tile[]</strong> are visible to all threads before any reads occur.</li><li>This approach is simple but stalls the entire block, even though only 16 threads need the data.</li></ul><h3>3. Warp-Level Optimization with Shuffle Intrinsics</h3><p>Now let’s refine the approach: if data exchange is restricted to a single warp, we can avoid shared memory altogether by using warp shuffle intrinsics (<strong>__shfl_sync</strong>, etc.). This drastically cuts latency and removes block‐wide synchronization, key enablers in DeepSeek’s method of assigning different communication tasks to separate warps.</p><p>Below is the warp shuffle version. Notice that we only use half a warp (16 threads), so we manage “inactive” lanes with <strong>__activemask()</strong>.</p><pre>///////////////////////////////////////////////////////////////////////  <br>// Warp-Level 4×4 Transpose with __shfl_sync (Partial Warp Example)  <br>///////////////////////////////////////////////////////////////////////<br>__global__ void transpose_warp_shfl(float* output, const float* input)<br>{<br>    int tid = threadIdx.x;<br>    // Contains the set of lanes actually active in the warp<br>    unsigned int mask = __activemask();<br><br>    if (tid &lt; 16)<br>    {<br>        float val = input[tid];<br>        int row = tid / 4;<br>        int col = tid % 4;<br>        // Identify which lane originally held the transposed element<br>        int srcTid = col * 4 + row;<br><br>        // Use the valid lane mask to avoid undefined data from inactive lanes<br>        float transposedVal = __shfl_sync(mask, val, srcTid, 32);<br><br>        output[tid] = transposedVal;<br>    }<br>}</pre><p>Explanation:</p><ul><li>Each active lane fetches transposed data via <strong>__shfl_sync</strong>.</li><li>Shared memory and <strong>__syncthreads()</strong> are no longer necessary.</li><li>If fewer than 32 lanes are in use, <strong>__activemask()</strong> helps avoid unwanted reads/writes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x-RCP2KtXjKXO30DGNLUGA.png" /></figure><h3>4. PTX and Warp Specialization: The Broader Context</h3><p>DeepSeek’s large‐scale approach extends this same strategy beyond small tiles. Specialized warps handle IB sending, NVLink forwarding, or MoE gating without major stalls. This is done by carefully constructing kernels (and sometimes diving into PTX) to:</p><ul><li>Assign warp roles (e.g., one warp handles IB tasks, another handles NVLink).</li><li>Overlap communication and compute by scheduling these tasks on separate warps within the same block or across multiple SMs.</li><li>Dynamically adjust the number of warps used for different tasks, based on real‐time workload.</li></ul><p>NVIDIA doesn’t provide a direct “pin warp to IB/NVLink” feature, yet DeepSeek’s team discovered and fine‐tuned these warp partitions manually. They also demonstrated that with customized PTX, they could push concurrency and reduce L2 traffic to levels not typically seen in standard CUDA pipelines.</p><h3>5. Practical Pitfalls in Real Scenarios</h3><p>If you only use part of a warp (say 16 out of 32 lanes), it’s crucial to manage all remaining “inactive” lanes properly. Otherwise, unintended reads or writes could occur. The CUDA intrinsic <strong>__activemask()</strong> helps you safely identify which lanes are active, ensuring data exchange remains correct. Meanwhile, if your data requirements exceed a single warp’s scope, you can’t rely on warp shuffle intrinsics alone. Larger tiles or computations typically call for shared memory, block‐level synchronization, or more intricate multi‐warp patterns.</p><p>Another important detail is memory visibility. Even though you’ve sidestepped block‐wide synchronization in warp‐only tasks, once another warp (or block) needs to read or write partial results, the proper fences and synchronization come back into the picture. Within‐warp data remains invisible to the wider block or grid unless you employ standard barriers.</p><p>Finally, specialized warps might coordinate both IB/NVLink traffic and local computation in theory, but making this overlap work in practice requires careful tuning and real‐world profiling. You’ll likely need to refine kernel launches, stream priorities, and chunk sizes, among other parameters.</p><h3>6. When (and When Not) To Use Inline PTX</h3><p>Even though <strong>__shfl_sync</strong> compiles into efficient instructions, sometimes you need super‐fine control , like specifying certain registers or caching modes that the compiler doesn’t expose. That’s where inline PTX steps in. But it’s a double‐edged sword:</p><ul><li>PTX is not final machine code and future GPUs might interpret it differently.</li><li>You must manage registers, predicates, and memory references carefully.</li><li>Minor changes in your C++/CUDA code or compiler can break delicate PTX.</li></ul><p>Inline PTX should be your last resort. Nevertheless, DeepSeek’s customized instructions highlight how effective it can be. They overcame cross‐node communication bottlenecks by reducing L2 usage and carefully scheduling instructions at warp granularity, going far beyond what the default CUDA runtime typically offers.</p><h3>7. Key Takeaways</h3><p>When your operation fits within the confines of a single warp, shuffle intrinsics are your best friend, eliminating the need for block‐wide barriers and extra memory transfers. Just remember that partial warps demand careful handling: inactive lanes can wreak havoc if they’re not properly managed. With the help of <strong>__activemask()</strong>, you can safeguard your data against unintended reads or writes, ensuring your intra‐warp tasks stay predictable.</p><p>As you scale up toward multi‐warp processes, shared memory and block‐level sync steps inevitably rejoin the picture. This doesn’t mean you should fear them; rather, treat them as useful tools within more intricate concurrency patterns. Borrowing a page from DeepSeek’s playbook, you can dedicate entire warps to IB or NVLink communication and let other warps handle compute, resulting in better resource utilization and near‐continuous workstreams when concurrency is tuned correctly.</p><p>Lastly, if even the most aggressive compiler flags and CUDA intrinsics can’t hit your performance target, inline PTX stands as your final frontier. It grants you unrivaled control over registers, caching, and instruction scheduling, albeit at the cost of greater development complexity and maintenance. Just as DeepSeek did, tread carefully in this realm: successes here can be monumental, but so too can the engineering overhead.</p><h3>Conclusion</h3><p>DeepSeek’s mastery of warp‐level transposition, communication overlap, and custom PTX optimizations proves that GPUs are more malleable than most developers including myself realize. By restricting data exchange to the warp and dynamically allocating warp roles for communication or compute, the DeepSeek team achieves concurrency levels that standard tools seldom provide.</p><p>While everyone’s chasing the latest GPU that costs more than a brand new car, some crafty engineers at DeepSeek were like “Hold my coffee (or most likely tea)” and achieved what NVIDIA themselves hadn’t tackled yet. Sometimes all it takes is being clever with the threads you’ve got.</p><p><strong>References:</strong></p><p><a href="https://github.com/deepseek-ai/DeepSeek-V3/blob/main/DeepSeek_V3.pdf">https://github.com/deepseek-ai/DeepSeek-V3/blob/main/DeepSeek_V3.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6cf0c68a178" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swarm Intelligence Showdown: A Benchmarking Study]]></title>
            <link>https://medium.com/@amin32846/swarm-intelligence-showdown-a-benchmarking-study-a94cc2ca598c?source=rss-5cb28ed91c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a94cc2ca598c</guid>
            <category><![CDATA[swarm-intelligence]]></category>
            <category><![CDATA[openmp]]></category>
            <category><![CDATA[cuda]]></category>
            <category><![CDATA[aritificial-intelligence]]></category>
            <category><![CDATA[high-performace-computing]]></category>
            <dc:creator><![CDATA[Amin Sedaghat]]></dc:creator>
            <pubDate>Fri, 05 Jul 2024 20:10:22 GMT</pubDate>
            <atom:updated>2026-08-03T13:56:29.524Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mgycB8rohOTwRy5bN-wiMA.jpeg" /></figure><h3>Introduction: Nature’s Algorithms in the Digital Arena</h3><p>In an era of rapid advancements in distributed computing and artificial intelligence, swarm intelligence algorithms have emerged as increasingly attractive methods for finding optimal solutions in vast, complex landscapes. From machine learning to supply chain optimization, these nature-inspired techniques offer powerful tools for tackling today’s most challenging computational problems.</p><p>The natural world abounds with examples of collective intelligence: flocks of birds navigating vast distances, ant colonies efficiently foraging for food, and schools of fish evading predators. These phenomena have inspired a class of optimization techniques known as swarm intelligence algorithms. But in the realm of computer science, which of these nature-inspired algorithms reigns supreme?</p><p>This study evaluates ten popular swarm intelligence algorithms across a suite of challenging benchmark functions, implemented on four distinct platforms ranging from simple C++ to cutting-edge GPU computing. The goal of this study is to provide an analysis of their performance, strengths, and weaknesses in various computational environments.</p><h3>The Contenders and the Battleground</h3><p><strong>Algorithm Contenders</strong></p><p>Our ten swarm intelligence contenders, each with its unique strategy:</p><ol><li>Particle Swarm Optimization (PSO)</li><li>Firefly Algorithm (FA)</li><li>Moth-Flame Optimization (MFO) Algorithm</li><li>Grey Wolf Optimizer (GWO)</li><li>Whale Optimization Algorithm (WOA)</li><li>Artificial Bee Colony (ABC) Algorithm</li><li>Dragonfly Algorithm (DA)</li><li>Salp Swarm Algorithm (SSA)</li><li>Grasshopper Optimization Algorithm (GOA)</li><li>Ant Colony Optimization (ACO)</li></ol><p>It’s worth noting that while some algorithms, such as Ant Colony Optimization, are primarily designed for specific problem types like the Traveling Salesman Problem (TSP), they can be adapted to solve continuous optimization problems as represented by our benchmark functions.</p><p><strong>The Battleground: Benchmark Functions</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eaminsed%2F3.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fplotly.com%2F%7Eaminsed%2F3%2F&amp;image=https%3A%2F%2Fplotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/12a04887d00181433b0071f3f9278b97/href">https://medium.com/media/12a04887d00181433b0071f3f9278b97/href</a></iframe><p>These functions were chosen for their diverse characteristics, providing a comprehensive test of each algorithm’s capabilities across different problem types.</p><p><strong>The Arenas: Implementation Platforms</strong></p><p>Each algorithm was implemented and tested on four distinct platforms:</p><p>1. <strong>Pure C++</strong>: The classic single-threaded implementation<br>2. <strong>OpenMP</strong>: Harnessing the power of CPU multi-threading<br>3. <strong>CUDA</strong>: Unleashing the parallel prowess of GPUs<br>4. <strong>Thrust</strong>: High-level GPU programming with NVIDIA’s C++ template library</p><p>This multi-platform approach allows us to evaluate how different computing architectures impact the performance of swarm intelligence algorithms.</p><h3>Experimental Parameters and Considerations</h3><p>All algorithms used the same population size (1,000) and iteration count (1,000) on every platform. Note that identical iteration counts do not equalize computational budgets across algorithms: FA performs O(N²) pairwise attractiveness updates per iteration while PSO and GWO perform O(N) work, and ABC evaluates roughly two candidates per food source per cycle. Cross-algorithm runtime comparisons should be read with that in mind. The platform speed-ups, however, remain apples-to-apples, since each implementation is compared against its own single-threaded C++ baseline, I maintained the following consistent experimental parameters throughout the study:<br>- Population size: 1000<br>- Number of iterations: 1000</p><p>These parameters were applied uniformly across all algorithms and benchmark functions. It’s important to note that while these settings allowed for direct comparisons, they may have led to underutilization of GPU resources in some cases. GPUs are capable of handling much larger population sizes efficiently, which could potentially yield even more significant performance gains for GPU-implemented algorithms.</p><p>However, maintaining identical parameters across all platforms was crucial for ensuring fairness in our comparisons. This approach allowed the isolation of the impact of the algorithms themselves and the computing platforms, rather than introducing variations due to differing population sizes or iteration counts.</p><h3>Results and Analysis</h3><p><strong>Performance Across Platforms</strong></p><p>Benchmarking revealed compelling insights into the influence of different computing platforms on algorithm performance.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eaminsed%2F5.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fplotly.com%2F%7Eaminsed%2F5%2F&amp;image=https%3A%2F%2Fplotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/21bdc744779b87193b85be2f134e428a/href">https://medium.com/media/21bdc744779b87193b85be2f134e428a/href</a></iframe><p>As evident from the chart, GPU implementations (CUDA and Thrust) generally offered significant speedups, with some algorithms seeing major performance boosts compared to their CPU counterparts. However, the benefits were not uniform across all algorithms, highlighting the importance of algorithm structure in parallel implementations.</p><p><strong>Convergence and Solution Quality</strong></p><p>The ability to find high-quality solutions efficiently is crucial for any optimization algorithm. Our results show significant variations in convergence speed and solution quality across the different algorithms.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eaminsed%2F1.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fplotly.com%2F%7Eaminsed%2F1%2F&amp;image=https%3A%2F%2Fplotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/543f2a7e600164a3afb0f70af57e94c7/href">https://medium.com/media/543f2a7e600164a3afb0f70af57e94c7/href</a></iframe><p>This chart illustrates the number of iterations required for each algorithm to converge on an optimal solution, providing insights into their efficiency and effectiveness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGMcwF4QtphXoLWgUjBwYw.png" /></figure><p>The heatmap above showcases the solution quality achieved by each algorithm across all four benchmark functions after 1000 iterations. This visualization helps identify which algorithms consistently perform well across different problem types.</p><h3><strong>Spotlight on Top Performers</strong></h3><p><strong>Particle Swarm Optimization (PSO): The All-Rounder</strong></p><p>PSO emerged as a standout performer, excelling in speed, solution quality, and convergence rate. Its success can be attributed to a well-balanced approach that combines individual and collective intelligence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rYNyHWZZ2Gl-q9vI8R4QpA.png" /><figcaption>Particle Swarm Optimization (PSO) Nsignt Profiling Result</figcaption></figure><p>The Nsight profiling results for PSO’s CUDA implementation reveal its efficiency on GPU hardware. The `updateParticles` kernel dominates execution time, but completes rapidly, allowing for fast iterations and overall performance.</p><p><strong>Artificial Bee Colony (ABC): The Precision Expert</strong></p><p>ABC demonstrated exceptional solution quality across various benchmark functions. Its three-pronged approach — employed bees, onlooker bees, and scouts — creates a robust search strategy that effectively balances exploration and exploitation.</p><p><strong>Grey Wolf Optimizer (GWO): The Fast Learner</strong></p><p>GWO showcased impressive convergence speeds, thanks to its hierarchical structure mimicking wolf pack dynamics. The algorithm’s ability to balance exploration and exploitation led to swift and accurate results.</p><h3>Challenges and Opportunities</h3><p>While many algorithms benefited from GPU acceleration, some, like Moth-Flame Optimization (MFO) and Firefly Algorithm (FA), struggled on parallel hardware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIGaBRbKJpVPEmlmxdns0Q.png" /><figcaption>Moth-Flame Optimization (MFO) Nsignt Profiling Result</figcaption></figure><p>The Nsight profiling results for MFO reveal a critical bottleneck in sorting operations, The Nsight profile for MFO reveals a critical bottleneck in its per-iteration sorting step. GPU-parallel sorts exist Thrust’s radix sort among them but MFO must re-sort the entire population every iteration to rebuild its flame hierarchy. That sort acts as a global synchronization point between kernels, and at a population of 1,000 the array is far too small to amortize the sort’s launch and memory overhead, so the pipeline stalls rather than streams. Algorithms whose update step depends on globally ordered state pay this structural penalty on parallel hardware regardless of how fast the sort itself is.. This highlights the importance of considering algorithm structure when implementing swarm intelligence techniques on parallel hardware, as sorting operations can add significant overhead.</p><h3>Conclusion: Navigating the Swarm Intelligence Landscape</h3><p>This study demonstrates that the realm of swarm intelligence is diverse, complex, and brimming with potential. From digital whales to artificial bees, these nature-inspired algorithms offer powerful tools for tackling today’s most challenging optimization problems. However, our findings underscore a crucial point: T<strong>here is no one-size-fits-all solution in the realm of swarm intelligence.</strong></p><p>The choice of algorithm should depend on several key factors:</p><ol><li><strong>Specific problem characteristics</strong></li><li><strong>Available computational resources</strong></li><li><strong>Performance requirements</strong> (speed, accuracy, or a balance of both)</li></ol><p>Moreover, the selection of hardware plays a pivotal role in algorithm performance. The results clearly show that some algorithms excel in multi-core CPU environments, while others truly shine when leveraging the massive parallelism of GPUs. This hardware-algorithm interplay is a critical consideration for practitioners seeking to optimize their computational resources.</p><p>While this study provides insights into ten popular algorithms, there are newer swarm-inspired techniques emerging that warrant further investigation. For those interested in reproducing our experiments or delving deeper into the results, I encourage you to visit my<strong> </strong><a href="https://github.com/Aminsed/SwarmBenchmark"><strong>GitHub repository</strong></a><strong>.</strong></p><p>Furthermore, I invite you to contribute to this ongoing research. If you believe there’s a swarm intelligence algorithm that could outperform those in the study, I welcome your suggestions and contributions. By collaboratively expanding this repository of knowledge, we can continue to push the boundaries of what’s possible with swarm intelligence.</p><p>As computational challenges grow in complexity and scale, the importance of efficient optimization techniques cannot be overstated. Swarm intelligence algorithms, with their ability to tackle complex, high-dimensional problems, will undoubtedly play a crucial role in shaping the future of computational problem-solving.</p><h3>References</h3><p>1. Kennedy, J., &amp; Eberhart, R. (1995). Particle Swarm Optimization. Proceedings of ICNN’95 — International Conference on Neural Networks, 4, 1942–1948. (<a href="https://ieeexplore.ieee.org/document/488968">https://ieeexplore.ieee.org/document/488968</a>)</p><p>2. Dorigo, M., &amp; Gambardella, L. M. (1997). Ant Colony System: A Cooperative Learning Approach to the Traveling Salesman Problem. IEEE Transactions on Evolutionary Computation, 1(1), 53–66. (<a href="https://ieeexplore.ieee.org/document/585892">https://ieeexplore.ieee.org/document/585892</a>)</p><p>3. Mirjalili, S. (2015). Moth-flame optimization algorithm: A novel nature-inspired heuristic paradigm. Knowledge-Based Systems, 89, 228–249. (<a href="https://www.sciencedirect.com/science/article/abs/pii/S0950705115002580">https://www.sciencedirect.com/science/article/abs/pii/S0950705115002580</a>)</p><p>4. Mirjalili, S., Mirjalili, S. M., &amp; Lewis, A. (2014). Grey Wolf Optimizer. Advances in Engineering Software, 69, 46–61. (<a href="https://www.sciencedirect.com/science/article/abs/pii/S0965997813001853">https://www.sciencedirect.com/science/article/abs/pii/S0965997813001853</a>)</p><p>5. Mirjalili, S., &amp; Lewis, A. (2016). The Whale Optimization Algorithm. Advances in Engineering Software, 95, 51–67. (<a href="https://www.sciencedirect.com/science/article/abs/pii/S0965997816300163">https://www.sciencedirect.com/science/article/abs/pii/S0965997816300163</a>)</p><p>6. Karaboga, D., &amp; Basturk, B. (2007). A powerful and efficient algorithm for numerical function optimization: artificial bee colony (ABC) algorithm. Journal of Global Optimization, 39(3), 459–471.(<a href="https://www.researchgate.net/publication/221498082_Artificial_Bee_Colony_ABC_Optimization_Algorithm_for_Solving_Constrained_Optimization_Problems">https://www.researchgate.net/publication/221498082_Artificial_Bee_Colony_ABC_Optimization_Algorithm_for_Solving_Constrained_Optimization_Problems</a>)</p><p>7. Mirjalili, S. (2016). Dragonfly algorithm: a new meta-heuristic optimization technique for solving single-objective, discrete, and multi-objective problems. Neural Computing and Applications, 27(4), 1053–1073. (<a href="http://fa.mie.sut.ac.ir/Downloads/AcademicStaff/5/Courses/17/Dragonfly%20algorithm%202016.pdf">http://fa.mie.sut.ac.ir/Downloads/AcademicStaff/5/Courses/17/Dragonfly%20algorithm%202016.pdf</a>)</p><p>8. Mirjalili, S., &amp; Lewis, A. (2016). The Salp Swarm Algorithm. Advances in Engineering Software, 99, 84–100.(<a href="https://www.sciencedirect.com/science/article/abs/pii/S0965997816307736">https://www.sciencedirect.com/science/article/abs/pii/S0965997816307736</a>)</p><p>9. Saremi, S., Mirjalili, S., &amp; Lewis, A. (2017). Grasshopper Optimization Algorithm: Theory and application. Advances in Engineering Software, 105, 30–47.(<a href="https://www.sciencedirect.com/science/article/abs/pii/S0965997816305646">https://www.sciencedirect.com/science/article/abs/pii/S0965997816305646</a>)</p><p>10. Yang, X. S. (2010). Firefly Algorithm, Stochastic Test Functions and Design Optimization. International Journal of Bio-Inspired Computation, 2(2), 78–84.(<a href="https://arxiv.org/abs/1003.1466">https://arxiv.org/abs/1003.1466</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a94cc2ca598c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>