Core infrastructure
The worldfoundry/core shared layer — loading, attention, distributed, VRAM, kernels, memory, and the rule that reusable primitives live here, not in family packages.
On this page
Why this layer exists
worldfoundry/core is the shared inference infrastructure that every model family reuses and none of them owns. Checkpoint loading, state-dict remapping, attention backends, distributed collectives, VRAM placement and offload, kernels, configuration, media IO, memory contracts, and safety guardrails all live here once. A family package (worldfoundry/base_models/*, worldfoundry/synthesis/*, worldfoundry/pipelines/*) composes these primitives; it must not recreate them.
This is the layer to read when you are about to copy a utility into a model directory. The rule is explicit: if multiple families actually reuse a capability, it belongs in core; an adapter tied to a specific model belongs with that model. See Native diffusion for how diffusion consumes this layer, and Model runtime for how pipelines and operators do.
Subpackage responsibilities
Subpackage
attentionBackends, rotary embeddings, sequence layouts, KV caches, sparse and parallel attention.
Start here
backends/, rotary/, sequence/, cache/, sparse/, parallel/distributedProcess setup, collectives, model-parallel groups, sequence-parallel runtime and parameter sharding.
Start here
runtime/, collectives/, model_parallel/, sequence_parallel/, sharding/model_loadingModel construction, loading policy and weight conversion; checkpoints is the single owner of safe state-dict loading and assignment.
Start here
checkpoints/, factory.py, inference_model.py, lora.pyioAsset materialization, filesystems, structured formats and inference input datasets.
Start here
assets/, filesystem/, formats/, inputs/, paths.py, manifests.pymediaImage, audio and video codecs, frame processing, output types and artifact previews.
Start here
codecs/, processing/, types.py, resolutions.py, artifacts.pyexecutionDevice and process lifecycle, inference policy, runtime caches, CUDA graph replay and realtime orchestration.
Start here
graphs/, realtime/, inference.py, inference_runtime.py, process.pyconfigurationStructured/Python config, Hydra adapters, overrides, lazy instantiation and validation.
Start here
lazy_config/, hydra.py, hydra_utils.py, overrides.py, python.py, validators.pynnReusable neural blocks, transformer math, diffusion primitives, latent codecs and activation checkpointing.
Start here
blocks/, transformer/, diffusion/, latent/, checkpointing/accelerationReusable cache, token pruning and opt-in low-precision linear operators.
Start here
quantization/, cache.py, token_pruning.py, technology.pykernelsOperator implementations and dispatch for diffusion, MoE and quantized GEMM, including optional Triton providers.
Start here
capabilities.py, registry.py, diffusion.py, moe.py, quantized_gemm.pyvramPhysical parameter placement, meta initialization, disk state, CPU offload and encoder lifetime.
Start here
device_map.py, initialization.py, disk_map.py, layerwise_offload.py, encoder_lifecycle.pymemorySemantic/context memory contracts, retrieval, conditioning and persistence.
Start here
base.py, conditioning.py, media.py, mosaic.py, retrieval.py, store.pygeometryCamera transforms, pose conditioning, trajectories and RGBD warping.
Start here
transforms.py, pose.py, trajectory.py, conditioning.py, warp.pyobservabilityLogging, terminal formatting, timing, profiling and optional NVTX ranges.
Start here
logging_setup.py, formatting.py, colors.py, time.py, torchprofile.pysafetySafety filters and video input guardrails.
Start here
guardrails.py, video_io.pyutilsGeneral Python object/tree helpers and tensor/array utilities with no runtime or media ownership.
Start here
python/, tensors/
Dependency rule
core may depend on PyTorch, diffusers model/operator primitives, and narrow third-party libraries. It must not import worldfoundry.pipelines, worldfoundry.synthesis, worldfoundry.operators, worldfoundry.base_models family packages, or worldfoundry.evaluation, or worldfoundry.studio. The edge points out of family packages into core, never the reverse.
This keeps family packages thin: a model directory contains checkpoint-compatible tensor math and contract adapters, not a second copy of an offload manager, a distributed bootstrap, a kernel registry, or a quantization system. When you find yourself adding one of those to a family package, move it to core first and import it from there.
The diffusion package restates this rule for its own boundary in Native diffusion. Generic attention, transformer, loading, and offload primitives live in core; diffusion-domain contracts, schedulers, and recipes live in base_models/diffusion_model.
Where it is consumed
- Diffusion —
base_models/diffusion_modelloads checkpoints throughcore/model_loading, runs attention throughcore/attention, and offloads throughcore/vram. Itsoptimizations/re-exports core policy, not a parallel implementation. - Hosted and native runtimes —
synthesis/stages inputs throughcore/ioand writes artifacts throughcore/media. - Memory —
core/memory/base.pydefines the contract; streaming and long-context state insynthesis/*/memoryand action-policy trace state insynthesis/action_generation/memory.pyimplement it. - Distributed execution —
core/distributedis the only place model-parallel groups are initialized; no family package boots its own NCCL group.
What does not belong here
Training entrypoints, training-only datasets and dataloaders, losses, callbacks, augmentation-only modules, and experiment scripts do not belong in core, nor in base_models. core is inference infrastructure; if a module only matters during training, it should not be added here.
For the directory-level map of every package, see Codebase map. For how a model call flows through these primitives, see Model runtime and Runtime assembly.
Ownership decisions
checkpointis part ofmodel_loading/checkpoints; weight loading, assignment and conversion have one owner.- Media codecs and the former
videoprocessing helpers sharemedia; downloading and filesystem work stay inio. - CUDA graphs, prewarm, frame prefetch and overlap belong to
execution; encoder placement/lifetime belongs tovram. memorystays separate fromvram: context/retrieval is a model input concern, while placement/offload manages physical memory.- Configuration helpers leave
io, terminal formatting leavesio, and runtime scheduling leavesutils. - Wan sequence-parallel adapters and VGGT observation preprocessing live in their model families. Repository inventory audits live in
scripts/model_zoo.
Public lazy function/class facades remain stable. Internal module imports use the current owners; removed directories do not contain compatibility wrappers.
Regression gates
tests/core/test_core_module_boundaries.py checks lazy targets and core imports without optional model dependencies. It also guards against dependencies from core into model/application packages. Runtime facade tests run in model environments.
Real-checkpoint changes also require make test-geometry: use fixed inputs, checkpoints, environments and seeds, compare numerical outputs against an accepted reference, and verify the replay hashes still match the current source. Moving files must preserve computation as well as importability.