peal.generators.rae_pipeline.RAEPipeline¶
- class peal.generators.rae_pipeline.RAEPipeline[source]¶
Bases:
objectDrive RAEv2’s stage-1, stats, cache and stage-2 scripts as subprocesses.
Each
run_*method checks its own completion marker first, so the pipeline can be restarted after a crash. Training scripts run undertorch.distributed.runwith one process per visible GPU (or$RAE_NPROC), withcwdset to the RAEv2 checkout and itssrcand.depsdirectories onPYTHONPATH. Output goes to<base_path>/{stage1,stats,cache,stage2}.log.- Parameters:
cfg (
dict) – Config fromload_generator_config(); usesbase_path,raev2_dir,stage1_config,stage2_config, the experiment names, precisions,keep_checkpointsand thecache_*keys.logger (
callable, optional) – Receives progress strings. Defaultprint.
- Variables:
stage2_exp (stage1_exp,) – The RAEv2 experiment directories.
stats_path (decoder_path,) – Stage-1 assets consumed by stage 2.
stage2_yaml (stage1_yaml,) – The parsed RAEv2 stage configs.
Methods
Whether the stage-2 latent cache has its
metadata.jsonmarker.Delete all but the newest
keepepoch checkpoints of an experiment.Path of a stage config with PEAL placeholders already expanded.
Run one stage, or all four in order.
Encode the train set once (latent + CLIP embedding) into premixed shards.
Train the RAEv2 stage-1 autoencoder unless already finished.
Train the RAEv2 stage-2 diffusion model on the latent cache.
Extract the EMA decoder and per-channel latent statistics of stage 1.
Copy the generator yaml to
<base_path>/config.yaml(if different).Whether the final stage-1 checkpoint exists.
Path of the stage-1 checkpoint for the configured final epoch.
Whether the final stage-2 checkpoint exists.
Path of the stage-2 checkpoint for the configured final epoch.
Whether both
decoder.ptandstats.ptexist.- __init__(cfg, logger=<built-in function print>)[source]¶
Resolve the run layout from
cfgand parse both RAEv2 stage configs.
- resolved_stage_config(stage)[source]¶
Path of a stage config with PEAL placeholders already expanded.
RAEv2’s train scripts receive
--config <path>and parse it with OmegaConf, which knows nothing about<PEAL_RAEV2>or<PEAL_BASE>; a placeholder would reach it verbatim and surface asIncorrect path_or_model_id: '<PEAL_RAEV2>/configs/decoder/ViTXL'. The expanded copy is written once per process under<base>/resolvedand reused.
- prune_checkpoints(exp_dir, keep=None)[source]¶
Delete all but the newest
keepepoch checkpoints of an experiment.ep-last.ptis a hard link and survives on its own. RAEv2 writes about 10 GB per epoch and never prunes.
- save_config_copy(src_path)[source]¶
Copy the generator yaml to
<base_path>/config.yaml(if different).
- run_stage1()[source]¶
Train the RAEv2 stage-1 autoencoder unless already finished.
Prunes old checkpoints first, then runs
src/train_stage1.pywithstage1_config,stage1_dirandstage1_precision.- Raises:
RuntimeError – When the script exits 0 without writing the final checkpoint.
- run_stats()[source]¶
Extract the EMA decoder and per-channel latent statistics of stage 1.
Runs
scripts/stage1/extract_decoder.pyandscripts/stage1/compute_encoder_stats.py(the latter under torchrun overstats_num_samplestrain images), skipping whichever asset is already present.- Raises:
RuntimeError – When stage 1 has not finished, or the assets are still missing after the scripts exit 0.
- run_cache()[source]¶
Encode the train set once (latent + CLIP embedding) into premixed shards.
The shard-batch sampler serves every micro-batch from a single shard, so the source order is globally permuted first (cache_permutation_seed); without that each shard would hold one ImageFolder class. A cache directory that already holds
rank*files but nometadata.jsonis treated as incomplete and rebuilt with--overwrite.- Raises:
RuntimeError – When the stage-1 assets are missing or the build exits 0 without writing
metadata.json.
- run_stage2()[source]¶
Train the RAEv2 stage-2 diffusion model on the latent cache.
Verifies that the stage-2 yaml’s
pretrained_decoder_pathandnormalization_stat_pathpoint at this pipeline’s assets, prunes old checkpoints and runssrc/train.pyunder torchrun.- Raises:
RuntimeError – When prerequisites are missing, the stage-2 config points at other assets, or the final checkpoint is missing after a clean exit.