<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Architecture on Pathsolver</title><link>https://vlzm.github.io/pathsolver/docs/architecture/</link><description>Recent content in Architecture on Pathsolver</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://vlzm.github.io/pathsolver/docs/architecture/index.xml" rel="self" type="application/rss+xml"/><item><title>Pipeline</title><link>https://vlzm.github.io/pathsolver/docs/architecture/pipeline/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/pathsolver/docs/architecture/pipeline/</guid><description>&lt;h1 id="pipeline"&gt;Pipeline&lt;a class="anchor" href="#pipeline"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The five stages, in the order data flows through them.&lt;/p&gt;
&lt;h2 id="1-puzzle-definition"&gt;1. Puzzle definition&lt;a class="anchor" href="#1-puzzle-definition"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A puzzle is three files, no code:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;File&lt;/th&gt;
					&lt;th&gt;Content&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;generators/pXXX.json&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;{&amp;quot;actions&amp;quot;: [[...], ...], &amp;quot;names&amp;quot;: [&amp;quot;R&amp;quot;, &amp;quot;R'&amp;quot;, ...]}&lt;/code&gt; — one permutation per legal move&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;targets/*.pt&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;1-D &lt;code&gt;torch&lt;/code&gt; tensor: the solved state \( V_0 \)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;datasets/pXXX-tXXX-{rnd,santa}.pt&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;2-D tensor, one scramble per row&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Details and naming rules in
&lt;a href="https://vlzm.github.io/pathsolver/docs/architecture/data-contract/"&gt;Data contract&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="2-data-generation-on-the-fly"&gt;2. Data generation (on the fly)&lt;a class="anchor" href="#2-data-generation-on-the-fly"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There is no dataset-building step for training — &lt;code&gt;Trainer.generate_random_walks&lt;/code&gt;
produces training data inside the training loop, on the GPU. Per epoch it launches
&lt;code&gt;walkers_num = 1_000_000 // K_max&lt;/code&gt; walkers for each length
\( K \in [K_{\min}, K_{\max}] \), so an epoch is ~10⁶ labelled states regardless of
puzzle. Walks avoid immediately undoing the previous move
(&lt;code&gt;inverse_moves&lt;/code&gt;, built by &lt;code&gt;generate_inverse_moves&lt;/code&gt; from the generator names).&lt;/p&gt;</description></item><item><title>The pathsolver package</title><link>https://vlzm.github.io/pathsolver/docs/architecture/pathsolver/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/pathsolver/docs/architecture/pathsolver/</guid><description>&lt;h1 id="the-pathsolver-package"&gt;The &lt;code&gt;pathsolver&lt;/code&gt; package&lt;a class="anchor" href="#the-pathsolver-package"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;About a thousand lines total. Five modules, no inheritance hierarchies, no config
framework — each file does one thing.&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Module&lt;/th&gt;
					&lt;th style="text-align: right"&gt;Lines&lt;/th&gt;
					&lt;th&gt;Responsibility&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;model.py&lt;/code&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;116&lt;/td&gt;
					&lt;td&gt;The &lt;code&gt;PathSolver&lt;/code&gt; network and batched inference helpers&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;trainer.py&lt;/code&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;184&lt;/td&gt;
					&lt;td&gt;Random-walk generation, training loop, checkpointing&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;searcher.py&lt;/code&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;143&lt;/td&gt;
					&lt;td&gt;Batched GPU beam search&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;dqn.py&lt;/code&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;44&lt;/td&gt;
					&lt;td&gt;Bellman (Modified DQN) target refinement&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;utils.py&lt;/code&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;54&lt;/td&gt;
					&lt;td&gt;Puzzle loading, inverse moves, neighbours, hashing&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="modelpy--the-network"&gt;&lt;code&gt;model.py&lt;/code&gt; — the network&lt;a class="anchor" href="#modelpy--the-network"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;PathSolver(state_size, hd1=5000, hd2=1000, nrd=2, output_dim=1, dropout_rate=0.0, num_classes=6)&lt;/code&gt;
is a plain MLP with residual blocks:&lt;/p&gt;</description></item><item><title>Data contract</title><link>https://vlzm.github.io/pathsolver/docs/architecture/data-contract/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/pathsolver/docs/architecture/data-contract/</guid><description>&lt;h1 id="data-contract"&gt;Data contract&lt;a class="anchor" href="#data-contract"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;A puzzle is defined entirely by files. Nothing about it lives in code, so if your
files satisfy the conventions below, &lt;code&gt;train.py&lt;/code&gt; and &lt;code&gt;test.py&lt;/code&gt; work unchanged. This is
the contract to preserve when &lt;a href="https://vlzm.github.io/pathsolver/docs/usage/new-puzzles/"&gt;adding a new puzzle&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="identifiers"&gt;Identifiers&lt;a class="anchor" href="#identifiers"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Two integers identify every artefact:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;group_id&lt;/code&gt;&lt;/strong&gt; — the puzzle (its generating set). Formatted as three digits &lt;code&gt;pXXX&lt;/code&gt;
in filenames: &lt;code&gt;--group_id 54&lt;/code&gt; → &lt;code&gt;p054&lt;/code&gt;. The full table is in
&lt;a href="https://vlzm.github.io/pathsolver/docs/reference/groups/"&gt;Reference → Groups&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;target_id&lt;/code&gt;&lt;/strong&gt; — which solved state to aim for, formatted &lt;code&gt;tXXX&lt;/code&gt;. Almost always
&lt;code&gt;0&lt;/code&gt;; it exists because a graph can have several meaningful targets.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="generatorspxxxjson--the-moves"&gt;&lt;code&gt;generators/pXXX.json&lt;/code&gt; — the moves&lt;a class="anchor" href="#generatorspxxxjson--the-moves"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;actions&amp;#34;&lt;/span&gt;: [[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, &lt;span style="color:#960050;background-color:#1e0010"&gt;...&lt;/span&gt;], [&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#960050;background-color:#1e0010"&gt;...&lt;/span&gt;]],
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;names&amp;#34;&lt;/span&gt;: [&lt;span style="color:#e6db74"&gt;&amp;#34;R&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;R&amp;#39;&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;actions&lt;/code&gt; — a list of &lt;code&gt;n_gens&lt;/code&gt; permutations, each of length &lt;code&gt;state_size&lt;/code&gt;. Loaded as
an int64 tensor &lt;code&gt;all_moves&lt;/code&gt; of shape &lt;code&gt;[n_gens, state_size]&lt;/code&gt;. A move is applied with
&lt;code&gt;torch.gather(state, 1, all_moves[i])&lt;/code&gt;, so entry &lt;code&gt;j&lt;/code&gt; of a permutation is &lt;em&gt;the index
the value at position &lt;code&gt;j&lt;/code&gt; comes from&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;names&lt;/code&gt; — one label per action. These are not decoration: &lt;code&gt;generate_inverse_moves&lt;/code&gt;
pairs &lt;code&gt;&amp;quot;X&amp;quot;&lt;/code&gt; with &lt;code&gt;&amp;quot;X'&amp;quot;&lt;/code&gt; by string matching to build the inverse-move index used
during random-walk generation. &lt;strong&gt;Every move must have its inverse present in the
set&lt;/strong&gt;, named with a trailing apostrophe. There is no self-inverse special case: a
move whose name has no &lt;code&gt;'&lt;/code&gt;-suffixed partner makes &lt;code&gt;generate_inverse_moves&lt;/code&gt; raise
&lt;code&gt;ValueError&lt;/code&gt;, so list a self-inverse move twice, once under each name.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The generating set must be closed under inversion — otherwise the graph is directed
and the whole formulation breaks.&lt;/p&gt;</description></item></channel></rss>