Skip to content

Changelog

Unreleased

  • time/update_gather: the update's seconds building each minibatch from the rectangle (the rows' gather and decode), which the other phases left out and a run's time/update counted.
  • rollout.learner_gpus: the update on several GPUs of one machine. The coordinator spawns a helper process per further GPU (no torchrun; the launch line does not change), each attached to the training rectangle's shared segment. Every trainable cell belongs to one rank for the iteration; each rank trains its cells of every batch, the gradients are summed onto rank 0, which clips and steps, and the parameters are broadcast back. Rank 0's weights reach the helpers at the start of every update, so a resume, a rollback or starting weights need nothing more. The diagnostics, the ratio invariant and the terms' measurements are rank 0's (one minibatch in N); a debug iteration compares each helper's first minibatch with rank 0's gather of the same cells. The ranks join their process group together once every helper has built, each helper holds its allocator to the run's vram_fraction, and on NCCL a collective that times out raises in rank 0 (blocking wait) and a broken group is aborted rather than destroyed. Left out of the run identity; refused under determinism.tier run_exact. time/update_sync is the update's seconds between the ranks.
  • RunContext.learner_rank and learner_world: which rank an extension's terms are built on, so a term that draws rows of its own can draw a different stream on each.
  • Batch.shard, RectBuffer(attach=True), replica_columns / take_replica_columns and learn.transform.attach_policy_transform, which the helper ranks are built from.

0.5.26

  • rollout.eval_lockstep: each evaluation worker plays rollout.eval_games_per_worker of its battles at once, a decision at a time for all of them, with one forward per policy per decision over every battle that policy is playing (EvalActors.act_many). Each battle keeps its own seed, side, frame history and stream, and a scripted anchor acts a battle at a time in seat order, so a gate is the same measurement as before; batched arithmetic can differ from a batch of one in the last bits, so a near-tie sample can come out the other way. With rollout.eval_device "cuda" a gate's decision costs one forward per policy for all of a worker's battles rather than one per battle. Left out of the run identity; unset plays a battle at a time.
  • The gate's farm waits for an answer in proportion to the battles a worker plays at once, closes itself when a wait fails, and no longer holds the process at exit when a failed batch left requests unread in its queue.

0.5.25

  • rollout.eval_device: "cuda": the gate's evaluation workers run their actors on the run's GPU rather than at one CPU thread and a batch of one a decision. The gate is synchronous, so its battles hold the update, and on the processor a gate of a thousand battles with a network of a real run's size held it for hours while the GPU was idle. Off a CUDA run it stays on the CPU and says so; left out of the run identity, so a run can turn it on at a resume.
  • time/update_critic, time/update_actor, time/update_terms, time/update_backward and time/update_optimizer: where the update's epochs spent their seconds. On CUDA each phase is a pair of events read after the update's one synchronisation, so the split is the device's time and costs no synchronisation of its own. A phase a path does not run is absent: the critic apart from the actor only where ppo.forced_rows skips or the actor is frozen, the terms only with extra actor-loss terms.

0.5.24

  • net.critic_autocast_dtype: the critic's trunk at its own precision (bfloat16, say) and its value head at float32, whatever the actor runs at. The critic never enters the importance ratio, so an actor kept at float32 for the ratio invariant no longer holds the critic, which is most of an update under ppo.forced_rows "critic_only", to float32 as well. Needs net.separate_trunks; left out of both digests, so a run can resume with it changed.
  • Under rollout.overlap no CUDA graph is captured on the collection thread. 0.5.23's capture, thread-local and without the device-wide synchronise, still broke the update beside it on a GPU ("operation not permitted when stream is capturing" in the first update's critic pass). Every graph is now captured on the main thread before the update starts: the learner's at each size it has used, for the behaviour actor, and every graph the last overlapped collection found missing, which ran without a graph meanwhile.
  • ladder.rollback_after: after that many straight gates in which the candidate scored below ladder.rollback_below (0.45 unset) against the champion, the learner goes back to the champion's weights and both optimizers' states, saved beside each candidate before its gate (ladder/learners/). Everything else carries on, and with rollout.overlap the batch collected beside that update is dropped. ladder.stall_after: after that many straight gates without a promotion the run stops and saves itself. Only gates that played count, and a promotion ends both streaks. ladder/rollbacks, ladder/gates_below and ladder/gates_since_promotion report them. A checkpoint written with both off resumes with them on, with the streaks at zero.

0.5.23

  • ladder.pfsp_source: "games": PFSP weighs the pool by the learner's own latest learning games against each member, the last ladder.pfsp_window (200 unset) of them, a draw as a half and a half before any, rather than by the fit's prediction through the snapshot standing in for the learner. The scores are read as each plan is drawn, so an iteration's episodes are all drawn by one set of weights, and the matchmaker's checkpoint keeps the record and the resident set it drew, so a resumed run draws what the run would have. ladder.pfsp_offset adds a constant to every shaped weight before they are normalised; the hard shape at power 2 with both floors at zero and an offset of 0.05 gives (1 - score)^2 + 0.05. Unset, nothing is encoded and nothing changes. The weights are over the resident set: once the drawable pool is larger than ladder.max_resident_opponents, residents are drawn by them first and an episode's opponent among the residents, so for the formula over every member set max_resident_opponents to at least the drawable pool. Under "games" a battle still on the same episode keeps its opponent and seat when a plan is drawn, since the weights move at every plan; and a config that could weigh a member at exactly zero (no offset, both floors zero) is refused.
  • ladder.admit_refused: a candidate due its gate is always gated, also when a floor admission is due at the same step, and one the gate refuses joins the pool anyway, unpromoted. Without it a due floor admission takes the gate's place, so a floor cadence that is a multiple of the candidate cadence admits every second candidate without a gate. Unset, nothing changes.
  • A resumed run takes the fit it had without moving the residency epoch, so it holds the residents the run that never stopped held. It was moved by one at every resume, and the resident set was drawn again from another stream.
  • rollout.cuda_graphs captures with the graph's own begin and end in thread-local mode, without the device-wide synchronise and emptied allocator cache torch.cuda.graph adds. Under rollout.overlap the capture runs on the collection thread while the update runs, and in the default global mode an allocation the update makes during a capture is an error. With overlap the behaviour snapshot's weights are copied into one actor held across iterations, so the learner's graphs are captured once rather than every iteration.
  • RunContext.champion() names the ladder's champion now (gated=True: only once a champion has won its gate by playing, LadderPool.gated_champion), and RunContext.load_snapshot(id, actor) loads a pool snapshot's weights into an actor of the run's architecture, so an extension's term can anchor to the champion and follow it from one promotion to the next.

0.5.22

  • rollout.cuda_graphs: each policy's rollout forward is captured as a CUDA graph at the smallest of a few bucketed batch sizes (8 to 512 rows) and replayed, so the host launches one graph rather than a few hundred kernels per forward (learn/graphs.py). The rows are copied into buffers the graph owns and their logits read back out; the padding is real rows the network never mixes in. One graph per policy and size: the learner's (captured again when the overlap's behaviour snapshot changes) and each frozen opponent's, which goes when that opponent is no longer resident. Only the forward is captured, so sampling, decodes and the learner's statistics are as before. Off a CUDA device it is off, and a line says so. Unset, nothing is encoded.
  • Tests marked gpu need a CUDA device and are deselected by default (-m gpu runs them).

0.5.21

  • The rollout's inference gathers, decodes and uploads the uniforms of a round's policy rows once, gives each policy's forward its own contiguous part of that batch, and brings every policy's actions, log-probabilities and no-op check home in one copy at the end of the round. It read each policy's answers back as that policy finished, so a round against several frozen opponents waited on the device once per opponent, and the launches of one forward never overlapped the work of the last. The actions and log-probabilities are the same.

  • ladder.opponent_affinity: the pool battles of one shard that are on the same episode ordinal meet one opponent, drawn once for them by the same PFSP weights, from a stream of the shard's own (match/worker/{w}/shard/{s}/ordinal/{k}). The inference makes one forward per frozen opponent present in a shard's round, and drawn per battle a dozen pool battles against a large pool make about one each; a shard's battles are an episode or two apart, so with it a round holds one or two. Each episode's opponent is still a draw by the weights, and a battle's seat and its own stream are what they were. Unset, nothing is encoded and nothing changes.

0.5.20

  • A value that is not a whole number on its way into a uint8 plane is stored rounded, and is now counted in health/obs_codec_rounded, alarmed on (obs_codec_rounded, warn), and named once in a line. Preflight admits a plane to a byte when every sampled value of it is whole, and a sample that never showed a feature holds only zeros, so such a plane's fractions were rounded away without a word.
  • health/obs_codec_clipped counts what every process packed: each rollout worker sends its codec's counts home in its control word, in the record's reserve, so no offset moved. It read only the parent's codec, which a process worker's rows never pass through, so it was zero under rollout.source = "process". It is now this iteration's count rather than a running total.
  • rollout.codec_float16_planes: planes stored as float16 whatever the sample holds. rollout.codec_unseen_float16: every plane the sample never shows other than zero stored so. Either decides storage only, so the table and its digest are the ones a sample that showed those planes' fractions would have decided. Unset, nothing is encoded and tables are unchanged.

0.5.19

  • ppo.policy_transform: plugin:<module>:<function>, a function of your own of the actor's logits, f(logits, mask, vector, layout). The policy the learner trains is the masked softmax of its output, on every path the learner's policy is read: its seats in training battles, the overlap's behaviour snapshot, the update on either pairing, the ratio check, the entropy terms and the extra actor terms. The stored log-probabilities are the transformed policy's, so the first ratio is still one. Snapshots, opponents, the gate and evaluation play the actor itself, the live learner included. The first batch checks that the output is float32 logits of the input's shape, finite on every legal action, differentiable, and each row's own. Set, it is in algo_digest and its module in the identity's user_code; unset, nothing is encoded. RunContext.policy_transform hands it to an extension, and the surface carries PolicyLayout, PolicyTransform and MaskedCategorical.
  • The shared-trunk pairing's update runs the policy head as the actor's forward does under net.policy_head_float32: in float32, on float32 features. It ran the head under the autocast, so its logits were not the rollout's.
  • Learner.load_env rebuilds an engine whose __init__ takes *args, **kwargs and hands them to its base's, RoyaleGym's SymmetricRustEngine among them, which failed on cards. It takes its base's settings, and is held to them as any engine is.
  • A refused carry-on, learn over a run started with another network, environment or opponent setup, leaves the run's environment.json as it was. It was rewritten with the new env before the check.

0.5.18

  • rollout.mask_only_scripted: a scripted opponent's seat skips building its observation after its episode's first step (RoyaleGym's ClashParallelEnv.set_mask_only), since a scripted opponent reads only the masks. The run plays exactly what it played without it: the same actions, rewards and episodes, and the same learner rows. Not on the shard that carries the viewer or the recorder. Needs royalegym 0.1.21; preflight refuses it on an older one. Unset, off.

0.5.17

  • device="auto" trains on the CPU, and says why in one line, when the NVIDIA card torch can see is one this PyTorch was not built for: a GTX 970 (sm_52) under a build for sm_75 and newer, say, where the first kernel failed with "no kernel image is available". A run that names the GPU itself is refused with the same reason. A card runs a build with machine code for its major version at or below its minor, or PTX at or below its capability (royalelearn.gpu.cuda_arch_supported); AMD cards are not judged this way.

0.5.16

  • SnapshotSpec.actor_digest: what an actor folder's weights compute, which is arch_digest less the autocast precision, the head's precision, the device, the initialisation and the critic (learn.nets.actor_digest_of; net.noop_bias, added in the forward, stays in). check_compatible compares it when both sides state it, so a warm start or a pool snapshot loads into a run that differs only there, a bfloat16 run from a float32 clone, say. A folder without it is held to arch_digest as before, and an unset one is not written, so existing folders keep their bytes. A run's identity and resume keep arch_digest. The extensions surface carries actor_digest_of, arch_digest_of and NetConfig.

0.5.15

Tagged, never published to PyPI: its CI failed on the tag. Everything below is in 0.5.16.

  • net.policy_head_float32 computes the policy's logits in float32 from the trunk's features while the trunk keeps net.autocast_dtype. Under bfloat16 a large logit is rounded to bfloat16's spacing, which the importance ratio feels through the largest action's probability; the preflight ratio guard now predicts from the precision the logits are computed at, and names this setting when it refuses. An extension's RunContext.precision is that precision. Every actor is built by learn.nets.build_actor and follows it: the run's own, a pool snapshot's, an evaluation's and a saved bot's. Unset, nothing changes.
  • net.critic_channels and net.critic_blocks give the critic's trunk, and its value head, a width and depth of their own under net.separate_trunks. Unset, the critic is the actor's size and every config hash and architecture digest is as before. A critic shape that cannot be built is refused by these names.

0.5.14

  • royalelearn bench times the codec on a row with every key the run's observation space declares. It packed a row of the spatial, vector and mask keys alone, which a run storing id planes (card, spell or unit ids) refused with a TypeError before the table was printed.

0.5.13

  • Where collection's time goes, per iteration: time/worker_env, time/worker_busy and time/worker_idle (one worker's seconds in the environments, working on rounds, and waiting for the learner), time/worker_straggle (how much longer the slowest worker took than the average, over all rounds), time/parent_wait and time/parent_other (with time/inference they add up to time/collection), and throughput/worker_busy_frac. Each worker states its busy and idle time in the control word it publishes, in the record's reserve, so no offset moved. royalelearn bench prints the new figures.
  • A worker's publication after a command that runs no step carries no environment time; it carried the previous step's, which time/env then counted twice at each iteration's start. The schema says plainly that time/env is summed over the workers.

0.5.12

  • environment.json holds the whole of env.config() for the env build_env returns, and Learner.save writes it beside the bot as well as into the run's folder. An add-on that saves a bot writes it with royalelearn.extensions.write_environment_record, and Learner.environment is what it holds.
  • Learner.load_env(folder) rebuilds the environment a saved bot, a run's folder or one of its checkpoints was trained in from that record alone, with no build_env run. It builds only RoyaleGym's and RoyaleLearn's own classes, each of the kind its place takes, and refuses an env that does not describe itself as the record does. A part it cannot rebuild is named and can be handed in, built: Learner.load_env(folder, reward_fn=MyReward()). A record written before it named the engine takes the engine policy.json names.

0.5.11

  • AMD cards on torch's ROCm build, which shows them as "cuda" devices: a run's identity names the card by its AMD architecture (rocm:<name>:gfx1100); the throughput tier leaves cuDNN's benchmark search off there; the start-up memory check and the memory health fields carry on when the driver cannot say how much memory is free; and the GPU utilisation hint names AMD's package. When the card refuses the GPU memory cap (reported for AMD's APUs), the run goes on without one.
  • A card reached through ZLUDA is named as such and noted at start-up, and cuDNN is switched off there. It is refused on a torch build without PTX, as torch's builds for CUDA 12 and later are, with a net.autocast_dtype other than float32, and under determinism.tier run_exact.
  • The looser float32 ratio tolerance applies only on cards that have TF32 (NVIDIA Ampere and newer); elsewhere float32 is checked at float32's tolerance.
  • net.button_head = "card": each ability button is scored from its card's embedding (the hand slots' table), its own status and its ready bit beside the pooled board, by one scorer shared by every button, so which position a card's button sits in does not change its logit. It reads RoyaleGym's per-button fields (SpatialObsBuilder(button_index=True)), which then reach only the button scorer. Unset, the head and every digest are as before.

0.5.10

  • The start-up memory projection counts a process worker's fixed cost as 200 MB, measured on Windows; it counted 40. A run whose rollout workers came up with torch imported is warned at start-up, since that costs some 850 MB a worker the projection cannot see.
  • net.hand_slot_features: observation vector fields with one value per hand slot (for example own_hand_evolved) join that slot's card embedding where the policy head builds the slot's query. Unset, the network, its weights and its architecture digest are as before.
  • unit_ids, each tile's own unit type (RoyaleGym's SpatialObsBuilder(unit_identity=True)), is stored exactly in a codec region of its own (one byte a value, two once the unit list passes 255 types), carried in ObsBatch.unit_ids and embedded in a table of its own beside the card ids. Without it, every row, table and digest is as before.

0.5.9

  • doctor.vram_fraction sets the GPU memory cap from a config: a share of the card in (0, 1], or null for no cap. Unset, the constructor's vram_fraction decides, as before.
  • The ratio check's tolerance follows the precision the forwards ran at: float32 on a GPU allowed TF32 (the default outside determinism.tier run_exact) is checked at 5e-3, or at ppo.ratio_atol["tf32"] when a config names it, instead of float32's 1e-4.
  • When the start-up memory probe runs out of memory under the cap, the message says so and names what to change.

0.5.8

  • A CUDA run on Windows starts again: the memory cap named the device as cuda with no index, which torch refuses, so every such run stopped at start-up since 0.5.5. It now names the device's index, or the current device's.

0.5.7

  • rollout.overlap runs: the next iteration is collected on a second thread while the update trains on a copy of this one. Its learner seats sample from a snapshot of the actor taken just before the update, so each batch after the first is one update behind the learner it trains, and the ratio check is made against that snapshot. Rows carry ppo/behaviour_lag_iterations and time/overlap_saved. It needs a second rectangle of memory, is off by default, and is refused under determinism.tier run_exact.

0.5.6

  • net.trunk_stride, an opt-in stride for the residual trunk (1 or 2, default 1). At 2 a strided convolution after the stem runs the residual blocks at half the board's resolution in each direction, and their output is upsampled and added to the stem's, so the heads still read one feature per tile. At 1 nothing changes: the network, its weights and its architecture digest are as before.

0.5.5

  • On Windows a GPU run caps its memory at 80% of the card by default. Windows backs a full card with system RAM instead of failing, so without a cap torch's memory cache could take gigabytes of it over a long run. Set it with Learner(vram_fraction=...): a share of the card, or None for no cap. Elsewhere there is no cap unless you set one. The start-up check that one minibatch fits the card counts the cap.

0.5.4

  • The spells' ids reach the network. RoyaleGym's SpatialObsBuilder(spell_identity=True) adds a spell_ids observation (four planes in the card_ids vocabulary). It is stored exactly beside card_ids, carried in ObsBatch.card_ids after the card planes, and read through the same card embedding into the trunk. It needs card_identity; a spell_ids without card_ids, or in another vocabulary, is refused at start-up. Without it, every row, table and digest is as before.

0.5.3

  • The start-up check that plays a battle of no-ops to its end allows half a match past the clock, so it passes on an engine whose level overtime ends after the clock (RoyaleSim's tower drain).

0.5.2

  • A run that uses an add-on installed from a wheel (RoyaleImitate's warm_start or imitation, installed with pip install "royalegym[all]") starts. The run's identity names the add-on by the content of its files, content:<sha256>, where there is no commit to name; it used to refuse the run.

0.5.1

  • royalelearn.extensions.write_policy_record(folder, env_spec, net) writes the policy.json that lets Learner.load_policy load an actor folder another tool wrote, such as a clone.

0.5.0

  • ladder.opponent_mode and ladder.release_mode take stochastic, argmax, or a decode of your own: plugin:<module>:<function>, called with a batch's masked log-probabilities, mask and observation vector, returning one legal action per row. No other decode is built in, and a config that names another is refused.
  • royalelearn.extensions adds LearningCoordinator, SCRIPTED_NAMES and build_opponent, for add-ons such as RoyaleImitate's recording and cloning.

0.4.3

  • A run carried on from save_dir with another environment from build_env (the reward, the decks, the observation, the actions, when a battle ends) says so in one line, naming what changed. The run's folder keeps environment.json for it.

0.4.2

  • Runs on macOS: shared-memory segment names are at most 30 characters (macOS refuses longer ones), and a longer name is refused on every platform.

0.4.1

  • A Learner made again on the same save_dir with other training settings (learning rates, epochs, batch sizes, the entropy bonus, the discount) carries the run on and prints what changed. Another network, environment or opponent setup is refused, saying so in words.
  • Ctrl-C during learner.learn() stops after the current update, writes a checkpoint and returns, so the script carries on (to learner.save, say). A second Ctrl-C stops at once.
  • Learner.load_policy loads a run's folder (its newest checkpoint) or one checkpoint, as well as a folder learner.save wrote.

0.4.0

  • Learner takes its settings by name, each with a default: the network (trunk_channels, trunk_blocks, critic_hidden), the update (ppo_epochs, ppo_batch_size, ppo_minibatch_size, policy_lr, critic_lr, ppo_ent_coef, ppo_clip_range, gae_gamma, gae_lambda, standardize_returns), timestep_limit, n_checkpoints_to_keep, and log_to_wandb with wandb_project_name, wandb_group_name and wandb_run_name. The defaults build the same run as before.
  • learner.learn() with no total_steps stops at timestep_limit.
  • A build_env in code run by exec (a docs checker, some IDE runners) is found by the run.

0.3.0

  • Learner trains on the GPU by default: device="auto" is CUDA when torch can see a GPU, and otherwise the CPU, with one printed line saying so. On a CPU it uses half the machine's cores for the network (threads=).
  • net.policy_head = "factored": the policy as three stages (wait or act, then which card or button, then which tile) over the same action space, with net.factored_act_init for the gate's start.
  • ppo.entropy_coef_stages: one entropy coefficient for each of those three stages.
  • SeedSnapshot.weight: how often the pool draws a seed, as a multiplier on its draw weight.
  • Learner(..., extensions={...}) sets an add-on's config sections, such as RoyaleImitate's warm_start, and learner.run keeps the finished run for an add-on to read.

0.2.0

  • Learner(build_env).learn(total_steps=...): train a bot in one call, with defaults that run on a CPU, one progress line per update, and checkpoints that carry a run on from the same save_dir. Learner.load_policy(path) loads a saved bot that plays one seat.
  • Ability buttons (a hero's or a champion's) are actions the network can choose.
  • ladder.seat_decks trains one deck where the learner sits, against a field of others.
  • ladder.opponent_mode sets how a frozen opponent picks its moves in training battles.

0.1.0

  • The first release: the PPO learner, the opponent ladder, checkpoints and resume.