plasma-umass / cwhy

"See why!" Explains and suggests fixes for compile-time errors for C, C++, C#, Go, Java, LaTeX, PHP, Python, Ruby, Rust, and TypeScript
Apache License 2.0
272 stars 6 forks source link

Unable to use Bedrock API #61

Closed sunnyszy closed 8 months ago

sunnyszy commented 8 months ago
$export AWS_ACCESS_KEY_ID=xxxx # also tried to wrap it with ""
$echo $AWS_ACCESS_KEY_ID
xxxx  #verify expert command
$export AWS_SECRET_ACCESS_KEY=yyyy
$export AWS_REGION_NAME=us-west-2
$cwhy --- python tmp.py
.....
==================================================
CWhy
==================================================
....

Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

You need a key (or keys) from an AI service to use CWhy.

OpenAI:
  You can get a key here: https://platform.openai.com/api-keys
  Set the environment variable OPENAI_API_KEY to your key value:
    export OPENAI_API_KEY=<your key>

Bedrock:
  To use Bedrock, you need an AWS account.
  Set the following environment variables:
    export AWS_ACCESS_KEY_ID=<your key id>
    export AWS_SECRET_ACCESS_KEY=<your secret key>
    export AWS_REGION_NAME=us-west-2
nicovank commented 8 months ago

We just added Bedrock support, still working on it. My hypothesis would be a permission issue, happened to me when I initially tried. You can try adding something here to get more information about the actual underlying exception / issue: https://github.com/plasma-umass/cwhy/blob/5455c0b06147aaf74b70adffde9cc81a7fd31d9a/src/cwhy/cwhy.py#L188-L190

import traceback
traceback.print_exc()

I'll take a look at improving error messages tomorrow.

nicovank commented 8 months ago

(More information about permissions here: https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html)

sunnyszy commented 8 months ago

Fixed. Sorry I used a wrong key. Maybe later you can add an explict check for key validation?

Analysis from bedrock/anthropic.claude-v2:1:
--------------------------------------------
 It looks like your model is running into an issue with the Neuron compiler
where there is an out of bounds access pattern. Specifically, this error:

Reason: Access pattern out of bound. Instruction: I-46 Opcode: Save Argument AP: Access Pattern: [[3,4],[3,1],[1,3]]

Indicates that an instruction in the compiled graph is trying to save data using
an access pattern that goes out of bounds of the target memory location.
Some things you could try to resolve this:
- Simplify the model to remove complex access patterns. For example, flatten
large multi-dimensional tensors before operations.
- If using strided slicing, try removing that or changing to simpler slicing.
- If multiple slices/indices into a tensor, try consolidating into one slice.
- Try reducing the batch size or dimensions of your tensors to simplify sizes.
- Print out and inspect the shape of your tensors before problematic operations
to ensure sizes are what you expect.
- Upgrade to latest Neuron SDK in case bug fixes help.
- Report the issue to AWS for investigation in case it is a compiler bug.
(Total cost: approximately $0.03 USD.)
NoneType: None
==================================================