Skip to content

Custom/sft base 1gpu - #122

Open
jajqja wants to merge 6 commits into
Tencent-Hunyuan:mainfrom
jajqja:custom/sft-base-1gpu
Open

jajqja wants to merge 6 commits into
Tencent-Hunyuan:mainfrom
jajqja:custom/sft-base-1gpu

Conversation

@jajqja

@jajqja jajqja commented Aug 17, 2026

Copy link
Copy Markdown

No description provided.

jajqja and others added 6 commits August 17, 2026 11:33
data/, output/ and HunyuanOCR/ are produced on the training box and are
several GB once packing and checkpointing run; none of it belongs in git.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The three launchers built their flags into $args and then passed them as
"${args}". Quoted, the whole block reaches the entry point as ONE argv
element, so HfArgumentParser.parse_args_into_dataclasses() aborts before
training starts:

    $ A="--x 1 --y 2"; python -c "import sys;print(sys.argv[1:])" "${A}"
    ['--x 1 --y 2']

$args is assembled inside double quotes, where backslash-newline is a line
continuation, so it is already a single flat line. Dropping the quotes lets
normal word splitting hand each flag over separately.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The counter dropped every line whose answer was empty:

    if not question or not answer:
        return None

For an OCR dataset an empty label is not missing data — it is the label of a
blank page, and it is what teaches the model to return nothing instead of
hallucinating text onto a sheet that carries none. Our set has 25 such pages
and silently losing them trains the opposite behaviour.

Empty answers are still skipped by default so upstream behaviour is unchanged;
pack_data.sh opts in via ALLOW_EMPTY=1 (its default). pack_data.sh also grows
FOREGROUND=1 to run in the foreground, which is what you want on a single box.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reads <root>/<config>/<split>/metadata.jsonl + images and emits the schema the
code actually consumes:

    {"img_path_sh": "/abs/x.jpg", "conv": [{"question": <prompt>, "answer": <md>}]}

Note this is NOT the schema in docs/data_format.md, which documents
image_path/conversations and a packed_samples/cu_seqlens output. No code in
the repo reads those keys — pipeline_count_and_pack.py reads
img_path_sh|img_path_cq + conv[0].question|answer, and data_processor.py reads
item["image"]/["question"]/["answer"] with one JSON array per packed line.

The prompt goes in `question` rather than a system message on purpose:
pack_data() never forwards `system` into the packed record, so a system prompt
is counted at pack time and then absent at train time.

Run over the 4-config Vietnamese OCR set: 1007 train / 120 validation,
0 missing images, 25 empty labels preserved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sft_base.sh targets an 8-GPU node behind InfiniBand. env_common.sh pins NCCL
to a bond1 interface and eight mlx5 HCAs, which do not exist on a single box,
so NCCL warns loudly or stalls at rendezvous. env_single.sh disables IB, keeps
NCCL on loopback, and sets expandable_segments to limit fragmentation as
activation size swings between packs.

sft_base_1gpu.sh retunes the same entry point for one 80GB card and a ~1k-page
domain set rather than a cluster and ~1M packs:

    NPROC_PER_NODE     8     -> 1
    packed_max_length  20480 -> 16384   (docs/training.md notes 20480 can OOM at 80GB)
    GRAD_ACCUM         1     -> 4       (one pack per step is too noisy a batch)
    SAVE_STEPS         200   -> 50      (an epoch here is well under 200 steps)

A 1B model in bf16 with gradient checkpointing fits full SFT at 80GB without
ZeRO, so DeepSpeed stays off and is opt-in via DEEPSPEED=scripts/zero2.json.
TUNE_VISION/TUNE_MLP/TUNE_LLM, PACK_LEN, LR, EPOCHS and RUN_NAME are all
env-overridable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
End-to-end steps for this fork: environment, dataset conversion, packing,
training, and the parts of upstream that need care —

  - flash-attn is mandatory; train_hunyuan.py hardcodes flash_attention_2
    with no eager fallback, so it fails at model load, not at step 1.
  - Do not enable eval during training: eval_dataset is built with
    is_packed=False while the collator is PackedVLDataCollator, which expects
    a list of lists.
  - PACK_LEN must match between packing and training.
  - docs/data_format.md documents a schema no code reads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant