Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
c29aa11
feat: add codeCarbon energyProfiler with basic integration in evaluat…
giuliobilli01 Mar 8, 2026
a71d09d
fix: fix EnergyProfiler logger
giuliobilli01 Mar 9, 2026
6de502c
chore: add codecarbon requirement
giuliobilli01 Mar 9, 2026
a6d53f0
fix: fix requirements
giuliobilli01 Mar 10, 2026
4e018ae
feat: removed duplicates after pull
giuliobilli01 Mar 10, 2026
556d2af
feat: add logs.sh script to better log access
giuliobilli01 Mar 11, 2026
8e3a283
feat: add eval_study script
giuliobilli01 Mar 11, 2026
75b69bf
feat: setup wandb run for energy profiler
giuliobilli01 Mar 20, 2026
0871170
feat: add estimator integration and added comparison
giuliobilli01 Mar 21, 2026
d79c120
fix: fix get_model_params call
giuliobilli01 Mar 21, 2026
fb56e12
feat: wip
giuliobilli01 Mar 22, 2026
66cb577
feat: add energy evaluation configurations
giuliobilli01 Mar 22, 2026
399099d
feat: update sbatch
giuliobilli01 Mar 22, 2026
6ce49f2
fix: fix name error
giuliobilli01 Mar 22, 2026
982dff1
fix: fix pubmed conf
giuliobilli01 Mar 22, 2026
0646be3
fix: fix trust on estimator
giuliobilli01 Mar 22, 2026
8dd9d5f
fix: fix trust on estimator
giuliobilli01 Mar 22, 2026
4f891b4
fix: fix tdp unit measure
giuliobilli01 Mar 23, 2026
44592b8
refactor: add wand_logger
giuliobilli01 Mar 23, 2026
1aeaae5
fix: fix cpu poweer estimation
giuliobilli01 Mar 25, 2026
4eb0254
fix: fix cpu poweer estimation
giuliobilli01 Mar 26, 2026
f3a606d
fix: fix multi-modal models cache_params
giuliobilli01 Mar 29, 2026
53839cb
refactor: improved emission_comparator and estimation_pipeline implem…
giuliobilli01 Mar 29, 2026
e859831
feat: add more evaluation energy configurations
giuliobilli01 Mar 29, 2026
1d211a3
QLoRa implementation
Mar 30, 2026
8d711e5
fix: correct indentation
andreeascrob Mar 30, 2026
159c192
Fix QLoRa error
Mar 30, 2026
266ad93
see inconsistency
Mar 30, 2026
0e98ad2
fix: correct indentation in model input requirement check
andreeascrob Mar 30, 2026
7c9af2b
Fix some repetitions
Mar 31, 2026
c1472df
Resolve merge conflicts + ignore sbatch script
Apr 9, 2026
db6ce25
.
Apr 10, 2026
0573dea
feat: add configuration files for qa_pubmed_mcqa with gemma-2-2b and …
andreeascrob Apr 10, 2026
64544b1
feat: add qa_pubmed_mcqa configuration for llama-3-8b model
andreeascrob Apr 10, 2026
a066b49
chore: remove qa_pubmed_mcqa configuration for llama-3-8b model
andreeascrob Apr 10, 2026
9c74b90
fix: correct formatting in qa_pubmed_mcqa_llama-3-8b_QLoRa.yaml
andreeascrob Apr 10, 2026
78c2590
fix: update model kwargs to use 'torch_dtype' instead of 'dtype'
andreeascrob Apr 10, 2026
c6f5c93
fix: update completion_only_loss to False and max_length to 1024 in q…
andreeascrob Apr 10, 2026
5e2112d
fix: update peft_config parameters and adjust max_length in qa_pubmed…
andreeascrob Apr 10, 2026
174f133
fix: update model kwargs to include device_map and adjust max_length …
andreeascrob Apr 11, 2026
c324e06
feat: add new configuration for qa_pubmed_mcqa_medgemma-4b_QLoRa.yaml
andreeascrob Apr 11, 2026
a68be9e
fix: update output_dir and run_name for qa_pubmed_mcqa_medgemma-4b_QL…
andreeascrob Apr 11, 2026
1c83a9a
chore: removed duplicated logged values in comparison
giuliobilli01 Apr 11, 2026
af37159
feat: add medMcqa_data_builder for fine tuning on medMcqa dataset
giuliobilli01 Apr 13, 2026
f81b679
fix: fix lm_eval requirements for pyproject install
giuliobilli01 Apr 13, 2026
e28b6f1
fix: fix medmcqa task builder
giuliobilli01 Apr 13, 2026
b0cd297
feat: add cli_evaluate metrics aggregator
giuliobilli01 Apr 14, 2026
61cc180
feat: add script to populate old runs
giuliobilli01 Apr 14, 2026
48ecd99
fix: fix script to populate old runs
giuliobilli01 Apr 14, 2026
7c1b69f
feat: add script to check model modules for PEFT compatibility
andreeascrob Apr 16, 2026
85ffc23
feat: add wandb energy accuracy builder
giuliobilli01 Apr 17, 2026
d225674
feat: add wandb energy accuracy plot with vega preset
giuliobilli01 Apr 17, 2026
b7ea2ee
feat: update wandb pareto plot
giuliobilli01 Apr 18, 2026
bfbf0b3
feat: update wandb pareto plot
giuliobilli01 Apr 18, 2026
e52b960
chore: from dtype to torch_dtype
giuliobilli01 Apr 19, 2026
112ba11
fix: update WANDB_TRAIN_PROJECT to reflect new project name
andreeascrob Apr 19, 2026
8fcc867
fix: yaml file
Apr 19, 2026
aa01ceb
fix: fix warning condition
giuliobilli01 Apr 19, 2026
2e8b4fe
feat: update returned fields to create pareto chart for task group an…
giuliobilli01 Apr 19, 2026
d08027b
fix: fix lm-eval metrics retrieval
giuliobilli01 Apr 19, 2026
68aa68b
feat: add MedMCQA and MedQA data builders with processing logic
andreeascrob Apr 19, 2026
77f4038
fix: update quantization and trainer configuration parameters in qa_p…
andreeascrob Apr 19, 2026
3f76070
fix: handle invalid 'cop' values in MedmcqaDataBuilder processing logic
andreeascrob Apr 20, 2026
cdd1ab8
test QLoRa on pubmed dataset
Apr 20, 2026
a078d4e
fix: update test for MedmcqaDataBuilder to ensure data integrity and …
andreeascrob Apr 20, 2026
09f9fe8
feat: add new YAML configuration files for MedMCQA and MedQA tasks
andreeascrob Apr 20, 2026
962bef6
fix: update dataset directory in qa_pubmed_gen_qa_gemma configuration
andreeascrob Apr 20, 2026
56bda92
feat: add new configuration for med_mcqa_gemma-2-2b with quantization…
andreeascrob Apr 20, 2026
233f8b0
fix: update dataset directory in qa_pubmed_mcqa_gemma configurations
andreeascrob Apr 20, 2026
30db52e
fix: correct bf16 and fp16 settings in qa_pubmed_mcqa_gemma configura…
andreeascrob Apr 20, 2026
69023e2
fix: update dataset directory in qa_pubmed_mcqa_llama-3-8b and qa_pub…
andreeascrob Apr 20, 2026
7eb7e4e
chore: updated trl version to latest with correct transformers version
giuliobilli01 Apr 20, 2026
528e572
feat: added gemma4 configs
giuliobilli01 Apr 20, 2026
e15fe6e
fix: update quantization settings and trainer arguments in qa_pubmed_…
andreeascrob Apr 22, 2026
a64d4bb
fix: update quantization settings and peft configuration in qa_pubmed…
andreeascrob Apr 22, 2026
e35b7cc
fix: update PEFT configuration and training parameters in qa_pubmed_m…
andreeascrob Apr 22, 2026
8e3cf6d
fix: fix requires_grad=False flow
giuliobilli01 Apr 22, 2026
ea91701
feat: add train wandb project config
giuliobilli01 Apr 22, 2026
b035081
feat: add more configs
giuliobilli01 Apr 22, 2026
46cac20
feat: updated train configurations
giuliobilli01 Apr 23, 2026
61b16a5
fix: update dataset directory and adjust bf16/fp16 settings in qa_pub…
andreeascrob Apr 23, 2026
30efdec
fix: update num_processes to 1 in accelerator configuration files
andreeascrob Apr 23, 2026
48da7ef
fix: enhance quantization configuration and update trainer arguments …
andreeascrob Apr 23, 2026
0395f61
fix: add model_validator import to trainer_run_config.py
andreeascrob Apr 23, 2026
d5c7fe4
fix: update PEFT configuration and training parameters in qa_pubmed_m…
andreeascrob Apr 23, 2026
eec9820
fix: update warmup_steps value in qa_pubmed_mcqa_gemma-2-2b_zero-shot…
andreeascrob Apr 23, 2026
d9b6204
fix: update run_name and logging_steps in qa_pubmed_mcqa_gemma-2-2b_z…
andreeascrob Apr 23, 2026
28250b0
fix: add evaluator configuration files for gemma-2-2b, llama-3-8b, an…
andreeascrob Apr 27, 2026
f1f6393
fix: update pretrained model and PEFT path in pubmed_mcqa_medgemma-4b…
andreeascrob Apr 27, 2026
c73a56d
fix: update wandb_args configuration in pubmed_mcqa_gemma-2-2b, llama…
andreeascrob Apr 27, 2026
ef10717
fix: update PEFT path and output directory in pubmed_mcqa_medgemma-4b…
andreeascrob Apr 27, 2026
1c03480
fix: add configuration file for pubmed_mcqa_qwen-2-7b-qlora model
andreeascrob Apr 27, 2026
0431026
fix: update tasks configuration in evaluator YAML files for gemma-2-2…
andreeascrob Apr 29, 2026
9a03f1d
fix: add attn_implementation to various pubmed_mcqa YAML configurations
andreeascrob Apr 29, 2026
957cc78
fix: consolidate model_args in pubmed_mcqa_qwen-2-7b-qlora.yaml for i…
andreeascrob Apr 29, 2026
22dd1f1
fix: streamline model_args formatting in pubmed_mcqa YAML files for c…
andreeascrob Apr 29, 2026
60c849e
fix: add check_tokenizer parameter to model_args in pubmed_mcqa_medge…
andreeascrob Apr 29, 2026
0950722
fix: update wandb_args project name in pubmed_mcqa_gemma-2-2b.yaml fo…
andreeascrob Apr 29, 2026
308c444
feat: add bf16 and eager params to configs
giuliobilli01 Apr 29, 2026
e02138e
feat: fixed metrics unit of measure and inference flops
giuliobilli01 Apr 30, 2026
f043d84
feat: add config loucher script
giuliobilli01 Apr 30, 2026
a5b62ed
Merge remote-tracking branch 'origin/feat/Qlora-quantization' into fe…
giuliobilli01 May 1, 2026
f556169
feat: add new configs for qlora training and evaluation
giuliobilli01 May 1, 2026
c14c830
chore: update project on wandb for logs
giuliobilli01 May 1, 2026
f3faa58
chore: removed gemma 4 configs
giuliobilli01 May 1, 2026
e3a8ca9
feat: add medqa, pubmedqa configs
giuliobilli01 May 1, 2026
18bb8e1
feat: add config to reduce used space
giuliobilli01 May 3, 2026
f174210
feat: add config with process tracking mode to test
giuliobilli01 May 3, 2026
f8e6aae
fix: fix completion only loss preserve_tail
giuliobilli01 May 4, 2026
92386db
feat: update evaluation config for qlora fine tuning
giuliobilli01 May 6, 2026
e4d9251
feat: add auto pareto chart calculation
giuliobilli01 May 10, 2026
d4e9a5d
chore: changed wandb project for eval configurations
giuliobilli01 May 10, 2026
024217a
chore: removed gemma4 configs
giuliobilli01 May 10, 2026
f2f6628
fix: fix fields mismatch in pareto calculation
giuliobilli01 May 12, 2026
78e88ab
fix: fix wandb key
giuliobilli01 May 13, 2026
0af56da
feat: update run script
giuliobilli01 May 13, 2026
9ce5b5f
fix: add file creation for GPU PARAMS and MODEL PARAMS files
giuliobilli01 May 13, 2026
3f3327e
feat: updated pareto plot ui
giuliobilli01 May 14, 2026
1f538d3
feat: updated pareto plot ui
giuliobilli01 May 14, 2026
b1cc391
fix: fix energy estimation error for training with peft
giuliobilli01 May 21, 2026
f84a8f7
feat: updated eval configs for flash_attn
giuliobilli01 May 21, 2026
d69424a
feat: add mixed dataset builder
giuliobilli01 May 27, 2026
1863697
feat: add mixed dataset configs
giuliobilli01 May 27, 2026
e77bf42
feat: update trainer configuration for early stopping and checkpointing
andreeascrob Jun 6, 2026
c5cdf31
fix: adjust logging steps and refine early stopping/checkpointing par…
andreeascrob Jun 6, 2026
dfc53f6
feat: enhance early stopping configuration in trainer and YAML settings
andreeascrob Jun 6, 2026
8662d63
feat: implement early stopping configuration in YAML files and add sc…
andreeascrob Jun 6, 2026
c8ac132
fix: update logging steps to improve tracking frequency in trainer co…
andreeascrob Jun 6, 2026
f9f0e4a
fix: reduce logging steps from 100 to 10 across multiple trainer conf…
andreeascrob Jun 6, 2026
f73a595
fix: reduce logging steps to 10 and enhance evaluation/checkpointing …
andreeascrob Jun 7, 2026
93140e7
fix: reduce logging steps to 10 and enhance evaluation/checkpointing …
andreeascrob Jun 13, 2026
6c1771d
feat: add eval configs for mixed dataset
giuliobilli01 Jun 20, 2026
7a0cbf0
fix: update WANDB project name and adjust PEFT configurations across …
andreeascrob Jun 24, 2026
15b8b92
fix: fix Gemma3Config vocab_size error
giuliobilli01 Jun 24, 2026
f30924a
fix: update WANDB training project name to 'open-medical-llm-train-en…
andreeascrob Jun 26, 2026
bd7826c
fix: update WANDB training project name and adjust PEFT configuration…
andreeascrob Jun 26, 2026
a277197
fix: update WANDB training project name to 'open-medical-llm-train-en…
andreeascrob Jun 28, 2026
06a99eb
back to QLoRa train project
andreeascrob Jun 28, 2026
778e604
fix: update WANDB training project name to 'open-medical-llm-QLoRa-ev…
andreeascrob Jun 29, 2026
962f8f2
feat: add new trainer configuration files for Gemma, Llama, and Qwen …
andreeascrob Jun 29, 2026
7c12da9
fix: update WANDB training project name to 'open-medical-llm-QLoRa'
andreeascrob Jun 29, 2026
1e6eb15
feat: add new configuration files for Gemma, Llama, and Qwen models w…
andreeascrob Jun 30, 2026
dc48fd2
feat: add outline in pareto plot for mixed dataset
giuliobilli01 Jun 30, 2026
f69095a
feat: update model configurations for Gemma, Llama, and Qwen with new…
andreeascrob Jul 1, 2026
1837e74
feat: update experiment configurations for Gemma, Llama, and Qwen mod…
andreeascrob Jul 1, 2026
b99f3be
feat: update model configurations for Gemma, Llama, and Qwen with new…
andreeascrob Jul 1, 2026
15398d7
feat: update experiment configurations for Gemma, Llama, and Qwen mod…
andreeascrob Jul 1, 2026
042d134
feat: update model configurations for Gemma, Llama, and Qwen with new…
andreeascrob Jul 2, 2026
a0dcf70
feat: update learning rates and output paths for Gemma, Llama, and Qw…
andreeascrob Jul 2, 2026
b8dfabb
feat: update learning rates in YAML configurations for Gemma, Llama, …
andreeascrob Jul 2, 2026
cc8bb10
fix: fix pubmedqa builder
giuliobilli01 Jul 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ models
wandb/*
.cache
*.gradio*
*.egg*
*.egg*
*.sbatch

55 changes: 55 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
The estimator's FLOP-based model overestimates for larger models because it doesn't account for real-world hardware efficiency gains (optimized kernels, memory hierarchy effects, batching).

Larger models emit more CO₂, but not linearly — going from 1B to 14B parameters (~14× more params) only increases emissions ~3-5×, probably because runtime doesn't scale linearly with parameter count for inference/evaluation workloads.

GPU utilization increases with model size — small models (1-2B) use only 25–35% of the GPU, while large models (8–14B) push utilization to 70–88%.

LLaMA 3.2 is the most efficient (1B: 6.1g CO₂, 216s)

Qwen3 is mid-range (1.7B: 11.9g, 454s)

and Gemma 3 is the least efficient (~1B: 11.0g, 458s)


Comparison con le stesse famiglie anche magari tra gemma2, gemma3
In Context Learning

Con il CPU load mode fallback utilizza P=TDP×(0.1+0.9×(cpu_load/100)
3 ) con TDP = 450w

cpu_load = psutil.cpu_percent(interval=0.5, percpu=False)

the cpu_load reflects the entire node's CPU usage — including other users' jobs if the node isn't exclusively allocated. That's why your force_cpu_power=450 matters: even if the node shows 80% load, some of that may not be yours.

Provare a runnare di nuovo con tracking process

Configurazioni per il train.









### 1. Dataset Selection and Preprocessing
To isolate model architecture as the primary variable for energy consumption, your dataset pipeline must be perfectly rigid.

* **Select a Single Baseline Dataset:** As discussed, use a single dataset like **MedQA (USMLE)** or **MedMCQA** to ensure consistent reasoning complexity and average sequence length across all models.
* **Standardize the Token Count (Crucial):** Do not train for "3 epochs." Because different models use different tokenizers (e.g., Llama's tokenizer splits words differently than Gemma's), 1 epoch of MedQA might be 10 million tokens for Model A but 11 million for Model B. Set your training loop to stop after exactly $X$ million tokens have been processed. If possible we can have this stop_criteria as a parameter in the config
* **Unified Prompt Template:** Wrap every training example in the exact same instruction format (e.g., `Instruction: [Question] \n Options: [A,B,C,D] \n Answer: [Target]`).


### 3. Model Configuration (PEFT / QLoRA)
Full-parameter fine-tuning is likely too resource-intensive and noisy for this comparison. You should use Parameter-Efficient Fine-Tuning (PEFT).

* **Standardize LoRA Parameters:** Apply the exact same adapter size to all models. For example, fix your LoRA Rank ($r=16$) and Alpha ($\alpha=32$). This ensures you are testing how efficiently the base model integrates new knowledge, rather than testing different adapter sizes.
* **Maximize Batch Size:** To measure true efficiency, you must saturate the GPU. Find the maximum batch size that fits into the GPU memory for *each* model. A model running at 40% memory utilization will yield artificially poor energy efficiency metrics.

### 5. Evaluation and Comparison
Once the models are fine-tuned, you need to map their energy cost against their new capabilities.

* **Standardize Inference:** When testing the models on the test split to get their accuracy scores, use strict, fixed hyperparameters (e.g., `temperature = 0.1`, `top_p = 0.95`).
* **Plot the Pareto Frontier:** Create a scatter plot with **Total Fine-Tuning Energy (Wh)** on the X-axis and **Benchmark Accuracy (%)** on the Y-axis. The models that sit on the top-left edge of this plot represent the optimal trade-off between energy efficiency and learned performance. Add this as a separate function called energy_accuracy_plot in a folder called plots or similar. Add it to evaluation.

120 changes: 120 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,126 @@ include_path: config_files/evaluator_configs/tasks
- Running via SLURM:
- Configure venv and config paths in the slurm script ``scripts/autollm_eval.sbatch``.
- Run the script: ``sbatch scripts/autollm_eval.sbatch``.

#### Step 3. Refresh Pareto frontier panels (post-hoc)

Each eval run logs its own energy (`emissions/*`) and accuracy (`eval/*`)
metrics to wandb, **but not** the `pareto/<label>/*` fields used by the
Pareto-frontier workspace. Pareto optimality is a **cross-run** property: a
run can only know its rank relative to every other run in the project, so
the frontier must be computed once per batch — not during a single run.

After a sweep or batch of eval jobs has finished, refresh the frontier flags
and workspace panels by running the standalone backfill script. This is a
lightweight wandb-API call (no GPU, no dataset loading) — run it directly on
the cluster login/head node, inside the same venv used for eval. **Do not
submit it via `sbatch`.**

```shell
# On the cluster login node:
source $VENV_PATH/bin/activate
source $ENV_VARIABLES_PATH # exports WANDB_API_KEY

python scripts/wandb_pareto_plot.py \
--entity <wandb-entity> \
--project <wandb-project>
```

The script is idempotent — re-running it after new eval jobs simply
recomputes the frontier and overwrites the `pareto/<label>/*` summary fields
on every run. Useful flags:

- ``--dry-run``: report per-label frontier sizes without writing anything.
- ``--skip-panel``: only backfill summary fields, skip the workspace upsert.
- ``--skip-backfill``: only (re)create the workspace view.
- ``--tag <tag>``: restrict to runs carrying a given tag (default: ``energy-profiling``).

##### Auto-refresh option (opt-in)

If you want each energy-eval run to update the workspace itself — without
having to remember to launch `scripts/wandb_pareto_plot.py` after every batch
— add an ``auto_pareto`` block to your evaluator YAML. When the eval job
finishes and the energy metrics have been flushed to wandb, the same Slurm
job calls `refresh_pareto_workspace(...)` in-process, on the same venv,
using the same ``WANDB_API_KEY`` already exported for energy logging.

The hook lives in `auto_llm/evaluator/run.py` (right after
`WandbEnergyLogger.flush()`). It only fires when ``energy_profiling: true``
**and** ``auto_pareto.enabled: true`` are both set — so existing configs that
omit the block keep their previous behavior (no auto-refresh).

```yaml
# config_files/evaluator_configs/.../my-eval.yaml
model: hf
tasks: medmcqa,medqa_4options,...
model_args: pretrained=google/gemma-2-2b-it
wandb_args: project=open-medical-llm-energy,name=my-run
energy_profiling: true

auto_pareto:
enabled: true
entity: llm4kmu # required if WANDB_ENTITY is unset
project: open-medical-llm-energy # defaults to wandb_args.project
# Everything below is optional — defaults match scripts/wandb_pareto_plot.py
energy_key: emissions/actual_energy_consumed_kWh
score_scale: 100.0
tag: energy-profiling
workspace_name: Pareto Frontier
skip_preset: false # set true once preset is registered
skip_panel: false
skip_backfill: false
dry_run: false
```

What the hook does, step by step:

1. After ``wandb_logger.flush()`` finishes the energy run, reads the
``auto_pareto`` block.
2. Resolves the wandb entity (``auto_pareto.entity`` →
``wandb_args.entity`` → ``WANDB_ENTITY`` env var). Aborts the refresh
(with a warning, not an error) if none is set.
3. Calls ``refresh_pareto_workspace(...)`` from
``auto_llm.evaluator.plots.wandb_pareto_plot`` — the same library
function the manual CLI script wraps, so behavior is identical.
4. The function fetches every run in the target project via the wandb
API, recomputes the frontier for all 13 labels (1 overall + 3 groups
+ 9 tasks), writes ``pareto/<label>/*`` keys back into each run's
summary, then upserts the saved workspace view.
5. On success, logs the workspace URL. On any failure (network glitch,
wandb 5xx, missing entity, …), logs a single warning of the form
``auto_pareto refresh failed (best-effort, eval job will succeed): …``
and the eval job still exits 0.

Trade-offs to be aware of:

- **Best-effort only.** A refresh failure never fails the eval job. If
reliability matters for a specific batch, leave ``enabled: false`` and
run the manual command from the login node at the end.
- **Concurrent jobs race.** When two energy-eval Slurm jobs finish at
the same time and both attempt to refresh, both write
``pareto/<label>/*`` into every run's summary. Last writer wins;
flags converge as more jobs finish. This is acceptable because the
Pareto frontier is a deterministic function of the data already in
wandb — every refresh that runs after the last ``wandb.finish()``
produces the same answer.
- **Cost.** The refresh fetches every run in the project via the wandb
API (no GPU, no dataset loading). For projects with hundreds of runs
this adds a few seconds per eval job. On large sweeps, prefer
``enabled: false`` plus one manual run at the end.
- **Workspace only.** This refresh updates the live ``Pareto Frontier``
workspace via ``wandb_workspaces.workspaces``. It does **not**
publish a frozen Report — for that, run the manual command and call
the ``wandb_workspaces.reports.v2`` API yourself.

When to leave ``auto_pareto`` disabled (the default):

- Local debugging — no need to overwrite the project workspace from
every smoke test.
- Configs not running with ``energy_profiling: true`` — the hook is
only reached when the energy block executes.
- Massive sweeps where you only care about the final frontier — let
the sweep complete and run the manual command once on the login
node.
</details>

# Contact Us
Expand Down
59 changes: 59 additions & 0 deletions auto_llm/builder/task_data_builder/med_mcqa_data_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from datasets import DatasetDict, load_dataset, Dataset

from auto_llm.builder.task_data_builder.task_data_builder import TaskDataBuilder
from auto_llm.dto.builder_config import (
DatasetSplit,
TaskDatasetFeatures,
)


class MedmcqaDataBuilder(TaskDataBuilder):
"""Build the MedMCQA dataset into ``input_text`` / ``output_text`` format.

Source: ``openlifescienceai/medmcqa`` on HuggingFace.

Raw columns: ``question``, ``opa``/``opb``/``opc``/``opd`` (four options),
``cop`` (0-indexed correct option: 0=A, 1=B, 2=C, 3=D), ``choice_type``
(``"single"`` or ``"multi"``).

"""

OPTION_MAP = {0: "A", 1: "B", 2: "C", 3: "D"}

def build(self) -> DatasetDict:
ds_dict = load_dataset("openlifescienceai/medmcqa", trust_remote_code=True)

return DatasetDict(
{
DatasetSplit.TRAIN: self._process_split(ds_dict["train"]),
DatasetSplit.VALIDATION: self._process_split(ds_dict["validation"]),
DatasetSplit.TEST: self._process_split(ds_dict["test"]),
}
)

def _process_split(self, ds: Dataset) -> Dataset:
samples = []
for item in ds:
if item["cop"] not in self.OPTION_MAP:
continue

question = item["question"]
input_text = (
f"Question: {question}\n"
f"Options:\n"
f"A. {item['opa']}\n"
f"B. {item['opb']}\n"
f"C. {item['opc']}\n"
f"D. {item['opd']}"
)

output_text = self.OPTION_MAP[item["cop"]]

samples.append(
{
TaskDatasetFeatures.INPUT_TEXT: input_text,
TaskDatasetFeatures.OUTPUT_TEXT: output_text,
}
)

return Dataset.from_list(samples)
Loading