### 0
pkill -9 sglang; sleep 3; ray stop
  --force; pkill -9 ray; pkill -9 miles; sleep 3; pkill -9 ray; pkill -9 miles; pkill -9 redis; true; 

### 1
export PYTHONUNBUFFERED=1 && ray start
  --head
  --node-ip-address 127.0.0.1
  --num-gpus 4
  --disable-usage-stats

### 2
nvidia-smi topo -m 2>/dev/null | grep -o 'NV[0-9][0-9]*' | wc -l

### 3
export no_proxy=127.0.0.1 && export PYTHONUNBUFFERED=1 && ray job submit
  --address="http://127.0.0.1:8265"
  --runtime-env-json='{"env_vars": {"PYTHONUNBUFFERED": "1", "CUDA_DEVICE_MAX_CONNECTIONS": "1", "NCCL_NVLS_ENABLE": "0", "no_proxy": "127.0.0.1,127.0.0.1", "MASTER_ADDR": "127.0.0.1", "SGLANG_HEALTH_CHECK_TIMEOUT": "120", "SGLANG_DISABLE_MULTIMEM_AG": "1", "PYTHONPATH": "<REPO_ROOT>:/root/Megatron-LM:/frozen/pythonpath", "TORCHINDUCTOR_COMPILE_THREADS": "1"}}'
  -- python3 <REPO_ROOT>/train.py
  --spec miles_plugins.models.qwen3_8_next.qwen3_8_next get_qwen3_8_next_spec
  --disable-bias-linear
  --qk-layernorm
  --group-query-attention
  --num-attention-heads 24
  --num-query-groups 2
  --kv-channels 256
  --num-layers 48
  --hidden-size 2560
  --ffn-hidden-size 640
  --normalization RMSNorm
  --apply-layernorm-1p
  --position-embedding-type rope
  --norm-epsilon 1e-6
  --rotary-percent 0.25
  --swiglu
  --untie-embeddings-and-output-weights
  --vocab-size 248320
  --rotary-base 10000000
  --moe-ffn-hidden-size 640
  --moe-shared-expert-intermediate-size 640
  --moe-router-score-function softmax
  --moe-token-dispatcher-type alltoall
  --moe-router-topk 10
  --moe-layer-freq '[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]'
  --num-experts 512
  --moe-grouped-gemm
  --moe-token-drop-policy probs
  --moe-router-dtype fp32
  --moe-permute-fusion
  --moe-aux-loss-coeff 0
  --attention-output-gate
  --moe-shared-expert-gate
  --hf-checkpoint /root/models/Qwen3.8-Flash-Next
  --ref-load /root/ckpt/qwen3.8-flash-next_torch_dist 
  --label-key label
  --apply-chat-template
  --rollout-shuffle
  --rm-type math
  --num-rollout 5
  --rollout-batch-size 4
  --n-samples-per-prompt 8
  --rollout-temperature 0.8
  --num-steps-per-rollout 1
  --balance-data
  --prompt-data /root/datasets/dapo-math-17k/dapo-math-17k.jsonl
  --input-key prompt
  --rollout-max-response-len 4096
  --apply-chat-template-kwargs '{"thinking_mode":"thinking"}' 
  --optimizer adam
  --lr 1e-6
  --lr-decay-style constant
  --weight-decay 0.1
  --adam-beta1 0.9
  --adam-beta2 0.98 
  --advantage-estimator grpo
  --kl-loss-coef 0.00
  --kl-loss-type low_var_kl
  --entropy-coef 0.00
  --eps-clip 0.2
  --eps-clip-high 0.28 
  --use-wandb
  --wandb-project miles-run_qwen3_8_next
  --wandb-group 260101-000000-000
  --wandb-key 'frozen-wandb-api-key'
  --disable-wandb-random-suffix 
  --tensor-model-parallel-size 2
  --sequence-parallel
  --pipeline-model-parallel-size 8
  --context-parallel-size 1
  --expert-model-parallel-size 4
  --expert-tensor-parallel-size 1
  --recompute-granularity full
  --recompute-method uniform
  --recompute-num-layers 1
  --micro-batch-size 1
  --max-tokens-per-gpu 8192 
  --rollout-num-gpus-per-engine 8
  --sglang-tp-size 8
  --sglang-ep-size 8
  --sglang-linear-attn-prefill-backend flashinfer
  --sglang-moe-runner-backend triton
  --sglang-chunked-prefill-size 8192
  --sglang-disable-radix-cache
  --router-health-success-threshold 1
  --router-health-check-interval-secs 15
  --router-health-failure-threshold 40 
  --attention-dropout 0.0
  --hidden-dropout 0.0
  --attention-softmax-in-fp32
  --accumulate-allreduce-grads-in-fp32
  --update-weight-buffer-size 1073741824
  --actor-num-nodes 8
  --actor-num-gpus-per-node 4
  --num-gpus-per-node 4
  --train-memory-margin-bytes 3221225472
  --offload-train-target disk
  --offload-train-disk-dir /root/train_offload
  --sglang-mem-fraction-static 0.7
  --colocate
  --model-name qwen4_exp
  --qkv-format thd
  --linear-attention-backend flashqla
  --custom-model-provider-path miles_plugins.models.qwen3_8_next.model_provider.get_qwen3_8_next_model_provider
  --rollout-health-check-interval 300
  --distributed-timeout-minutes 60
  --rollout-health-check-timeout 300
  --check-weight-update-equal
  --check-weight-update-skip-list visual. ple_embedding.   
  --deploy-component all
