JohnCage's picture
Upload folder using huggingface_hub
8a2fd95 verified
Raw History Blame Contribute Delete
1.27 kB
import sys
from pathlib import Path
project_root = Path(__file__).parent.parent
sys.path.append(str(project_root))
if __name__ == "__main__":
# Keep CUDA/model imports out of multiprocessing worker module imports.
# Only the torchrun training ranks execute these registrations.
import thinkstream.model.patch # noqa: F401
from thinkstream.model.streaming_attention import register_streaming_attention
from thinkstream.trainer.builder import TRAINER_BUILDERS
register_streaming_attention()
if len(sys.argv) < 2:
print("Usage: torchrun ... train.py <builder_name> [args...]")
print(f"Available builders: {list(TRAINER_BUILDERS.keys())}")
sys.exit(1)
builder_name = sys.argv[1]
try:
# Retrieve the builder from the registry
builder_fn = TRAINER_BUILDERS.get(builder_name)
except KeyError:
print(f"Error: Unknown builder '{builder_name}'.")
print(f"Available builders: {list(TRAINER_BUILDERS.keys())}")
sys.exit(1)
# Build the train node
train_node = builder_fn()
# Parse CLI arguments, validate Arg inputs, prepare, and execute the pipeline.
train_node.run(
use_argparse=True,
cli_args=sys.argv[2:],
)
print(train_node)