# Current run: GPU 2 with a compute-process guard `bash run_training.sh` starts `gpu2_supervisor.py`, which launches only on physical GPU 2, selected by its NVIDIA UUID. The current microbatch is 8 with 4 accumulation steps on one GPU, preserving the effective batch size of 32. The training parameters, eligible data, content limit, and evaluation schedule remain unchanged. The previous DDP launcher is saved as `run_training.ddp.sh`. The guard polls compute processes every 0.5 seconds. It protects the training process and its descendants, and sends SIGTERM to other compute processes on GPU 2, followed by SIGKILL after two seconds if they remain. This includes unrelated jobs owned by `priya`. It does not target graphics processes or compute processes attached only to other GPUs. Actions are logged in `gpu2_guard.log`. The guard runs with `priya`'s OS permissions. This account cannot enable exclusive compute mode, and cannot signal protected processes owned by other users. If such a process blocks GPU 2, the supervisor stops this experiment and waits for the blocker to leave. Polling is not a hardware reservation; another process can briefly allocate memory before detection. Full recovery checkpoints are saved after update 1 and every 10 updates, including optimizer, scheduler, RNG, and Trainer state. Evaluation and normal best-model selection still occur every 100 steps. A completion marker written after each successful save prevents resuming partial checkpoints. After a failure the supervisor retries up to three times, resuming the newest complete checkpoint; on out-of-memory errors it halves the microbatch and increases accumulation to retain batch size 32. Progress is marked failed if retries run out. Guarding stops when training completes or the supervisor is stopped. Current output directory: `/22tdata/priya/qwen_unsloth/outputs/Qwen38-27B-3shotTrained-GPU2`. The final model and tokenizer go to its `final_model` subdirectory. `training.log` links to the active attempt log in `run_logs/`. Inspect `training_progress.json`, `training_launch.json`, and `gpu2_supervisor.json` for current state. The active supervisor was launched in a detached process and does not depend on the agent/chat remaining open. # Previous DDP optimization The original script is preserved as `train_qwen38-3S.original.py`. The initial single-GPU script and launcher are preserved as `train_qwen38-3S.single_gpu.py` and `run_training.single_gpu.sh`. The project `.venv` uses the existing geocoding environment's packages as a base, with project-local overrides. Other environments are not modified. Launch with `bash run_training.sh`. The launcher selects physical GPUs 2 and 3 and places downloads, caches and model output under `/22tdata/priya/qwen_unsloth`. The configured training runs for up to five epochs, with early stopping. Each GPU handles 4 examples per microbatch. Four accumulation steps retain the original effective batch size: 4 x 2 GPUs x 4 accumulation steps = 32. For the background run, inspect `training.log`, `training_launch.json`, and `training_progress.json` in this directory. Progress JSON includes optimizer steps and a measured remaining time after the first two steps. The estimate includes periodic evaluation after the first evaluation finishes. Initial compilation, checkpoints, and final saving can add overhead. Final adapters and tokenizer are saved to: `/22tdata/priya/qwen_unsloth/outputs/Qwen38-27B-3shotTrained-DDP/final_model`. The base model is kept in the Hugging Face cache on the same data drive. The script now uses the CSV in this directory, the current TRL configuration API, and Unsloth's `FastModel` loader for this hybrid architecture. It loads the official Unsloth prequantized 4-bit variant with bfloat16 computation, and skips the unused vision tower. Sequence packing stays disabled for this hybrid linear-attention architecture to preserve independent recurrent states. Distributed training normalizes response losses using token counts aggregated across devices. Randomized length grouping reduces training padding while retaining the eligible dataset and objective. Validation explicitly retains sequential ordering and the initial per-device batch size of 4. Fused causal convolution is built locally for this host's glibc and CUDA 11.8 PyTorch. `verify_kernels.py` checks outputs and input/weight/bias gradients against PyTorch in float32 and bfloat16, including the model's tensor layout. The local kernel shows an incorrect gradient at an unaligned sequence boundary. Production batches pad to multiples of 8, and verification checks the padded kernel against unpadded reference outputs/gradients across boundary lengths. Padding labels stay masked; the 1,730-token content limit is unchanged. `verify_distributed.py` checks NCCL communication and distributed gradient normalization against a single-GPU reference on a small controlled problem. Epoch count, learning rate, LoRA rank/alpha/dropout, response-only masks, checkpoint/evaluation cadence, early stopping and maximum sequence length retain their original settings. Different example order and distributed arithmetic do not guarantee bitwise-identical optimization trajectories. This script evaluates teacher-forced validation loss. It has no generation stage for vLLM to accelerate. At the original 1,730-token limit, Unsloth excludes 194 training examples and 26 validation examples whose assistant response was truncated entirely. The full five-epoch run therefore has 23,122 training examples and 3,615 optimizer steps. There are 2,892 eligible validation examples. The original sequence limit is retained for this performance comparison. Microbatch size and accumulation can be overridden with `TRAIN_BATCH_SIZE` and `TRAIN_GRAD_ACC`; their product times the GPU count must equal 32. Only global rank zero writes progress and final metadata. The output directory's `runtime_config.json` records actual dataset counts and effective batch size. The initial single-GPU log and throughput are archived for comparison. Resume an interrupted run by setting `TRAIN_RESUME_CHECKPOINT` to an existing checkpoint directory before launching. Do not launch a second copy while the current process is running.