#!/bin/bash

echo "============================================================"
echo "Testing Text Loss Basic Functionality"
echo "============================================================"
echo ""
echo "Configuration:"
echo "- Task: text2music (default)"
echo "- Text loss: ON"
echo "- Continuous embeddings: OFF"
echo "- Testing text reconstruction during training"
echo "- Iterations: 5 (quick test)"
echo ""

cd /home/vibert/projects/neon-sunogpt-captioning/sunoGPT

CUDA_VISIBLE_DEVICES=7 /home/vibert/anaconda3/envs/suno_3/bin/python -u train.py \
    --out_dir=/app2/suno/checkpoints/text_loss_test \
    --data_dir=/app2/suno/data/auk_v0 \
    --train_metas_filename=metas_v1_tr_mini.jsonl \
    --val_metas_filename=metas_v3_val.jsonl \
    --step_save_iters=100000 \
    --eval_interval=25 \
    --eval_iters=2 \
    --batch_store_size=1 \
    --n_layer=2 \
    --n_head=16 \
    --d_head=64 \
    --learning_rate=1e-4 \
    --max_iters=50 \
    --warmup_iters=1 \
    --batch_size=1 \
    --grad_checkpointing=False \
    --compile=False \
    --use_text_loss=True \
    --prob_text_loss=1.0 \
    --use_hoot=False \
    --use_ditto=False \
    --fsdp=False \
    --checkpoint_save_old_format=False \
    --wandb_log=False \
    2>&1 | tee /home/vibert/logs/$(date +%Y-%m-%d)/test_text_loss_$(date +%H%M%S).log

echo ""
echo "============================================================"
echo "Test completed!"
echo "Log saved to: /home/vibert/logs/$(date +%Y-%m-%d)/test_text_loss_*.log"
echo "Check output for:"
echo "  - text_output loss values (should appear ~100% of time with prob=1.0)"
echo "  - Text blocks with targets when text_is_post=True"
echo "  - Text inference token prepending in text generation"
echo "============================================================"