d9d 0.1.1__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- d9d-0.2.0/LICENSE +201 -0
- {d9d-0.1.1 → d9d-0.2.0}/PKG-INFO +2 -1
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/swiglu/op.py +17 -4
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/__init__.py +5 -2
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/model_stage_factory.py +14 -54
- d9d-0.1.1/d9d/loop/component/loss_computer.py → d9d-0.2.0/d9d/loop/component/pipeline_result_processing.py +73 -10
- d9d-0.1.1/d9d/loop/component/train_task_operator.py → d9d-0.2.0/d9d/loop/component/task_operator.py +97 -57
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/config/config.py +1 -1
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/control/task.py +2 -2
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/run/__init__.py +3 -0
- d9d-0.2.0/d9d/loop/run/inference.py +256 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/run/train.py +2 -4
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/state.py +4 -1
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/api/__init__.py +3 -0
- d9d-0.2.0/d9d/pipelining/api/types.py +28 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/factory/factory.py +68 -29
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/runtime/__init__.py +3 -1
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/runtime/action.py +7 -10
- d9d-0.1.1/d9d/pipelining/infra/schedule/component/runtime/loss.py → d9d-0.2.0/d9d/pipelining/infra/schedule/component/runtime/callback.py +33 -10
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/runtime/executor.py +10 -8
- d9d-0.2.0/d9d/pipelining/infra/schedule/component/runtime/offline.py +70 -0
- {d9d-0.1.1 → d9d-0.2.0}/pyproject.toml +1 -1
- {d9d-0.1.1 → d9d-0.2.0}/README.md +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/autograd/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/autograd/grad_context.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_context/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_context/configured.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_context/device_mesh_domains.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_context/log.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_context/params.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_ops/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_ops/object.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/dist_ops/tensor.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/protocol/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/protocol/training.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/sharding/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/sharding/auto_spec.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/sharding/shard.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/sharding/spec.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/sharding/unshard.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/types/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/types/data.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/core/types/pytree.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/dataset/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/dataset/buffer_sorted.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/dataset/padding.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/dataset/sharded.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/determinism/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/determinism/seed.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/grad_norm/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/grad_norm/group.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/grad_norm/norm.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/grad_sync/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/grad_sync/bucket.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/grad_sync/placement_helper.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/grad_sync/synchronizer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/pipeline_state/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/pipeline_state/api.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/pipeline_state/handler.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/pipeline_state/storage.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/profiling/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/profiling/profile.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/state/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/internals/state/main_process.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/cce/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/cce/cce.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/cce/main.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/general/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/general/get_int_dtype.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/gmm/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/gmm/function.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/moe/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/moe/indices_to_multihot.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/moe/permute_with_probs.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/stochastic/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/stochastic/adamw_step.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/stochastic/copy.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/stochastic/ops/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/stochastic/ops/round.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/swiglu/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/kernel/swiglu/function.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/auto/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/auto/auto_lr_scheduler.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/auto/auto_optimizer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/batch_maths.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/checkpointer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/data_loader_factory.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/garbage_collector.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/gradient_clipper.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/gradient_manager.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/job_logger.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/job_profiler.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/model_stage_exporter.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/optimizer_factory.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/stepper.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/component/timeout_manager.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/config/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/config/types.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/control/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/control/dataset_provider.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/control/lr_scheduler_provider.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/control/model_provider.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/loop/control/optimizer_provider.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/lr_scheduler/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/lr_scheduler/piecewise/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/lr_scheduler/piecewise/builder.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/lr_scheduler/piecewise/config.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/lr_scheduler/piecewise/curves.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/lr_scheduler/piecewise/engine.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/lr_scheduler/visualizer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/metric/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/metric/abc.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/metric/impl/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/metric/impl/compose.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/metric/impl/mean.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/io/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/io/dto.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/io/module_reader.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/io/module_writer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/io/reader.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/io/writer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/abc.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/adapters/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/adapters/mapper.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/adapters/module.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/compose/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/compose/helper.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/compose/parallel.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/compose/sequential.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/compose/shard.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/leaf/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/leaf/dtensor.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/leaf/identity.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/leaf/rename.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/leaf/select_child.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/model_state/mapper/leaf/stack.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/base/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/base/late_init.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/attention/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/attention/grouped_query.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/attention/sdpa/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/attention/sdpa/flash.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/embedding/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/embedding/shard_token_embedding.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/ffn/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/ffn/swiglu.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/head/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/head/language_modelling.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/hidden_states_aggregator/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/hidden_states_aggregator/base.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/hidden_states_aggregator/factory.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/hidden_states_aggregator/mean.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/hidden_states_aggregator/noop.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/communications/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/communications/base.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/communications/deepep.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/communications/naive.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/grouped_experts.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/grouped_linear.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/layer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/moe/router.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/positional/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/block/positional/rope.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/model/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/model/qwen3_moe/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/model/qwen3_moe/decoder_layer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/model/qwen3_moe/model.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/model/qwen3_moe/params.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/api/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/api/expert_parallel.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/api/fully_sharded.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/api/hybrid_sharded.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/api/replicate_parallel.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/model/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/model/qwen3_moe.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/style/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/style/shard_experts.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/module/parallelism/style/to_local.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/optim/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/optim/stochastic/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/optim/stochastic/adamw.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/all/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/all/config.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/all/method.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/applicator.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/base.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/full_tune/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/full_tune/config.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/full_tune/method.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/lora/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/lora/config.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/lora/layer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/peft/lora/method.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/api/module.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/api/schedule.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/api/sharding.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/factory/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/factory/config.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/factory/registry.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/program/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/program/base.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/program/communications.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/program/topology.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/component/runtime/communications.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/program/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/program/bfs.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/program/dualpipev.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/program/interleaved.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/schedule/program/zerobubblev.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/stage/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/stage/communications.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/stage/computations.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/stage/splitgrad.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/stage/stage.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/infra/stage/struct_helper.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/training/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/training/optimizer.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/pipelining/training/scheduler.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/base.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/factory.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/provider/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/provider/aim/__init__.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/provider/aim/config.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/provider/aim/tracker.py +0 -0
- {d9d-0.1.1 → d9d-0.2.0}/d9d/tracker/provider/null.py +0 -0
d9d-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
{d9d-0.1.1 → d9d-0.2.0}/PKG-INFO
RENAMED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: d9d
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: d9d - d[istribute]d - distributed training framework based on PyTorch that tries to be efficient yet hackable
|
|
5
5
|
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Author: Maksim Afanasyev
|
|
7
8
|
Author-email: mr.applexz@gmail.com
|
|
8
9
|
Requires-Python: >=3.11,<3.15
|
|
@@ -3,6 +3,15 @@ import triton
|
|
|
3
3
|
import triton.language as tl
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
def _size_bucket(n_elements: int) -> int:
|
|
7
|
+
# different auto-tuning for small and asymptotically large kernels
|
|
8
|
+
# perhaps we could extend this in future?
|
|
9
|
+
if n_elements < 8192:
|
|
10
|
+
return 0
|
|
11
|
+
else:
|
|
12
|
+
return 1
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
@triton.autotune(
|
|
7
16
|
configs=[
|
|
8
17
|
triton.Config({"BLOCK_SIZE": 1024}, num_warps=4),
|
|
@@ -11,7 +20,7 @@ import triton.language as tl
|
|
|
11
20
|
triton.Config({"BLOCK_SIZE": 4096}, num_warps=8),
|
|
12
21
|
triton.Config({"BLOCK_SIZE": 8192}, num_warps=8),
|
|
13
22
|
],
|
|
14
|
-
key=["
|
|
23
|
+
key=["size_bucket"]
|
|
15
24
|
)
|
|
16
25
|
@triton.jit
|
|
17
26
|
def _silu_mul_kernel(
|
|
@@ -19,6 +28,7 @@ def _silu_mul_kernel(
|
|
|
19
28
|
y_ptr: torch.Tensor,
|
|
20
29
|
out_ptr: torch.Tensor,
|
|
21
30
|
n_elements: int,
|
|
31
|
+
size_bucket: int, # used for autotuning
|
|
22
32
|
BLOCK_SIZE: tl.constexpr,
|
|
23
33
|
):
|
|
24
34
|
# prepare
|
|
@@ -72,7 +82,8 @@ def silu_mul_forward(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
|
72
82
|
|
|
73
83
|
_silu_mul_kernel[_grid](
|
|
74
84
|
x, y, out,
|
|
75
|
-
n_elements
|
|
85
|
+
n_elements,
|
|
86
|
+
size_bucket=_size_bucket(n_elements)
|
|
76
87
|
)
|
|
77
88
|
|
|
78
89
|
return out
|
|
@@ -86,7 +97,7 @@ def silu_mul_forward(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
|
86
97
|
triton.Config({"BLOCK_SIZE": 4096}, num_warps=8),
|
|
87
98
|
triton.Config({"BLOCK_SIZE": 8192}, num_warps=8),
|
|
88
99
|
],
|
|
89
|
-
key=["
|
|
100
|
+
key=["size_bucket"]
|
|
90
101
|
)
|
|
91
102
|
@triton.jit
|
|
92
103
|
def _silu_mul_backward_kernel(
|
|
@@ -96,6 +107,7 @@ def _silu_mul_backward_kernel(
|
|
|
96
107
|
grad_x_ptr: torch.Tensor,
|
|
97
108
|
grad_y_ptr: torch.Tensor,
|
|
98
109
|
n_elements: int,
|
|
110
|
+
size_bucket: int, # used for autotuning
|
|
99
111
|
BLOCK_SIZE: tl.constexpr
|
|
100
112
|
):
|
|
101
113
|
# prepare
|
|
@@ -161,7 +173,8 @@ def silu_mul_backward(
|
|
|
161
173
|
_silu_mul_backward_kernel[_grid](
|
|
162
174
|
grad_output, x, y,
|
|
163
175
|
grad_x, grad_y,
|
|
164
|
-
n_elements
|
|
176
|
+
n_elements,
|
|
177
|
+
size_bucket=_size_bucket(n_elements)
|
|
165
178
|
)
|
|
166
179
|
|
|
167
180
|
return grad_x, grad_y
|
|
@@ -6,13 +6,13 @@ from .gradient_clipper import GradientClipper
|
|
|
6
6
|
from .gradient_manager import GradientManager
|
|
7
7
|
from .job_logger import JobLogger
|
|
8
8
|
from .job_profiler import JobProfiler
|
|
9
|
-
from .loss_computer import LossComputer
|
|
10
9
|
from .model_stage_exporter import ModelStageExporter
|
|
11
10
|
from .model_stage_factory import ModelStageFactory, TrackedModules
|
|
12
11
|
from .optimizer_factory import OptimizerFactory
|
|
12
|
+
from .pipeline_result_processing import InferenceProcessor, LossComputer, PipelineOutputsProcessor
|
|
13
13
|
from .stepper import Stepper
|
|
14
|
+
from .task_operator import ForwardResult, InferenceTaskOperator, TrainTaskOperator
|
|
14
15
|
from .timeout_manager import TimeoutManager
|
|
15
|
-
from .train_task_operator import ForwardResult, TrainTaskOperator
|
|
16
16
|
|
|
17
17
|
__all__ = [
|
|
18
18
|
"BatchMaths",
|
|
@@ -20,6 +20,8 @@ __all__ = [
|
|
|
20
20
|
"ForwardResult",
|
|
21
21
|
"GradientClipper",
|
|
22
22
|
"GradientManager",
|
|
23
|
+
"InferenceProcessor",
|
|
24
|
+
"InferenceTaskOperator",
|
|
23
25
|
"JobLogger",
|
|
24
26
|
"JobProfiler",
|
|
25
27
|
"LossComputer",
|
|
@@ -27,6 +29,7 @@ __all__ = [
|
|
|
27
29
|
"ModelStageExporter",
|
|
28
30
|
"ModelStageFactory",
|
|
29
31
|
"OptimizerFactory",
|
|
32
|
+
"PipelineOutputsProcessor",
|
|
30
33
|
"StateCheckpointer",
|
|
31
34
|
"Stepper",
|
|
32
35
|
"TimeoutManager",
|
|
@@ -15,7 +15,7 @@ from d9d.pipelining.api import PipelineStageInfo
|
|
|
15
15
|
from d9d.pipelining.factory.factory import PipelineScheduleInfo, build_schedule
|
|
16
16
|
|
|
17
17
|
from .batch_maths import BatchMaths
|
|
18
|
-
from .
|
|
18
|
+
from .pipeline_result_processing import PipelineOutputsProcessor
|
|
19
19
|
|
|
20
20
|
StatefulPredicate = Callable[[str, torch.Tensor], bool]
|
|
21
21
|
"""Determines if a specific parameter or buffer should be included in the state dictionary."""
|
|
@@ -51,28 +51,6 @@ class TrackedModules(Stateful):
|
|
|
51
51
|
self._modules = modules
|
|
52
52
|
self._stateful_predicate = stateful_predicate
|
|
53
53
|
|
|
54
|
-
def __call__(self, *args: Any, **kwargs: Any) -> Any:
|
|
55
|
-
"""
|
|
56
|
-
Forwards execution to the only pipeline stage.
|
|
57
|
-
|
|
58
|
-
This method is only valid when pipeline parallelism is disabled.
|
|
59
|
-
|
|
60
|
-
Args:
|
|
61
|
-
*args: Positional arguments passed to the module.
|
|
62
|
-
**kwargs: Keyword arguments passed to the module.
|
|
63
|
-
|
|
64
|
-
Returns:
|
|
65
|
-
The output of the model execution.
|
|
66
|
-
|
|
67
|
-
Raises:
|
|
68
|
-
ValueError: If pipeline parallelism is configured.
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
if self._dist_context.mesh_params.has_pipeline_parallel:
|
|
72
|
-
raise ValueError("You cannot call tracked modules when using pipelining")
|
|
73
|
-
|
|
74
|
-
return self._modules[0](*args, **kwargs)
|
|
75
|
-
|
|
76
54
|
@property
|
|
77
55
|
def modules(self) -> list[nn.Module]:
|
|
78
56
|
"""Returns the list of underlying PyTorch model modules."""
|
|
@@ -159,8 +137,8 @@ class ModelStageFactory:
|
|
|
159
137
|
dist_context: DistributedContext,
|
|
160
138
|
batch_maths: BatchMaths,
|
|
161
139
|
config_model: ModelStageFactoryConfig,
|
|
162
|
-
config_pipelining: PipeliningConfig
|
|
163
|
-
|
|
140
|
+
config_pipelining: PipeliningConfig,
|
|
141
|
+
pipeline_callback: PipelineOutputsProcessor
|
|
164
142
|
):
|
|
165
143
|
"""Constructs a ModelStageFactory object."""
|
|
166
144
|
|
|
@@ -169,7 +147,7 @@ class ModelStageFactory:
|
|
|
169
147
|
self._config_model = config_model
|
|
170
148
|
self._config_pipelining = config_pipelining
|
|
171
149
|
self._batch_maths = batch_maths
|
|
172
|
-
self.
|
|
150
|
+
self._pipeline_callback = pipeline_callback
|
|
173
151
|
|
|
174
152
|
def _build_model_stage(self, stage: PipelineStageInfo) -> nn.Module:
|
|
175
153
|
# create a model with no real memory occupied
|
|
@@ -218,21 +196,13 @@ class ModelStageFactory:
|
|
|
218
196
|
|
|
219
197
|
def build_pipeline_and_modules(
|
|
220
198
|
self
|
|
221
|
-
) -> tuple[PipelineScheduleInfo
|
|
199
|
+
) -> tuple[PipelineScheduleInfo, TrackedModules]:
|
|
222
200
|
"""
|
|
223
201
|
Constructs the execution schedule and the model container.
|
|
224
202
|
|
|
225
|
-
If pipeline parallelism is enabled, this orchestrates the creation of a
|
|
226
|
-
distributed pipeline schedule.
|
|
227
|
-
|
|
228
|
-
Otherwise, it simply builds a standalone model stage.
|
|
229
|
-
|
|
230
203
|
Returns:
|
|
231
|
-
The pipeline schedule information
|
|
204
|
+
The pipeline schedule information.
|
|
232
205
|
The `TrackedModules` instance wrapping the created model stage(s).
|
|
233
|
-
|
|
234
|
-
Raises:
|
|
235
|
-
ValueError: If pipelining configuration is missing but a pipeline is requested.
|
|
236
206
|
"""
|
|
237
207
|
|
|
238
208
|
if self._config_model.checkpoint_only_trainable_parameters:
|
|
@@ -240,22 +210,12 @@ class ModelStageFactory:
|
|
|
240
210
|
else:
|
|
241
211
|
stateful_predicate = _stateful_predicate_always
|
|
242
212
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
dist_context=self._dist_context,
|
|
251
|
-
n_microbatches=self._batch_maths.num_microbatches_pipelining,
|
|
252
|
-
schedule_config=self._config_pipelining.schedule,
|
|
253
|
-
model_provider=self._build_model_stage,
|
|
254
|
-
loss_fn=loss_fn
|
|
255
|
-
)
|
|
256
|
-
|
|
257
|
-
return schedule, TrackedModules(self._dist_context, modules, stateful_predicate)
|
|
258
|
-
else:
|
|
259
|
-
model = self._build_model_stage(PipelineStageInfo(num_stages=1, current_stage=0))
|
|
213
|
+
schedule, modules = build_schedule(
|
|
214
|
+
dist_context=self._dist_context,
|
|
215
|
+
n_microbatches=self._batch_maths.num_microbatches_pipelining,
|
|
216
|
+
schedule_config=self._config_pipelining.schedule,
|
|
217
|
+
model_provider=self._build_model_stage,
|
|
218
|
+
callback=self._pipeline_callback
|
|
219
|
+
)
|
|
260
220
|
|
|
261
|
-
|
|
221
|
+
return schedule, TrackedModules(self._dist_context, modules, stateful_predicate)
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
from typing import Generic, TypeVar
|
|
3
|
+
|
|
1
4
|
import torch
|
|
2
5
|
|
|
3
6
|
from d9d.internals.pipeline_state import PipelineStateHandler
|
|
4
|
-
from d9d.loop.control import ComputeLossContext, TrainTask
|
|
7
|
+
from d9d.loop.control import ComputeLossContext, InferenceTask, ProcessOutputsContext, TrainTask
|
|
5
8
|
|
|
6
9
|
from .stepper import Stepper
|
|
7
10
|
|
|
@@ -9,7 +12,20 @@ STATE_LOSS = "__internal_loss"
|
|
|
9
12
|
STATE_LOSS_WEIGHT = "__internal_loss_weight"
|
|
10
13
|
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
TOutput = TypeVar("TOutput")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class PipelineOutputsProcessor(abc.ABC, Generic[TOutput]):
|
|
19
|
+
@abc.abstractmethod
|
|
20
|
+
def __call__(
|
|
21
|
+
self,
|
|
22
|
+
pipeline_outputs: dict[str, torch.Tensor],
|
|
23
|
+
microbatch_idx: int
|
|
24
|
+
) -> TOutput:
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class LossComputer(PipelineOutputsProcessor[torch.Tensor]):
|
|
13
29
|
"""
|
|
14
30
|
Handles the computation of loss values and their integration into the pipeline state.
|
|
15
31
|
|
|
@@ -38,10 +54,10 @@ class LossComputer:
|
|
|
38
54
|
self._task = task
|
|
39
55
|
self._stepper = stepper
|
|
40
56
|
|
|
41
|
-
def
|
|
57
|
+
def __call__(
|
|
42
58
|
self,
|
|
43
59
|
pipeline_outputs: dict[str, torch.Tensor],
|
|
44
|
-
microbatch_idx: int
|
|
60
|
+
microbatch_idx: int
|
|
45
61
|
) -> torch.Tensor:
|
|
46
62
|
"""
|
|
47
63
|
Computes the weighted loss for a specific sharded microbatch or the full microbatch.
|
|
@@ -61,12 +77,9 @@ class LossComputer:
|
|
|
61
77
|
The calculated loss multiplied by its weight.
|
|
62
78
|
"""
|
|
63
79
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
state = self._state.sharded_state(
|
|
68
|
-
shard_id=microbatch_idx
|
|
69
|
-
)
|
|
80
|
+
state = self._state.sharded_state(
|
|
81
|
+
shard_id=microbatch_idx
|
|
82
|
+
)
|
|
70
83
|
|
|
71
84
|
computation = self._task.compute_loss(ComputeLossContext(
|
|
72
85
|
pipeline_results=pipeline_outputs,
|
|
@@ -84,3 +97,53 @@ class LossComputer:
|
|
|
84
97
|
state[STATE_LOSS_WEIGHT] = loss_weight[None]
|
|
85
98
|
|
|
86
99
|
return loss * loss_weight
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class InferenceProcessor(PipelineOutputsProcessor[None]):
|
|
103
|
+
"""
|
|
104
|
+
Handles the processing of model outputs during inference or evaluation.
|
|
105
|
+
|
|
106
|
+
This component retrieves the appropriate state context
|
|
107
|
+
and delegates the output processing logic to the user-defined inference task.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
def __init__(
|
|
111
|
+
self,
|
|
112
|
+
state: PipelineStateHandler,
|
|
113
|
+
task: InferenceTask
|
|
114
|
+
):
|
|
115
|
+
"""
|
|
116
|
+
Constructs a new ModelOutputsProcessor.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
state: Handler for managing global and sharded pipeline states.
|
|
120
|
+
task: The user-defined inference task containing processing logic.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
self._state = state
|
|
124
|
+
self._task = task
|
|
125
|
+
|
|
126
|
+
def __call__(
|
|
127
|
+
self,
|
|
128
|
+
pipeline_outputs: dict[str, torch.Tensor],
|
|
129
|
+
microbatch_idx: int
|
|
130
|
+
) -> None:
|
|
131
|
+
"""
|
|
132
|
+
Processes model outputs for a specific microbatch or full batch.
|
|
133
|
+
|
|
134
|
+
This method retrieves the relevant state (scoped by microbatch index if provided)
|
|
135
|
+
and invokes the task's output processing logic.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
pipeline_outputs: Dictionary containing model output tensors.
|
|
139
|
+
microbatch_idx: Index of the current microbatch, or None if not using microbatching.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
state = self._state.sharded_state(
|
|
143
|
+
shard_id=microbatch_idx
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
self._task.process_outputs(ProcessOutputsContext(
|
|
147
|
+
pipeline_results=pipeline_outputs,
|
|
148
|
+
state=state
|
|
149
|
+
))
|