Repository navigation
air run: catch report_to set through a dict in the Trainer MLflow check - #8283
anshul0713 wants to merge 1 commit into
Conversation
Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at ea22234. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR extends the Trainer MLflow check so it also catches report_to set through a dict item (extra["report_to"] = ...) or a dict literal entry ("report_to": ...), which is the case that crashed the agent trial. The dict-item part works. Letting : follow a bare report_to goes further than needed, though, and it regresses the check in both directions. On transformers 4.x AI environments, lines like if args.report_to: now turn off the default-reporting warning. Annotated dataclass fields can now set off a false warning. Accepting : only after a closing quote fixes both, and each case needs a test.
| // report_to set as a keyword argument (report_to=...), a dict item | ||
| // (args["report_to"] = ...) or a dict literal entry ("report_to": ...), but | ||
| // not compared with ==. | ||
| reportToPattern = `^[^#]*report_to["']?[[:space:]]*\]?[[:space:]]*[=:]([^=]|$)` |
There was a problem hiding this comment.
[blocking] Because [=:]([^=]|$) accepts a colon right after a bare report_to, lines that only read the value now count as setting it. Examples are if args.report_to:, print("report_to:", args.report_to) and report_to: list[str]. On databricks_ai_v5, a script with mlflow.start_run(run_id=...), TrainingArguments(output_dir='o'), one of those lines and trainer.train() warned at base. Now trainerMLflowConflict (line 91) skips the default branch and the check stays silent, so the job still crashes with Run ... is already active. Could the colon form require a closing quote, as in ["']report_to["'][[:space:]]*:, while the dict-item form keeps \]?[[:space:]]*=? A v5 default-path test containing if args.report_to: would pin this.
| // (args["report_to"] = ...) or a dict literal entry ("report_to": ...), but | ||
| // not compared with ==. | ||
| reportToPattern = `^[^#]*report_to["']?[[:space:]]*\]?[[:space:]]*[=:]([^=]|$)` | ||
| trainerReportsMLflowPattern = `^[^#]*report_to["']?[[:space:]]*\]?[[:space:]]*[=:]([^=][^#]*)?(mlflow|["']all["'])` |
There was a problem hiding this comment.
[nice to have] The colon match causes the opposite problem in trainerReportsMLflowPattern. A common HF argument dataclass line is report_to: str = field(default="none", metadata={"help": "... mlflow, wandb"}). It now matches, because [^=][^#]* runs on to the mlflow inside the help string. Any script that also passes a run ID to start_run and calls .train() gets a warning even though reporting is "none", and at base it didn't. The same quoted-key restriction as on line 30 fixes this. Can you add this annotated line as a no-warning case?
✅ Integration test reportCommit: ea22234
Top 3 slowest tests (at least 2 minutes):
|
Changes
The Trainer MLflow check from #8234 now also finds
report_towhen it's set through a dict:extra["report_to"] = ["mlflow"].{"report_to": "mlflow"}, typically passed toTrainingArguments(**kw).Before, both patterns needed
report_to=. A comparison such ascfg.report_to == "mlflow"still doesn't count.No changelog fragment: #8234's entry hasn't been released and still describes the check.
Why
In an agent trial on the CLI from
main(feed854), the HF Trainer fine-tune still crashed withRun with UUID ... is already active. The script calledmlflow.start_run(run_id=mlflow_run_id)and thentrainer.train(), but built its training arguments as a dict withextra["report_to"] = ["mlflow"].--dry-runprinted no warning. The crash cost one GPU queue and setup cycle (about 4.5 minutes) and a rewrite of the logging.I ran the check on that trial's original
train.py: it warns with this change and stays silent onmain.Tests
TestTrainerMLflowRunWarningcases:report_to == "mlflow", andextra["report_to"] = [].go test ./cmd/air/...andgo test ./acceptance -run TestAccept/airpass.This pull request and its description were written by Isaac.