Buckets:
| import argparse | |
| import math | |
| from pathlib import Path | |
| import yaml | |
| def estimate_params(hidden, layers, vocab, intermediate): | |
| embeddings = vocab * hidden | |
| transformer = layers * ( | |
| 4 * hidden * hidden + | |
| 2 * hidden * intermediate | |
| ) | |
| return embeddings + transformer | |
| def round_multiple(value, multiple=64): | |
| return int(math.ceil(value / multiple) * multiple) | |
| def generate_config(target_params): | |
| vocab = 32000 | |
| if target_params <= 500_000_000: | |
| hidden = 1280 | |
| layers = 20 | |
| elif target_params <= 700_000_000: | |
| hidden = 1536 | |
| layers = 24 | |
| elif target_params <= 1_000_000_000: | |
| hidden = 2048 | |
| layers = 24 | |
| else: | |
| hidden = 2560 | |
| layers = 28 | |
| intermediate = round_multiple(hidden * 4) | |
| while estimate_params(hidden, layers, vocab, intermediate) < target_params: | |
| hidden += 64 | |
| intermediate = round_multiple(hidden * 4) | |
| heads = hidden // 128 | |
| config = { | |
| "model": { | |
| "vocab_size": vocab, | |
| "hidden_size": hidden, | |
| "intermediate_size": intermediate, | |
| "num_hidden_layers": layers, | |
| "num_attention_heads": heads, | |
| "max_position_embeddings": 4096, | |
| "dropout": 0.0, | |
| "rope_theta": 10000.0, | |
| }, | |
| "training": { | |
| "epochs": 10, | |
| "batch_size": 1, | |
| "learning_rate": 1e-4, | |
| "weight_decay": 0.01, | |
| "block_size": 512, | |
| "checkpoint_interval": 100, | |
| "gradient_accumulation_steps": 32, | |
| "warmup_steps": 1000, | |
| }, | |
| "system": { | |
| "device": "auto", | |
| "torch_threads": 4, | |
| }, | |
| } | |
| return config, estimate_params(hidden, layers, vocab, intermediate) | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument( | |
| "--params", | |
| type=float, | |
| default=1.0, | |
| help="Objetivo en miles de millones (ej: 1.0 = 1B)", | |
| ) | |
| parser.add_argument( | |
| "--output", | |
| default="configs/marslm-auto.yaml", | |
| ) | |
| args = parser.parse_args() | |
| target = int(args.params * 1_000_000_000) | |
| config, estimated = generate_config(target) | |
| output = Path(args.output) | |
| output.parent.mkdir(parents=True, exist_ok=True) | |
| with output.open("w", encoding="utf-8") as f: | |
| yaml.safe_dump(config, f, sort_keys=False) | |
| print(f"Archivo generado: {output}") | |
| print(f"Parámetros aproximados: {estimated:,}") | |
| if __name__ == "__main__": | |
| main() |
Xet Storage Details
- Size:
- 2.66 kB
- Xet hash:
- 41e5dca5189c80d9b8fb7a4336cd2b9bce073b57ca7cefc132a7d9ae1489f9d1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.