Skip to content

Commit

Permalink
test: avoid exporting in separate process
Browse files Browse the repository at this point in the history
If any other test accessed the neuron cores, they are still seen
as being used and the export process will be denied access.
  • Loading branch information
dacorvo committed Feb 11, 2025
1 parent 8caa502 commit dc725d2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions tests/decoder/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import copy
import logging
import subprocess
import sys
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -57,16 +56,11 @@ def _get_hub_neuron_model_id(config_name: str):


def _export_model(model_id, export_kwargs, neuron_model_path):
export_command = ["optimum-cli", "export", "neuron", "-m", model_id, "--task", "text-generation"]
for kwarg, value in export_kwargs.items():
export_command.append(f"--{kwarg}")
export_command.append(str(value))
export_command.append(neuron_model_path)
logger.info(f"Exporting {model_id} with {export_kwargs}")
try:
subprocess.run(export_command, check=True)
except subprocess.CalledProcessError as e:
raise SystemError(f"Failed to export model: {e}")
model = NeuronModelForCausalLM.from_pretrained(model_id, export=True, **export_kwargs)
model.save_pretrained(neuron_model_path)
except Exception as e:
raise ValueError(f"Failed to export {model_id}: {e}")


@pytest.fixture(scope="session", params=DECODER_MODEL_CONFIGURATIONS.keys())
Expand Down

0 comments on commit dc725d2

Please sign in to comment.