Skip to content

fix: ModelBuilder not passing HF_TOKEN to model. #4780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 11, 2024

Conversation

makungaj1
Copy link
Contributor

@makungaj1 makungaj1 commented Jul 10, 2024

Issue #, if available:

Description of changes:
Fixes:

  • ModelBuilder JS Builder not passing HF_TOKEN down to model.
  • ModelBuilder build issue with model object.

Testing done:
Tested with this public notebook.

model_builder = ModelBuilder(
    model=target_model_id,
    env_vars={
        "HUGGING_FACE_HUB_TOKEN": hf_hub_token
    },
    schema_builder=SchemaBuilder(sample_input, sample_output),
    sagemaker_session=sagemaker_session,
    role_arn=my_role,
)
optimized_model = model_builder.optimize(
   instance_type="ml.inf2.8xlarge",
   compilation_config={
          "OverrideEnvironment": {
            "OPTION_TENSOR_PARALLEL_DEGREE": "2",
            "OPTION_N_POSITIONS": "8192",
            "OPTION_DTYPE": "fp16",
            "OPTION_ROLLING_BATCH": "auto",
            "OPTION_MAX_ROLLING_BATCH_SIZE": "4",
            "OPTION_NEURON_OPTIMIZE_LEVEL": "2",
         }
   },
   output_path=f"s3://{out_put_bucket}/{uuid.uuid4().hex}/"
)
predictor = optimized_model.deploy(initial_instance_count=1)
predictor.predict(sample_input)
predictor.delete_model()
predictor.delete_endpoint()
model_builder = ModelBuilder(
    model="meta-textgeneration-llama-3-70b",
    schema_builder=SchemaBuilder(sample_input, sample_output),
    sagemaker_session=sagemaker_session,
    role_arn=my_role,
)
model_builder.display_benchmark_metrics()
model_builder.set_deployment_config("lmi-optimized", "ml.p5.48xlarge")

optimized_model = model_builder.optimize(
    accept_eula=True,
    speculative_decoding_config={
        "ModelSource": draft_model_s3_uri
    },
    env_vars={
        "HF_TOKEN": hf_hub_token # verified that HF token was passed correctly
    },
)

predictor = optimized_model.deploy(initial_instance_count=1)
predictor.predict(sample_input)
predictor.delete_model()
predictor.delete_endpoint()

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@makungaj1 makungaj1 marked this pull request as ready for review July 10, 2024 20:44
@makungaj1 makungaj1 requested a review from a team as a code owner July 10, 2024 20:44
@makungaj1 makungaj1 requested a review from zhaoqizqwang July 10, 2024 20:44
@Aditi2424 Aditi2424 merged commit b9c206f into aws:master Jul 11, 2024
11 checks passed
@makungaj1 makungaj1 deleted the hot-fix branch July 11, 2024 23:05
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.

4 participants