Download adapters/train_duo_dcd.py from jyliuAI/diffusion_baseline: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/jyliuAI/diffusion_baseline/resolve/main/adapters/train_duo_dcd.py
- Command line
-
hf download hf://jyliuAI/diffusion_baseline/adapters/train_duo_dcd.py
-
curl -L -o train_duo_dcd.py https://huggingface.co/jyliuAI/diffusion_baseline/resolve/main/adapters/train_duo_dcd.py
1.35 kB
| """Run Duo+DCD with a narrow compatibility patch for the pinned Duo source.""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| import sys | |
| from typing import Any | |
| def _patch_distillation_nll() -> None: | |
| import algo | |
| original = algo.Distillation.nll | |
| if getattr(original, "_dlb_accepts_labels", False): | |
| return | |
| def nll( | |
| self: Any, | |
| x0: Any, | |
| labels_or_output_tokens: Any = None, | |
| output_tokens: Any = None, | |
| current_accumulation_step: Any = None, | |
| train_mode: Any = None, | |
| ) -> Any: | |
| if output_tokens is None: | |
| output_tokens = labels_or_output_tokens | |
| return original( | |
| self, | |
| x0, | |
| output_tokens, | |
| current_accumulation_step, | |
| train_mode, | |
| ) | |
| nll._dlb_accepts_labels = True # type: ignore[attr-defined] | |
| algo.Distillation.nll = nll | |
| def main() -> int: | |
| import hydra | |
| sys.path.insert(0, str(Path.cwd())) | |
| _patch_distillation_nll() | |
| import main as upstream_main | |
| def run(config: Any) -> None: | |
| upstream_main.main.__wrapped__(config) | |
| return int(run() or 0) | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |