Files
qwen3-6-lora/requirements.train.txt
T
aleleba 63da20c031 Phase 6.2: pin the training environment and make 10_train.py configurable
The training container from phases 3-5 no longer exists and nothing in the
repo pinned its versions, so a rebuild could silently change either the
checkpoint key conversion (breaking adapter naming) or the assistant-mask
behaviour (training on system/user/tool tokens). requirements.train.txt
pins what matters and documents the two-phase install: llmcompressor
declares torch>=2.10.0 and the NGC image ships the 2.10.0a0 pre-release,
which pip's resolver reads as older, so it goes in with --no-deps.

Pre-flight verified against the merged bf16 checkpoint on spark:
01_inspect_modules.py prints model.layers.0.linear_attn.*, config.json is
sha256-identical to the base (93a4693f...), and the index keysets match
exactly (1045 tensors, 690 under model.language_model.layers.*, 0 under
model.layers.*). So PEFT will name adapter #2 the same way it named #1 and
ADAPTER_TO_CHECKPOINT_PREFIX in 20_merge_lora.py applies unchanged.

10_train.py: every path and hyperparameter moves to an env var, with the
phase 3 values as defaults so a bare run still reproduces phase 3 exactly.
Adds three guards that each cover a specific silent failure:
- abort if OUTPUT_DIR already holds an adapter, unless ALLOW_OVERWRITE=1.
  OUTPUT_DIR was hardcoded to out/lora-adapter, which is the provenance of
  the model currently in production.
- MAX_TOKENS aborts rather than truncates. There was no length filter at
  all, so one long design trajectory would blow the memory budget hours
  into a run; truncating would be worse, since it would silently cut
  assistant targets.
- assert use_rslora/use_dora/bias/modules_to_save. rsLoRA scales by
  alpha/sqrt(r), so an adapter trained with it would merge at 2.0 where
  11.3 belongs and pass every assertion in the merge script.
Also adds a config banner, a token-length histogram, and a per-bucket
assistant-mask ratio report.

New 07_lint_penpot_code.py hard-fails on the forbidden API patterns,
placeholder greys, fabricated penpot_api_info results, toy-shaped ids and
per-category coverage shortfalls. Error-recovery seeds legitimately need
the wrong pattern, so the exemption is derived mechanically rather than
declared by hand: a payload may contain a forbidden pattern only if its
tool result is a real error string from the allow-list and a later payload
in the same seed does the same thing without it.

Run against the 41 existing seeds it reproduces the diagnosis exactly:
110 problems, 36 unique payloads, 0% system messages, zero coverage of
addGridLayout/shadows/uploadMediaUrl/layoutChild, fabricated docs and
toy ids.
2026-07-30 17:01:41 +00:00

73 lines
3.9 KiB
Plaintext

# Dependencias del contenedor de entrenamiento `qwen-lora-train` (docker-compose.yml).
#
# Por que existe este archivo (Fase 6, riesgo #3 del plan): el contenedor de las Fases 3-5
# fue borrado y NADA en el repo fijaba estas versiones. Todo el estado de pip se perdio.
# Una version distinta de transformers puede cambiar la conversion de claves del checkpoint
# (-> los nombres del adapter dejan de matchear lo que espera 20_merge_lora.py) o el
# comportamiento de return_assistant_tokens_mask (-> el masking de 10_train.py entrena
# sobre tokens de system/user/tool sin avisar). Las dos fallas son silenciosas.
#
# Instalar con:
# docker exec qwen-lora-train pip install -c /workspace/ai-projects/qwen3-6-lora/constraints.txt \
# -r /workspace/ai-projects/qwen3-6-lora/requirements.train.txt
#
# El `-c constraints.txt` es obligatorio: fija torch al build de NGC que trae la imagen
# (nvcr.io/nvidia/pytorch:25.12-py3, aarch64/GB10). Sin el, cualquiera de estos paquetes
# puede arrastrar un torch de PyPI que no tiene el runtime CUDA de la imagen.
#
# Verificacion de que la instalacion quedo bien, antes de gastar una corrida:
# 1. 01_inspect_modules.py sobre el checkpoint merged imprime `model.layers.*`
# (no `model.language_model.layers.*`)
# 2. el `trainable%` del smoke run de 2 pasos iguala al de la Fase 3
# Ambos estan en el runbook de la fase (pasos 6.2.7 y 6.4.20).
transformers==5.14.1
peft==0.19.1
# Cuantizacion NVFP4 (21_quantize_nvfp4.py). llmcompressor 0.12.0 es la version con la que
# se produjo el checkpoint que esta hoy en produccion.
llmcompressor==0.12.0
accelerate
datasets
compressed-tensors
safetensors
# bitsandbytes: lo necesita optim="adamw_8bit" en 10_train.py. Sin el, TrainingArguments
# falla al construir el optimizador, ya adentro de la corrida.
bitsandbytes
# NOTA: las cinco ultimas quedan sin pinear a proposito. Son aarch64/GB10 y no todas
# publican wheel para toda version; pinear a ciegas rompe la instalacion en vez de fijarla.
# Las versiones REALMENTE resueltas quedan registradas abajo.
#
# ORDEN DE INSTALACION -- NO es un solo `pip install -r`.
# ---------------------------------------------------------------------------------
# llmcompressor 0.12.0 declara `torch<=2.12.0,>=2.10.0`, y el torch de la imagen NGC es el
# pre-release `2.10.0a0+b4e4ee81d3.nv25.12`. Para el resolvedor de pip un `a0` es ANTERIOR a
# 2.10.0, asi que la restriccion no se satisface y el install entero falla con
# ResolutionImpossible -- aunque el torch instalado sea perfectamente funcional. Por eso
# llmcompressor y compressed-tensors se instalan con --no-deps y sus dependencias reales
# (que no son torch) se instalan aparte:
#
# C=/workspace/ai-projects/qwen3-6-lora/constraints.txt
# pip install --no-cache-dir -c $C transformers==5.14.1 peft==0.19.1 accelerate datasets \
# bitsandbytes safetensors
# pip install --no-cache-dir --no-deps llmcompressor==0.12.0 compressed-tensors
# pip install --no-cache-dir -c $C loguru pydantic tqdm numpy pillow requests
#
# Verificacion (los dos invariantes del riesgo #3 del plan de fase), ya corrida en 6.2.7:
# - 01_inspect_modules.py sobre el merged imprime `model.layers.0.linear_attn.*` [OK]
# - config.json del merged sha256-identico al del base (93a4693fa9d8392f...) [OK]
# - keysets del index identicos: 1045 tensores, 690 bajo model.language_model.* [OK]
# - el `trainable%` del smoke run iguala al de la Fase 3 [paso 6.4.20]
#
# VERSIONES RESUELTAS (pip freeze del contenedor, Fase 6, 2026-07-30):
# torch==2.10.0a0+b4e4ee81d3.nv25.12 (de la imagen, via constraints.txt)
# transformers==5.14.1 tokenizers==0.22.1
# peft==0.19.1 accelerate==1.14.0
# datasets==4.4.1 bitsandbytes==0.50.0
# llmcompressor==0.12.0 compressed-tensors==0.17.1
# safetensors==0.8.0 numpy==2.1.0
# loguru==0.7.3 pydantic==2.12.5