Skip to content

Distributed tests for flux and wan with pytorch_xdit image - #359

Open
amd-droy wants to merge 74 commits into
mainfrom
dr/xdit
Open

Distributed tests for flux and wan with pytorch_xdit image#359
amd-droy wants to merge 74 commits into
mainfrom
dr/xdit

Conversation

@amd-droy

Copy link
Copy Markdown
Contributor

### Files Updated

New test suites:

cvs/tests/inference/pytorch_xdit/pytorch_xdit_flux1_dev_distributed.py — Multi-node FLUX.1-dev distributed benchmark: container cleanup, model verification, parallelism validation, unified torchrun launch, rank-0 result parsing, and threshold checks.
cvs/tests/inference/pytorch_xdit/pytorch_xdit_wan22_14b_distributed.py — Same pattern for WAN 2.2 I2V-A14B distributed inference.

New library modules:

cvs/lib/inference/pytorch_xdit/pytorch_xdit_flux_job.py — Shared FLUX benchmark launcher: NCCL env construction, torchrun command building, distributed log verification, fatal-output scanning, benchmark failure excerpt logging, and launch_flux_benchmark() entry point.
cvs/lib/inference/pytorch_xdit/pytorch_xdit_wan_job.py — WAN equivalent launcher with parallelism validation, shared output directory handling for rank-0, and launch_wan_benchmark() entry point.
cvs/lib/inference/pytorch_xdit/pytorch_xdit_flux.py — Moved FLUX output parser from cvs/parsers/; adds FluxOutputParser, log_results_summary() for multi-node result logging.
cvs/lib/inference/pytorch_xdit/pytorch_xdit_wan.py — Moved WAN output parser; adds WanOutputParser with multi-run aggregation under a shared output base directory.

Sample configs:

cvs/input/config_file/inference/pytorch_xdit/mi300x_pytorch_xdit_flux1_dev_distributed.json — Distributed FLUX template with nnodes, rendezvous, NCCL IB/socket settings, and ulysses_degree / ring_degree.
cvs/input/config_file/inference/pytorch_xdit/mi300x_pytorch_xdit_wan22_14b_distributed.json — Distributed WAN template with matching parallelism and NCCL fields.

Schema and validation:

cvs/parsers/schemas.py — Extended PytorchXditFluxConfig and PytorchXditWanConfig with distributed fields (nnodes, master_addr, master_port, NCCL IB/socket/GLOO settings); added PytorchXditDistributedNcclExamples base for example* NCCL hint fields in sample JSONs; added WAN ulysses_size / ring_size and FLUX ulysses_degree / ring_degree benchmark params.

Existing test touch-ups:

cvs/tests/inference/pytorch_xdit/pytorch_xdit_flux1_dev_single.py — Import parser from lib; use shared log_results_summary() for multi-node scale-out summary.
cvs/tests/inference/pytorch_xdit/pytorch_xdit_wan22_14b_single.py — Import WanOutputParser from lib instead of cvs/parsers/.

Unit tests:

cvs/lib/inference/pytorch_xdit/unittests/test_pytorch_xdit_flux.py — Tests for log_results_summary().
cvs/lib/inference/pytorch_xdit/unittests/test_pytorch_xdit_wan_job.py — Tests for WAN parallelism validation, torchrun command construction, and benchmark failure excerpt logging.
cvs/parsers/unittests/test_pytorch_xdit_schemas.py — Tests for distributed xDiT config schema validation including example* NCCL fields.

@amd-droy amd-droy changed the title Dr/xdit Distributed tests for flux and wan with pytorch_xdit image Aug 20, 2026

@speriaswamy-amd speriaswamy-amd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this @amd-droy , overall, the PR looks good, but couple of changes could be done to improve resilience

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do

  • RCCL env construction
  • torchrun/docker command building
  • launch planning
  • parallelism validation
  • run()

We need to add corresponding unit tests for these functions

@amd-droy amd-droy Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add unit tests for wan output parsing logic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the tests.


phdl_hosts = list(getattr(s_phdl, "host_list", []) or [])
if phdl_hosts == node_list:
return s_phdl.exec_cmd_list(commands, timeout=timeout, print_console=print_console) or {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exit codes are only returned when detailed=True is passed in

@amd-droy amd-droy Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed. The exec_cmd_list fast path is only used when detailed=False; benchmark run() uses detailed=True and gates on exit_code != 0.

failed_nodes = []
for node in plan.node_order:
output = (results or {}).get(node, "")
if scan_fatal_output(output):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scan_fatal_output/scan_wan_fatal_output only flags a run as failed if the captured text contains one of ~6 known substrings (Traceback, ModuleNotFoundError, ChildFailedError, OSError:, plus two WAN-specific GPU-driver strings) we would silently pass hardware, HIP, ROCm failures, segfaults, etc. we should probably gate on exit code instead of regex scan

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark pass/fail is now gated on docker exit_code from exec(..., detailed=True), not regex. Removed FLUX scan_fatal_output; WAN only uses scan_wan_fatal_output for the timeout/hang override path, plus post-failure hint regex. Added tests for non-zero exit without traceback

from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple

from cvs.lib import globals
from cvs.lib.parallel_ssh_lib import Pssh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is deprecated, we should be using :

    # Recommended (multi-process with auto-sharding):
    from cvs.lib.parallel.multiprocess_pssh import MultiProcessPssh

    # For single-process SSH only:
    from cvs.lib.parallel.pssh import Pssh

    # Configuration:
    from cvs.lib.parallel.config import ParallelConfig

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

world_size: int = 0


class FluxBenchmarkJob:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FluxBenchmarkJob and WanBenchmarkJob (pytorch_xdit_flux_job.py/pytorch_xdit_wan_job.py) duplicate check_kfd, _fetch_hostnames, _build_env_args, _build_volume_args, _build_docker_cmd, build_launch_plan, run(), and store_output_dir_hint we probably need to write a baseclass and extend

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new file cvs\lib\inference\pytorch_xdit\pytorch_xdit_benchmark_job.py is added.

update_test_result()
return

required_checks = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytorch_xdit_flux1_dev_distributed.py:282 verifies actual required files (model_index.json, transformer/vae weights) the WAN distributed test's equivalent branch both single and distributed tests only do do test -d && echo EXISTS no file level check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — WAN single and distributed tests now use the shared pytorch_xdit_model_verify.py helper to verify required files (model_index.json, transformer/vae weights, or native HF snapshot artifacts) via verify_required_checks_on_nodes, matching FLUX parity.

return nodes[:nnodes]
return list(self.s_phdl.host_list)

def validate_parallelism(self) -> Optional[str]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FluxBenchmarkJob.validate_parallelism() and WanBenchmarkJob.validate_parallelism() each call the module-level validate_parallelism() twice with identical arguments (once for the error check, again just to re-fetch world_size/product for logging)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — validate_parallelism() is now called once per job; the returned (world_size, product, err) tuple is used for both the error check and the success log line.

return nodes[:nnodes]
return list(self.s_phdl.host_list)

def validate_parallelism(self) -> Optional[str]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FluxBenchmarkJob.validate_parallelism() and WanBenchmarkJob.validate_parallelism() each call the module-level validate_parallelism() twice with identical arguments (once for the error check, again just to re-fetch world_size/product for logging)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — validate_parallelism() is now called once per job; the returned (world_size, product, err) tuple is used for both the error check and the success log line.

Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
amd-droy and others added 30 commits August 28, 2026 16:00
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
'

Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Signed-off-by: amd-droy <droy@amd.com>
Bring in flux2, wan diffusers, job refactors, schemas, and tests
from dr/xdit_wan after both branches were rebased onto main.

Co-authored-by: Cursor <cursoragent@cursor.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.

2 participants