SShortSingh.
Back to feed

Dev fixes O(N²) bug in DeepMind's mctx library, cutting MCTS overhead 3x

0
·1 views

A developer training an AlphaZero-style AI agent for the game Factorio discovered that DeepMind's open-source mctx library was performing superlinearly during Monte Carlo Tree Search, with costs growing roughly five-fold when simulation count was merely doubled. Profiling revealed that XLA's GPU compiler was generating full copies of two large tree-state buffers — children_values and children_visits — on every iteration of the backward pass loop, because it could not safely prove in-place aliasing was valid. At 64 simulations, this produced around 345 MB of repeated buffer copies per move, causing per-simulation costs to double with each doubling of the simulation budget, a classic O(N²) pattern. The developer traced the root cause to a roughly 80-line function in mctx's tree-update logic and submitted a fix via pull request #116, rewriting the function to eliminate the redundant copies while producing bitwise-identical search results. The patch restored near-linear scaling and improved training throughput significantly without any change to search behavior.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

LiteLLM disaster recovery requires database, config, and decryption key together

LiteLLM, an AI gateway proxy, is not stateless in team deployments — its PostgreSQL database stores virtual keys, user and team records, budgets, rate limits, and spend history. A full recovery requires three components restored together: the PostgreSQL database, the gateway configuration file, and the decryption key used to protect stored credentials. Restoring only the container or only the database is insufficient to return the system to a working state. The decryption key should be stored separately from the database backup to avoid keeping encrypted data and its key in the same location. Operators are advised to rehearse restores on throwaway instances and treat a never-tested backup as unverified.

0
ProgrammingHacker News ·

OpenNode Offers Bitcoin Payment Processing for Businesses

OpenNode is a Bitcoin payment processor designed to help businesses accept cryptocurrency transactions. The platform provides tools that enable merchants and developers to integrate Bitcoin payments into their services. It was shared on Hacker News, where it received 18 points and one comment. The service aims to simplify Bitcoin payment infrastructure for companies looking to adopt crypto-based transactions. No specific launch date or company details were provided in the submission.

0
ProgrammingDEV Community ·

Five Structured Output Patterns That Make AI Coding Agents More Reliable

A developer running a fully autonomous coding agent found that parsing AI responses with regex and string matching led to repeated failures in unattended production runs. Ambiguous phrasing, markdown formatting, and mid-answer reasoning changes caused the same parser logic to misread opposite outcomes. The fix was switching from free-form prose responses to schema-validated structured output using forced tool calls via the Anthropic API. Instead of asking the model to describe its decision, the approach forces it to populate a predefined JSON contract, eliminating format ambiguity entirely. The author outlines five specific patterns using Claude's tool-use feature that transformed the agent from unreliable to trustworthy in production.

Dev fixes O(N²) bug in DeepMind's mctx library, cutting MCTS overhead 3x · ShortSingh