Use different user for uploading perf reports (#945) #332
182 tests run, 88 passed, 74 skipped, 20 failed.
Annotations
Check failure on line 55 in forge/test/models/pytorch/text/bart/test_bart.py
github-actions / TT-Forge-FE Tests
test_bart.test_pt_bart_classifier[no_device]
RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
info:
update_reshape_attr called for a non-reshape operation
backtrace:
--- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
--- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
--- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
--- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
--- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
Raw output
test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
def test_pt_bart_classifier(test_device):
compiler_cfg = _get_global_compiler_config()
compiler_cfg.compile_depth = CompileDepth.SPLIT_GRAPH
model_name = f"facebook/bart-large-mnli"
model = download_model(BartForSequenceClassification.from_pretrained, model_name, torchscript=True)
tokenizer = download_model(BartTokenizer.from_pretrained, model_name, pad_to_max_length=True)
hypothesis = "Most of Mrinal Sen's work can be found in European collections."
premise = "Calcutta seems to be the only other production center having any pretensions to artistic creativity at all, but ironically you're actually more likely to see the works of Satyajit Ray or Mrinal Sen shown in Europe or North America than in India itself."
# generate inputs
inputs_dict = tokenizer(
premise,
hypothesis,
truncation=True,
padding="max_length",
max_length=256,
truncation_strategy="only_first",
return_tensors="pt",
)
decoder_input_ids = shift_tokens_right(
inputs_dict["input_ids"], model.config.pad_token_id, model.config.decoder_start_token_id
)
inputs = [inputs_dict["input_ids"], inputs_dict["attention_mask"], decoder_input_ids]
# Compile & feed data
pt_mod = BartWrapper(model.model)
> compiled_model = forge.compile(pt_mod, sample_inputs=inputs, module_name="pt_bart")
forge/test/models/pytorch/text/bart/test_bart.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_bart], graph_name='pt_bart', compiler_cfg=CompilerConfig(enable_training=False, enab...in_recompile=False, recompile_count=0, target_cycles_offset=0, forge_module=None, compiled_binary=None, attach_to=None)
def run_optimization_pass(context: CompileContext) -> CompileDepth:
"""
Runs optimization passes.
Parameters
----------
context: CompileContext
Compile context
Returns
-------
CompileDepth - next compile stage
"""
compiler_cfg = context.compiler_cfg
graph_name = context.graph_name
graph, intermediate_tensors = context.graph, context.intermediate_tensors
> run_optimization_graph_passes(graph)
E RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
E info:
E update_reshape_attr called for a non-reshape operation
E backtrace:
E --- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
E --- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
E --- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
E --- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
forge/forge/compile.py:785: RuntimeError
Check failure on line 141 in forge/test/models/pytorch/text/bert/test_bert.py
github-actions / TT-Forge-FE Tests
test_bert.test_bert_sequence_classification_pytorch[no_device]
TypeError: 'CompileResults' object is not callable
Raw output
test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
def test_bert_sequence_classification_pytorch(test_device):
model, inputs, _ = generate_model_bert_seqcls_hf_pytorch(
"textattack/bert-base-uncased-SST-2",
)
compiled_model = forge.compile(model, sample_inputs=inputs, module_name="pt_bert_sequence_classification")
> co_out = compiled_model(*inputs)
E TypeError: 'CompileResults' object is not callable
forge/test/models/pytorch/text/bert/test_bert.py:141: TypeError
Check failure on line 65 in forge/test/models/pytorch/text/gptneo/test_gptneo.py
github-actions / TT-Forge-FE Tests
test_gptneo.test_gptneo_causal_lm[no_device-EleutherAI/gpt-neo-125M]
AssertionError: Data mismatch on output 0 between framework and Forge codegen
Raw output
variant = 'EleutherAI/gpt-neo-125M', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_gptneo_causal_lm(variant, test_device):
# Set random seed for repeatability
torch.manual_seed(42)
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Load tokenizer and model
# Variants: # EleutherAI/gpt-neo-125M, EleutherAI/gpt-neo-1.3B,
# EleutherAI/gpt-neo-2.7B
config = download_model(GPTNeoConfig.from_pretrained, variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = GPTNeoConfig(**config_dict)
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
tokenizer.pad_token = tokenizer.eos_token
model = download_model(GPTNeoForCausalLM.from_pretrained, variant, config=config)
# Sample input text
prompt = "My name is Bert, and I am"
inputs = tokenizer(prompt, return_tensors="pt", max_length=256, pad_to_max_length=True, truncation=True)
# Wrapper to get around attention mask
class Wrapper(torch.nn.Module):
def __init__(self, model):
super().__init__()
self.model = model
def forward(self, input_ids, attention_mask):
return self.model(input_ids, None, attention_mask)
inputs = [inputs["input_ids"], inputs["attention_mask"]]
> compiled_model = forge.compile(
Wrapper(model),
sample_inputs=inputs,
module_name="pt_" + str(variant.split("/")[-1].replace("-", "_").replace(".", "_")) + "_causal_lm",
)
forge/test/models/pytorch/text/gptneo/test_gptneo.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:634: in generate_initial_graph
module, module_inputs = convert_to_forge_module(
forge/forge/compile.py:973: in convert_to_forge_module
forge_module, dev_types, module_inputs = generate_forge_module(
forge/forge/tvm_to_python.py:2136: in generate_forge_module
verify_framework_vs_forge_codegen(framework_outputs, forge_outputs, verify_cfg=verify_cfg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
frame_outputs = [tensor([[[ -2.93149, -3.04098, -5.19186, ..., -11.81308, -8.60934, -6.07345],
[ -6.99371, -5.94796, -1...],
[-38.90412, -38.28091, -42.97676, ..., -69.93178, -49.82716, -37.80742]]], grad_fn=<UnsafeViewBackward0>)]
forge_outputs = (Forge Tensor: tensor([[[ -2.93151, -3.04100, -5.19192, ..., -11.81311, -8.60940, -6.07350],
[ -6.99369,...2, -5.60490, -4.23273, ..., -16.88002, -15.43275, -9.50537]]], grad_fn=<UnsafeViewBackward0>), DataFormat.Float32,)
verify_cfg = DepricatedVerifyConfig(graph_name='graph', enabled=False, intermediates=False, rtol={torch.float32: None, torch.float1...ent_checking=True, enable_parameter_gradient_checking=True, _input_gradient_queue=None, _parameter_gradient_queue=None)
def verify_framework_vs_forge_codegen(frame_outputs, forge_outputs, verify_cfg):
from forge.verify.compare import compare_tensor_to_golden
test_pass = True
for i, (golden, output) in enumerate(zip(frame_outputs, forge_outputs)):
test_pass &= compare_tensor_to_golden(
f"Framework vs. Forge codegen output {i}", golden, output.value(), is_forge=False, verify_cfg=verify_cfg
)
> assert test_pass, f"Data mismatch on output {i} between framework and Forge codegen"
E AssertionError: Data mismatch on output 0 between framework and Forge codegen
forge/forge/tvm_to_python.py:1985: AssertionError
Check failure on line 116 in forge/test/models/pytorch/text/gptneo/test_gptneo.py
github-actions / TT-Forge-FE Tests
test_gptneo.test_gptneo_sequence_classification[no_device-EleutherAI/gpt-neo-1.3B]
AssertionError: Data mismatch on output 3 between framework and Forge codegen
Raw output
variant = 'EleutherAI/gpt-neo-1.3B', test_device = None
@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_gptneo_sequence_classification(variant, test_device):
# Load tokenizer and model from HuggingFace
# Variants: # EleutherAI/gpt-neo-125M, EleutherAI/gpt-neo-1.3B,
# EleutherAI/gpt-neo-2.7B
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
tokenizer.pad_token = tokenizer.eos_token
model = download_model(GPTNeoForSequenceClassification.from_pretrained, variant, torchscript=True)
# Load data sample
review = "the movie was great!"
# Data preprocessing
input_tokens = tokenizer(
review,
max_length=32,
padding="max_length",
truncation=True,
return_tensors="pt",
)
class Wrapper(torch.nn.Module):
def __init__(self, model):
super().__init__()
self.model = model
def forward(self, input_ids, attention_mask):
return self.model(input_ids, None, attention_mask)
inputs = [input_tokens["input_ids"], input_tokens["attention_mask"]]
> compiled_model = forge.compile(
Wrapper(model),
sample_inputs=inputs,
module_name="pt_" + str(variant.split("/")[-1].replace("-", "_").replace(".", "_")) + "_seq_cls",
)
forge/test/models/pytorch/text/gptneo/test_gptneo.py:116:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:634: in generate_initial_graph
module, module_inputs = convert_to_forge_module(
forge/forge/compile.py:973: in convert_to_forge_module
forge_module, dev_types, module_inputs = generate_forge_module(
forge/forge/tvm_to_python.py:2136: in generate_forge_module
verify_framework_vs_forge_codegen(framework_outputs, forge_outputs, verify_cfg=verify_cfg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
frame_outputs = [tensor([[ 2.02300, -1.06290]], grad_fn=<IndexBackward0>), tensor([[[[-8.65128e-02, 1.82043e-01, 2.00490e-01, ..., ...51],
[ 0.65266, 0.77656, -0.42172, ..., -0.43564, 0.00645, -0.18691]]]], grad_fn=<PermuteBackward0>), ...]
forge_outputs = (Forge Tensor: tensor([[ 2.36522, -0.28600]], grad_fn=<IndexBackward0>), DataFormat.Float32, Forge Tensor: tensor([[[[...40, 0.44998, -0.12259, ..., -0.48345, 0.07875, -0.03002]]]], grad_fn=<TransposeBackward0>), DataFormat.Float32, ...)
verify_cfg = DepricatedVerifyConfig(graph_name='graph', enabled=False, intermediates=False, rtol={torch.float32: None, torch.float1...ent_checking=True, enable_parameter_gradient_checking=True, _input_gradient_queue=None, _parameter_gradient_queue=None)
def verify_framework_vs_forge_codegen(frame_outputs, forge_outputs, verify_cfg):
from forge.verify.compare import compare_tensor_to_golden
test_pass = True
for i, (golden, output) in enumerate(zip(frame_outputs, forge_outputs)):
test_pass &= compare_tensor_to_golden(
f"Framework vs. Forge codegen output {i}", golden, output.value(), is_forge=False, verify_cfg=verify_cfg
)
> assert test_pass, f"Data mismatch on output {i} between framework and Forge codegen"
E AssertionError: Data mismatch on output 3 between framework and Forge codegen
forge/forge/tvm_to_python.py:1985: AssertionError
Check failure on line 116 in forge/test/models/pytorch/text/gptneo/test_gptneo.py
github-actions / TT-Forge-FE Tests
test_gptneo.test_gptneo_sequence_classification[no_device-EleutherAI/gpt-neo-2.7B]
AssertionError: Data mismatch on output 0 between framework and Forge codegen
Raw output
variant = 'EleutherAI/gpt-neo-2.7B', test_device = None
@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_gptneo_sequence_classification(variant, test_device):
# Load tokenizer and model from HuggingFace
# Variants: # EleutherAI/gpt-neo-125M, EleutherAI/gpt-neo-1.3B,
# EleutherAI/gpt-neo-2.7B
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
tokenizer.pad_token = tokenizer.eos_token
model = download_model(GPTNeoForSequenceClassification.from_pretrained, variant, torchscript=True)
# Load data sample
review = "the movie was great!"
# Data preprocessing
input_tokens = tokenizer(
review,
max_length=32,
padding="max_length",
truncation=True,
return_tensors="pt",
)
class Wrapper(torch.nn.Module):
def __init__(self, model):
super().__init__()
self.model = model
def forward(self, input_ids, attention_mask):
return self.model(input_ids, None, attention_mask)
inputs = [input_tokens["input_ids"], input_tokens["attention_mask"]]
> compiled_model = forge.compile(
Wrapper(model),
sample_inputs=inputs,
module_name="pt_" + str(variant.split("/")[-1].replace("-", "_").replace(".", "_")) + "_seq_cls",
)
forge/test/models/pytorch/text/gptneo/test_gptneo.py:116:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:634: in generate_initial_graph
module, module_inputs = convert_to_forge_module(
forge/forge/compile.py:973: in convert_to_forge_module
forge_module, dev_types, module_inputs = generate_forge_module(
forge/forge/tvm_to_python.py:2136: in generate_forge_module
verify_framework_vs_forge_codegen(framework_outputs, forge_outputs, verify_cfg=verify_cfg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
frame_outputs = [tensor([[-1.73945, 3.86908]], grad_fn=<IndexBackward0>), tensor([[[[-0.84780, -0.45597, -0.50286, ..., 0.32681, -0...70],
[-0.14309, -0.12644, -0.26851, ..., 0.24723, 0.67294, 0.32695]]]], grad_fn=<PermuteBackward0>), ...]
forge_outputs = (Forge Tensor: tensor([[ 1.12671, -1.29598]], grad_fn=<IndexBackward0>), DataFormat.Float32, Forge Tensor: tensor([[[[....37702e-03, ..., -3.20576e-01, 7.41636e-01, -2.53812e-01]]]], grad_fn=<TransposeBackward0>), DataFormat.Float32, ...)
verify_cfg = DepricatedVerifyConfig(graph_name='graph', enabled=False, intermediates=False, rtol={torch.float32: None, torch.float1...ent_checking=True, enable_parameter_gradient_checking=True, _input_gradient_queue=None, _parameter_gradient_queue=None)
def verify_framework_vs_forge_codegen(frame_outputs, forge_outputs, verify_cfg):
from forge.verify.compare import compare_tensor_to_golden
test_pass = True
for i, (golden, output) in enumerate(zip(frame_outputs, forge_outputs)):
test_pass &= compare_tensor_to_golden(
f"Framework vs. Forge codegen output {i}", golden, output.value(), is_forge=False, verify_cfg=verify_cfg
)
> assert test_pass, f"Data mismatch on output {i} between framework and Forge codegen"
E AssertionError: Data mismatch on output 0 between framework and Forge codegen
forge/forge/tvm_to_python.py:1985: AssertionError
Check failure on line 128 in forge/test/models/pytorch/text/llama/test_llama3.py
github-actions / TT-Forge-FE Tests
test_llama3.test_llama3_causal_lm[no_device-meta-llama/Meta-Llama-3-8B-Instruct]
OSError: You are trying to access a gated repo.
Make sure to have access to it at https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct.
401 Client Error. (Request ID: Root=1-67660e69-3621c16a3edfee2b1de55789;12d9f1d6-479f-4134-a90a-d7bc8531b0ea)
Cannot access gated repo for url https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json.
Access to model meta-llama/Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
Raw output
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
> response.raise_for_status()
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
path_or_repo_id = 'meta-llama/Meta-Llama-3-8B-Instruct'
filename = 'config.json', cache_dir = '/github/home/.cache/huggingface/hub'
force_download = False, resume_download = None, proxies = None, token = None
revision = None, local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
> resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:403:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ('meta-llama/Meta-Llama-3-8B-Instruct', 'config.json')
kwargs = {'cache_dir': '/github/home/.cache/huggingface/hub', 'force_download': False, 'local_files_only': False, 'proxies': None, ...}
has_token = False, arg_name = 'local_files_only', arg_value = False
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
repo_id = 'meta-llama/Meta-Llama-3-8B-Instruct', filename = 'config.json'
@validate_hf_hub_args
def hf_hub_download(
repo_id: str,
filename: str,
*,
subfolder: Optional[str] = None,
repo_type: Optional[str] = None,
revision: Optional[str] = None,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
cache_dir: Union[str, Path, None] = None,
local_dir: Union[str, Path, None] = None,
user_agent: Union[Dict, str, None] = None,
force_download: bool = False,
proxies: Optional[Dict] = None,
etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
token: Union[bool, str, None] = None,
local_files_only: bool = False,
headers: Optional[Dict[str, str]] = None,
endpoint: Optional[str] = None,
resume_download: Optional[bool] = None,
force_filename: Optional[str] = None,
local_dir_use_symlinks: Union[bool, Literal["auto"]] = "auto",
) -> str:
"""Download a given file if it's not already present in the local cache.
The new cache file layout looks like this:
- The cache directory contains one subfolder per repo_id (namespaced by repo type)
- inside each repo folder:
- refs is a list of the latest known revision => commit_hash pairs
- blobs contains the actual file blobs (identified by their git-sha or sha256, depending on
whether they're LFS files or not)
- snapshots contains one subfolder per commit, each "commit" contains the subset of the files
that have been resolved at that particular commit. Each filename is a symlink to the blob
at that particular commit.
```
[ 96] .
└── [ 160] models--julien-c--EsperBERTo-small
├── [ 160] blobs
│ ├── [321M] 403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
│ ├── [ 398] 7cb18dc9bafbfcf74629a4b760af1b160957a83e
│ └── [1.4K] d7edf6bd2a681fb0175f7735299831ee1b22b812
├── [ 96] refs
│ └── [ 40] main
└── [ 128] snapshots
├── [ 128] 2439f60ef33a0d46d85da5001d52aeda5b00ce9f
│ ├── [ 52] README.md -> ../../blobs/d7edf6bd2a681fb0175f7735299831ee1b22b812
│ └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
└── [ 128] bbc77c8132af1cc5cf678da3f1ddf2de43606d48
├── [ 52] README.md -> ../../blobs/7cb18dc9bafbfcf74629a4b760af1b160957a83e
└── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
```
If `local_dir` is provided, the file structure from the repo will be replicated in this location. When using this
option, the `cache_dir` will not be used and a `.cache/huggingface/` folder will be created at the root of `local_dir`
to store some metadata related to the downloaded files. While this mechanism is not as robust as the main
cache-system, it's optimized for regularly pulling the latest version of a repository.
Args:
repo_id (`str`):
A user or an organization name and a repo name separated by a `/`.
filename (`str`):
The name of the file in the repo.
subfolder (`str`, *optional*):
An optional value corresponding to a folder inside the model repo.
repo_type (`str`, *optional*):
Set to `"dataset"` or `"space"` if downloading from a dataset or space,
`None` or `"model"` if downloading from a model. Default is `None`.
revision (`str`, *optional*):
An optional Git revision id which can be a branch name, a tag, or a
commit hash.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
cache_dir (`str`, `Path`, *optional*):
Path to the folder where cached files are stored.
local_dir (`str` or `Path`, *optional*):
If provided, the downloaded file will be placed under this directory.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
force_download (`bool`, *optional*, defaults to `False`):
Whether the file should be downloaded even if it already exists in
the local cache.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
etag_timeout (`float`, *optional*, defaults to `10`):
When fetching ETag, how many seconds to wait for the server to send
data before giving up which is passed to `requests.request`.
token (`str`, `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If a string, it's used as the authentication token.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, avoid downloading the file and return the path to the
local cached file if it exists.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
`str`: Local path of file or if networking is off, last version of file cached on disk.
Raises:
[`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it doesn't exist,
or because it is set to `private` and you do not have access.
[`~utils.RevisionNotFoundError`]
If the revision to download from cannot be found.
[`~utils.EntryNotFoundError`]
If the file to download cannot be found.
[`~utils.LocalEntryNotFoundError`]
If network is disabled or unavailable and file is not found in cache.
[`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
If `token=True` but the token cannot be found.
[`OSError`](https://docs.python.org/3/library/exceptions.html#OSError)
If ETag cannot be determined.
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
If some parameter value is invalid.
"""
if constants.HF_HUB_ETAG_TIMEOUT != constants.DEFAULT_ETAG_TIMEOUT:
# Respect environment variable above user value
etag_timeout = constants.HF_HUB_ETAG_TIMEOUT
if force_filename is not None:
warnings.warn(
"The `force_filename` parameter is deprecated as a new caching system, "
"which keeps the filenames as they are on the Hub, is now in place.",
FutureWarning,
)
if resume_download is not None:
warnings.warn(
"`resume_download` is deprecated and will be removed in version 1.0.0. "
"Downloads always resume when possible. "
"If you want to force a new download, use `force_download=True`.",
FutureWarning,
)
if cache_dir is None:
cache_dir = constants.HF_HUB_CACHE
if revision is None:
revision = constants.DEFAULT_REVISION
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if isinstance(local_dir, Path):
local_dir = str(local_dir)
if subfolder == "":
subfolder = None
if subfolder is not None:
# This is used to create a URL, and not a local path, hence the forward slash.
filename = f"{subfolder}/{filename}"
if repo_type is None:
repo_type = "model"
if repo_type not in constants.REPO_TYPES:
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(constants.REPO_TYPES)}")
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
if local_dir is not None:
if local_dir_use_symlinks != "auto":
warnings.warn(
"`local_dir_use_symlinks` parameter is deprecated and will be ignored. "
"The process to download files to a local folder has been updated and do "
"not rely on symlinks anymore. You only need to pass a destination folder "
"as`local_dir`.\n"
"For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder."
)
return _hf_hub_download_to_local_dir(
# Destination
local_dir=local_dir,
# File info
repo_id=repo_id,
repo_type=repo_type,
filename=filename,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
)
else:
> return _hf_hub_download_to_cache_dir(
# Destination
cache_dir=cache_dir,
# File info
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
local_files_only=local_files_only,
force_download=force_download,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:860:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _hf_hub_download_to_cache_dir(
*,
# Destination
cache_dir: str,
# File info
repo_id: str,
filename: str,
repo_type: str,
revision: str,
# HTTP info
endpoint: Optional[str],
etag_timeout: float,
headers: Dict[str, str],
proxies: Optional[Dict],
token: Optional[Union[bool, str]],
# Additional options
local_files_only: bool,
force_download: bool,
) -> str:
"""Download a given file to a cache folder, if not already present.
Method should not be called directly. Please use `hf_hub_download` instead.
"""
locks_dir = os.path.join(cache_dir, ".locks")
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
# cross platform transcription of filename, to be used as a local file path.
relative_filename = os.path.join(*filename.split("/"))
if os.name == "nt":
if relative_filename.startswith("..\\") or "\\..\\" in relative_filename:
raise ValueError(
f"Invalid filename: cannot handle filename '{relative_filename}' on Windows. Please ask the repository"
" owner to rename this file."
)
# if user provides a commit_hash and they already have the file on disk, shortcut everything.
if REGEX_COMMIT_HASH.match(revision):
pointer_path = _get_pointer_path(storage_folder, revision, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Try to get metadata (etag, commit_hash, url, size) from the server.
# If we can't, a HEAD request error is returned.
(url_to_download, etag, commit_hash, expected_size, head_call_error) = _get_metadata_or_catch_error(
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
endpoint=endpoint,
proxies=proxies,
etag_timeout=etag_timeout,
headers=headers,
token=token,
local_files_only=local_files_only,
storage_folder=storage_folder,
relative_filename=relative_filename,
)
# etag can be None for several reasons:
# 1. we passed local_files_only.
# 2. we don't have a connection
# 3. Hub is down (HTTP 500, 503, 504)
# 4. repo is not found -for example private or gated- and invalid/missing token sent
# 5. Hub is blocked by a firewall or proxy is not set correctly.
# => Try to get the last downloaded one from the specified revision.
#
# If the specified revision is a commit hash, look inside "snapshots".
# If the specified revision is a branch or tag, look inside "refs".
if head_call_error is not None:
# Couldn't make a HEAD call => let's try to find a local file
if not force_download:
commit_hash = None
if REGEX_COMMIT_HASH.match(revision):
commit_hash = revision
else:
ref_path = os.path.join(storage_folder, "refs", revision)
if os.path.isfile(ref_path):
with open(ref_path) as f:
commit_hash = f.read()
# Return pointer file if exists
if commit_hash is not None:
pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Otherwise, raise appropriate error
> _raise_on_head_call_error(head_call_error, force_download, local_files_only)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:967:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
head_call_error = GatedRepoError('401 Client Error. (Request ID: Root=1-67660e69-3621c16a3edfee2b1de55789;12d9f1d6-479f-4134-a90a-d7bc85.../Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.')
force_download = False, local_files_only = False
def _raise_on_head_call_error(head_call_error: Exception, force_download: bool, local_files_only: bool) -> NoReturn:
"""Raise an appropriate error when the HEAD call failed and we cannot locate a local file."""
# No head call => we cannot force download.
if force_download:
if local_files_only:
raise ValueError("Cannot pass 'force_download=True' and 'local_files_only=True' at the same time.")
elif isinstance(head_call_error, OfflineModeIsEnabled):
raise ValueError("Cannot pass 'force_download=True' when offline mode is enabled.") from head_call_error
else:
raise ValueError("Force download failed due to the above error.") from head_call_error
# No head call + couldn't find an appropriate file on disk => raise an error.
if local_files_only:
raise LocalEntryNotFoundError(
"Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable"
" hf.co look-ups and downloads online, set 'local_files_only' to False."
)
elif isinstance(head_call_error, RepositoryNotFoundError) or isinstance(head_call_error, GatedRepoError):
# Repo not found or gated => let's raise the actual error
> raise head_call_error
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1482:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _get_metadata_or_catch_error(
*,
repo_id: str,
filename: str,
repo_type: str,
revision: str,
endpoint: Optional[str],
proxies: Optional[Dict],
etag_timeout: Optional[float],
headers: Dict[str, str], # mutated inplace!
token: Union[bool, str, None],
local_files_only: bool,
relative_filename: Optional[str] = None, # only used to store `.no_exists` in cache
storage_folder: Optional[str] = None, # only used to store `.no_exists` in cache
) -> Union[
# Either an exception is caught and returned
Tuple[None, None, None, None, Exception],
# Or the metadata is returned as
# `(url_to_download, etag, commit_hash, expected_size, None)`
Tuple[str, str, str, int, None],
]:
"""Get metadata for a file on the Hub, safely handling network issues.
Returns either the etag, commit_hash and expected size of the file, or the error
raised while fetching the metadata.
NOTE: This function mutates `headers` inplace! It removes the `authorization` header
if the file is a LFS blob and the domain of the url is different from the
domain of the location (typically an S3 bucket).
"""
if local_files_only:
return (
None,
None,
None,
None,
OfflineModeIsEnabled(
f"Cannot access file since 'local_files_only=True' as been set. (repo_id: {repo_id}, repo_type: {repo_type}, revision: {revision}, filename: {filename})"
),
)
url = hf_hub_url(repo_id, filename, repo_type=repo_type, revision=revision, endpoint=endpoint)
url_to_download: str = url
etag: Optional[str] = None
commit_hash: Optional[str] = None
expected_size: Optional[int] = None
head_error_call: Optional[Exception] = None
# Try to get metadata from the server.
# Do not raise yet if the file is not found or not accessible.
if not local_files_only:
try:
try:
> metadata = get_hf_file_metadata(
url=url, proxies=proxies, timeout=etag_timeout, headers=headers, token=token
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1374:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ()
kwargs = {'headers': {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0;...3f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10, 'token': None, ...}
has_token = False, arg_name = 'token', arg_value = None
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json'
token = None, proxies = None, timeout = 10, library_name = None
library_version = None, user_agent = None
headers = {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; transformers/4.47.0; session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}
@validate_hf_hub_args
def get_hf_file_metadata(
url: str,
token: Union[bool, str, None] = None,
proxies: Optional[Dict] = None,
timeout: Optional[float] = constants.DEFAULT_REQUEST_TIMEOUT,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
user_agent: Union[Dict, str, None] = None,
headers: Optional[Dict[str, str]] = None,
) -> HfFileMetadata:
"""Fetch metadata of a file versioned on the Hub for a given url.
Args:
url (`str`):
File url, for example returned by [`hf_hub_url`].
token (`str` or `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If `False` or `None`, no token is provided.
- If a string, it's used as the authentication token.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
timeout (`float`, *optional*, defaults to 10):
How many seconds to wait for the server to send metadata before giving up.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
A [`HfFileMetadata`] object containing metadata such as location, etag, size and
commit_hash.
"""
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
hf_headers["Accept-Encoding"] = "identity" # prevent any compression => we want to know the real size of the file
# Retrieve metadata
> r = _request_wrapper(
method="HEAD",
url=url,
headers=hf_headers,
allow_redirects=False,
follow_relative_redirects=True,
proxies=proxies,
timeout=timeout,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1294:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = True
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
> response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:278:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = False
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
response = <Response [401]>
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
# If redirection, we redirect only relative paths.
# This is useful in case of a renamed repository.
if 300 <= response.status_code <= 399:
parsed_target = urlparse(response.headers["Location"])
if parsed_target.netloc == "":
# This means it is a relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# We want to follow this relative redirect !
#
# Highly inspired by `resolve_redirects` from requests library.
# See https://github.com/psf/requests/blob/main/requests/sessions.py#L159
next_url = urlparse(url)._replace(path=parsed_target.path).geturl()
return _request_wrapper(method=method, url=next_url, follow_relative_redirects=True, **params)
return response
# Perform request and return if status_code is not in the retry list.
response = get_session().request(method=method, url=url, **params)
> hf_raise_for_status(response)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:302:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
response.raise_for_status()
except HTTPError as e:
error_code = response.headers.get("X-Error-Code")
error_message = response.headers.get("X-Error-Message")
if error_code == "RevisionNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
raise _format(RevisionNotFoundError, message, response) from e
elif error_code == "EntryNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
raise _format(EntryNotFoundError, message, response) from e
elif error_code == "GatedRepo":
message = (
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
)
> raise _format(GatedRepoError, message, response) from e
E huggingface_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-67660e69-3621c16a3edfee2b1de55789;12d9f1d6-479f-4134-a90a-d7bc8531b0ea)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:423: GatedRepoError
The above exception was the direct cause of the following exception:
variant = 'meta-llama/Meta-Llama-3-8B-Instruct', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_llama3_causal_lm(variant, test_device):
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Load model (with tokenizer)
> tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
forge/test/models/pytorch/text/llama/test_llama3.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/test/utils.py:15: in download_model
return download_func(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py:878: in from_pretrained
config = AutoConfig.from_pretrained(
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:1021: in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:590: in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:649: in _get_config_dict
resolved_config_file = cached_file(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path_or_repo_id = 'meta-llama/Meta-Llama-3-8B-Instruct'
filename = 'config.json', cache_dir = '/github/home/.cache/huggingface/hub'
force_download = False, resume_download = None, proxies = None, token = None
revision = None, local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
except GatedRepoError as e:
resolved_file = _get_cache_file_to_return(path_or_repo_id, full_filename, cache_dir, revision)
if resolved_file is not None or not _raise_exceptions_for_gated_repo:
return resolved_file
> raise EnvironmentError(
"You are trying to access a gated repo.\nMake sure to have access to it at "
f"https://huggingface.co/{path_or_repo_id}.\n{str(e)}"
) from e
E OSError: You are trying to access a gated repo.
E Make sure to have access to it at https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct.
E 401 Client Error. (Request ID: Root=1-67660e69-3621c16a3edfee2b1de55789;12d9f1d6-479f-4134-a90a-d7bc8531b0ea)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:421: OSError
Check failure on line 128 in forge/test/models/pytorch/text/llama/test_llama3.py
github-actions / TT-Forge-FE Tests
test_llama3.test_llama3_causal_lm[no_device-meta-llama/Llama-3.1-8B-Instruct]
OSError: You are trying to access a gated repo.
Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct.
401 Client Error. (Request ID: Root=1-67660e69-7acfb2bc4c45ab9a1cfb3fe0;ebed6745-26e2-4cfb-bf5f-42b6fb9de8cf)
Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json.
Access to model meta-llama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
Raw output
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
> response.raise_for_status()
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
path_or_repo_id = 'meta-llama/Llama-3.1-8B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
> resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:403:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ('meta-llama/Llama-3.1-8B-Instruct', 'config.json')
kwargs = {'cache_dir': '/github/home/.cache/huggingface/hub', 'force_download': False, 'local_files_only': False, 'proxies': None, ...}
has_token = False, arg_name = 'local_files_only', arg_value = False
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
repo_id = 'meta-llama/Llama-3.1-8B-Instruct', filename = 'config.json'
@validate_hf_hub_args
def hf_hub_download(
repo_id: str,
filename: str,
*,
subfolder: Optional[str] = None,
repo_type: Optional[str] = None,
revision: Optional[str] = None,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
cache_dir: Union[str, Path, None] = None,
local_dir: Union[str, Path, None] = None,
user_agent: Union[Dict, str, None] = None,
force_download: bool = False,
proxies: Optional[Dict] = None,
etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
token: Union[bool, str, None] = None,
local_files_only: bool = False,
headers: Optional[Dict[str, str]] = None,
endpoint: Optional[str] = None,
resume_download: Optional[bool] = None,
force_filename: Optional[str] = None,
local_dir_use_symlinks: Union[bool, Literal["auto"]] = "auto",
) -> str:
"""Download a given file if it's not already present in the local cache.
The new cache file layout looks like this:
- The cache directory contains one subfolder per repo_id (namespaced by repo type)
- inside each repo folder:
- refs is a list of the latest known revision => commit_hash pairs
- blobs contains the actual file blobs (identified by their git-sha or sha256, depending on
whether they're LFS files or not)
- snapshots contains one subfolder per commit, each "commit" contains the subset of the files
that have been resolved at that particular commit. Each filename is a symlink to the blob
at that particular commit.
```
[ 96] .
└── [ 160] models--julien-c--EsperBERTo-small
├── [ 160] blobs
│ ├── [321M] 403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
│ ├── [ 398] 7cb18dc9bafbfcf74629a4b760af1b160957a83e
│ └── [1.4K] d7edf6bd2a681fb0175f7735299831ee1b22b812
├── [ 96] refs
│ └── [ 40] main
└── [ 128] snapshots
├── [ 128] 2439f60ef33a0d46d85da5001d52aeda5b00ce9f
│ ├── [ 52] README.md -> ../../blobs/d7edf6bd2a681fb0175f7735299831ee1b22b812
│ └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
└── [ 128] bbc77c8132af1cc5cf678da3f1ddf2de43606d48
├── [ 52] README.md -> ../../blobs/7cb18dc9bafbfcf74629a4b760af1b160957a83e
└── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
```
If `local_dir` is provided, the file structure from the repo will be replicated in this location. When using this
option, the `cache_dir` will not be used and a `.cache/huggingface/` folder will be created at the root of `local_dir`
to store some metadata related to the downloaded files. While this mechanism is not as robust as the main
cache-system, it's optimized for regularly pulling the latest version of a repository.
Args:
repo_id (`str`):
A user or an organization name and a repo name separated by a `/`.
filename (`str`):
The name of the file in the repo.
subfolder (`str`, *optional*):
An optional value corresponding to a folder inside the model repo.
repo_type (`str`, *optional*):
Set to `"dataset"` or `"space"` if downloading from a dataset or space,
`None` or `"model"` if downloading from a model. Default is `None`.
revision (`str`, *optional*):
An optional Git revision id which can be a branch name, a tag, or a
commit hash.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
cache_dir (`str`, `Path`, *optional*):
Path to the folder where cached files are stored.
local_dir (`str` or `Path`, *optional*):
If provided, the downloaded file will be placed under this directory.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
force_download (`bool`, *optional*, defaults to `False`):
Whether the file should be downloaded even if it already exists in
the local cache.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
etag_timeout (`float`, *optional*, defaults to `10`):
When fetching ETag, how many seconds to wait for the server to send
data before giving up which is passed to `requests.request`.
token (`str`, `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If a string, it's used as the authentication token.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, avoid downloading the file and return the path to the
local cached file if it exists.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
`str`: Local path of file or if networking is off, last version of file cached on disk.
Raises:
[`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it doesn't exist,
or because it is set to `private` and you do not have access.
[`~utils.RevisionNotFoundError`]
If the revision to download from cannot be found.
[`~utils.EntryNotFoundError`]
If the file to download cannot be found.
[`~utils.LocalEntryNotFoundError`]
If network is disabled or unavailable and file is not found in cache.
[`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
If `token=True` but the token cannot be found.
[`OSError`](https://docs.python.org/3/library/exceptions.html#OSError)
If ETag cannot be determined.
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
If some parameter value is invalid.
"""
if constants.HF_HUB_ETAG_TIMEOUT != constants.DEFAULT_ETAG_TIMEOUT:
# Respect environment variable above user value
etag_timeout = constants.HF_HUB_ETAG_TIMEOUT
if force_filename is not None:
warnings.warn(
"The `force_filename` parameter is deprecated as a new caching system, "
"which keeps the filenames as they are on the Hub, is now in place.",
FutureWarning,
)
if resume_download is not None:
warnings.warn(
"`resume_download` is deprecated and will be removed in version 1.0.0. "
"Downloads always resume when possible. "
"If you want to force a new download, use `force_download=True`.",
FutureWarning,
)
if cache_dir is None:
cache_dir = constants.HF_HUB_CACHE
if revision is None:
revision = constants.DEFAULT_REVISION
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if isinstance(local_dir, Path):
local_dir = str(local_dir)
if subfolder == "":
subfolder = None
if subfolder is not None:
# This is used to create a URL, and not a local path, hence the forward slash.
filename = f"{subfolder}/{filename}"
if repo_type is None:
repo_type = "model"
if repo_type not in constants.REPO_TYPES:
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(constants.REPO_TYPES)}")
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
if local_dir is not None:
if local_dir_use_symlinks != "auto":
warnings.warn(
"`local_dir_use_symlinks` parameter is deprecated and will be ignored. "
"The process to download files to a local folder has been updated and do "
"not rely on symlinks anymore. You only need to pass a destination folder "
"as`local_dir`.\n"
"For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder."
)
return _hf_hub_download_to_local_dir(
# Destination
local_dir=local_dir,
# File info
repo_id=repo_id,
repo_type=repo_type,
filename=filename,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
)
else:
> return _hf_hub_download_to_cache_dir(
# Destination
cache_dir=cache_dir,
# File info
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
local_files_only=local_files_only,
force_download=force_download,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:860:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _hf_hub_download_to_cache_dir(
*,
# Destination
cache_dir: str,
# File info
repo_id: str,
filename: str,
repo_type: str,
revision: str,
# HTTP info
endpoint: Optional[str],
etag_timeout: float,
headers: Dict[str, str],
proxies: Optional[Dict],
token: Optional[Union[bool, str]],
# Additional options
local_files_only: bool,
force_download: bool,
) -> str:
"""Download a given file to a cache folder, if not already present.
Method should not be called directly. Please use `hf_hub_download` instead.
"""
locks_dir = os.path.join(cache_dir, ".locks")
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
# cross platform transcription of filename, to be used as a local file path.
relative_filename = os.path.join(*filename.split("/"))
if os.name == "nt":
if relative_filename.startswith("..\\") or "\\..\\" in relative_filename:
raise ValueError(
f"Invalid filename: cannot handle filename '{relative_filename}' on Windows. Please ask the repository"
" owner to rename this file."
)
# if user provides a commit_hash and they already have the file on disk, shortcut everything.
if REGEX_COMMIT_HASH.match(revision):
pointer_path = _get_pointer_path(storage_folder, revision, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Try to get metadata (etag, commit_hash, url, size) from the server.
# If we can't, a HEAD request error is returned.
(url_to_download, etag, commit_hash, expected_size, head_call_error) = _get_metadata_or_catch_error(
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
endpoint=endpoint,
proxies=proxies,
etag_timeout=etag_timeout,
headers=headers,
token=token,
local_files_only=local_files_only,
storage_folder=storage_folder,
relative_filename=relative_filename,
)
# etag can be None for several reasons:
# 1. we passed local_files_only.
# 2. we don't have a connection
# 3. Hub is down (HTTP 500, 503, 504)
# 4. repo is not found -for example private or gated- and invalid/missing token sent
# 5. Hub is blocked by a firewall or proxy is not set correctly.
# => Try to get the last downloaded one from the specified revision.
#
# If the specified revision is a commit hash, look inside "snapshots".
# If the specified revision is a branch or tag, look inside "refs".
if head_call_error is not None:
# Couldn't make a HEAD call => let's try to find a local file
if not force_download:
commit_hash = None
if REGEX_COMMIT_HASH.match(revision):
commit_hash = revision
else:
ref_path = os.path.join(storage_folder, "refs", revision)
if os.path.isfile(ref_path):
with open(ref_path) as f:
commit_hash = f.read()
# Return pointer file if exists
if commit_hash is not None:
pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Otherwise, raise appropriate error
> _raise_on_head_call_error(head_call_error, force_download, local_files_only)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:967:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
head_call_error = GatedRepoError('401 Client Error. (Request ID: Root=1-67660e69-7acfb2bc4c45ab9a1cfb3fe0;ebed6745-26e2-4cfb-bf5f-42b6fb...ama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.')
force_download = False, local_files_only = False
def _raise_on_head_call_error(head_call_error: Exception, force_download: bool, local_files_only: bool) -> NoReturn:
"""Raise an appropriate error when the HEAD call failed and we cannot locate a local file."""
# No head call => we cannot force download.
if force_download:
if local_files_only:
raise ValueError("Cannot pass 'force_download=True' and 'local_files_only=True' at the same time.")
elif isinstance(head_call_error, OfflineModeIsEnabled):
raise ValueError("Cannot pass 'force_download=True' when offline mode is enabled.") from head_call_error
else:
raise ValueError("Force download failed due to the above error.") from head_call_error
# No head call + couldn't find an appropriate file on disk => raise an error.
if local_files_only:
raise LocalEntryNotFoundError(
"Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable"
" hf.co look-ups and downloads online, set 'local_files_only' to False."
)
elif isinstance(head_call_error, RepositoryNotFoundError) or isinstance(head_call_error, GatedRepoError):
# Repo not found or gated => let's raise the actual error
> raise head_call_error
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1482:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _get_metadata_or_catch_error(
*,
repo_id: str,
filename: str,
repo_type: str,
revision: str,
endpoint: Optional[str],
proxies: Optional[Dict],
etag_timeout: Optional[float],
headers: Dict[str, str], # mutated inplace!
token: Union[bool, str, None],
local_files_only: bool,
relative_filename: Optional[str] = None, # only used to store `.no_exists` in cache
storage_folder: Optional[str] = None, # only used to store `.no_exists` in cache
) -> Union[
# Either an exception is caught and returned
Tuple[None, None, None, None, Exception],
# Or the metadata is returned as
# `(url_to_download, etag, commit_hash, expected_size, None)`
Tuple[str, str, str, int, None],
]:
"""Get metadata for a file on the Hub, safely handling network issues.
Returns either the etag, commit_hash and expected size of the file, or the error
raised while fetching the metadata.
NOTE: This function mutates `headers` inplace! It removes the `authorization` header
if the file is a LFS blob and the domain of the url is different from the
domain of the location (typically an S3 bucket).
"""
if local_files_only:
return (
None,
None,
None,
None,
OfflineModeIsEnabled(
f"Cannot access file since 'local_files_only=True' as been set. (repo_id: {repo_id}, repo_type: {repo_type}, revision: {revision}, filename: {filename})"
),
)
url = hf_hub_url(repo_id, filename, repo_type=repo_type, revision=revision, endpoint=endpoint)
url_to_download: str = url
etag: Optional[str] = None
commit_hash: Optional[str] = None
expected_size: Optional[int] = None
head_error_call: Optional[Exception] = None
# Try to get metadata from the server.
# Do not raise yet if the file is not found or not accessible.
if not local_files_only:
try:
try:
> metadata = get_hf_file_metadata(
url=url, proxies=proxies, timeout=etag_timeout, headers=headers, token=token
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1374:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ()
kwargs = {'headers': {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0;...3f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10, 'token': None, ...}
has_token = False, arg_name = 'token', arg_value = None
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json'
token = None, proxies = None, timeout = 10, library_name = None
library_version = None, user_agent = None
headers = {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; transformers/4.47.0; session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}
@validate_hf_hub_args
def get_hf_file_metadata(
url: str,
token: Union[bool, str, None] = None,
proxies: Optional[Dict] = None,
timeout: Optional[float] = constants.DEFAULT_REQUEST_TIMEOUT,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
user_agent: Union[Dict, str, None] = None,
headers: Optional[Dict[str, str]] = None,
) -> HfFileMetadata:
"""Fetch metadata of a file versioned on the Hub for a given url.
Args:
url (`str`):
File url, for example returned by [`hf_hub_url`].
token (`str` or `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If `False` or `None`, no token is provided.
- If a string, it's used as the authentication token.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
timeout (`float`, *optional*, defaults to 10):
How many seconds to wait for the server to send metadata before giving up.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
A [`HfFileMetadata`] object containing metadata such as location, etag, size and
commit_hash.
"""
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
hf_headers["Accept-Encoding"] = "identity" # prevent any compression => we want to know the real size of the file
# Retrieve metadata
> r = _request_wrapper(
method="HEAD",
url=url,
headers=hf_headers,
allow_redirects=False,
follow_relative_redirects=True,
proxies=proxies,
timeout=timeout,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1294:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = True
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
> response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:278:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = False
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
response = <Response [401]>
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
# If redirection, we redirect only relative paths.
# This is useful in case of a renamed repository.
if 300 <= response.status_code <= 399:
parsed_target = urlparse(response.headers["Location"])
if parsed_target.netloc == "":
# This means it is a relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# We want to follow this relative redirect !
#
# Highly inspired by `resolve_redirects` from requests library.
# See https://github.com/psf/requests/blob/main/requests/sessions.py#L159
next_url = urlparse(url)._replace(path=parsed_target.path).geturl()
return _request_wrapper(method=method, url=next_url, follow_relative_redirects=True, **params)
return response
# Perform request and return if status_code is not in the retry list.
response = get_session().request(method=method, url=url, **params)
> hf_raise_for_status(response)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:302:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
response.raise_for_status()
except HTTPError as e:
error_code = response.headers.get("X-Error-Code")
error_message = response.headers.get("X-Error-Message")
if error_code == "RevisionNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
raise _format(RevisionNotFoundError, message, response) from e
elif error_code == "EntryNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
raise _format(EntryNotFoundError, message, response) from e
elif error_code == "GatedRepo":
message = (
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
)
> raise _format(GatedRepoError, message, response) from e
E huggingface_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-67660e69-7acfb2bc4c45ab9a1cfb3fe0;ebed6745-26e2-4cfb-bf5f-42b6fb9de8cf)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:423: GatedRepoError
The above exception was the direct cause of the following exception:
variant = 'meta-llama/Llama-3.1-8B-Instruct', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_llama3_causal_lm(variant, test_device):
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Load model (with tokenizer)
> tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
forge/test/models/pytorch/text/llama/test_llama3.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/test/utils.py:15: in download_model
return download_func(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py:878: in from_pretrained
config = AutoConfig.from_pretrained(
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:1021: in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:590: in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:649: in _get_config_dict
resolved_config_file = cached_file(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path_or_repo_id = 'meta-llama/Llama-3.1-8B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
except GatedRepoError as e:
resolved_file = _get_cache_file_to_return(path_or_repo_id, full_filename, cache_dir, revision)
if resolved_file is not None or not _raise_exceptions_for_gated_repo:
return resolved_file
> raise EnvironmentError(
"You are trying to access a gated repo.\nMake sure to have access to it at "
f"https://huggingface.co/{path_or_repo_id}.\n{str(e)}"
) from e
E OSError: You are trying to access a gated repo.
E Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct.
E 401 Client Error. (Request ID: Root=1-67660e69-7acfb2bc4c45ab9a1cfb3fe0;ebed6745-26e2-4cfb-bf5f-42b6fb9de8cf)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:421: OSError
Check failure on line 128 in forge/test/models/pytorch/text/llama/test_llama3.py
github-actions / TT-Forge-FE Tests
test_llama3.test_llama3_causal_lm[no_device-meta-llama/Llama-3.2-1B-Instruct]
OSError: You are trying to access a gated repo.
Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct.
401 Client Error. (Request ID: Root=1-67660e69-686765224a9df84c50313d6e;190c776d-d322-4bc8-9f1b-be5aa3c95044)
Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json.
Access to model meta-llama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
Raw output
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
> response.raise_for_status()
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
path_or_repo_id = 'meta-llama/Llama-3.2-1B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
> resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:403:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ('meta-llama/Llama-3.2-1B-Instruct', 'config.json')
kwargs = {'cache_dir': '/github/home/.cache/huggingface/hub', 'force_download': False, 'local_files_only': False, 'proxies': None, ...}
has_token = False, arg_name = 'local_files_only', arg_value = False
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
repo_id = 'meta-llama/Llama-3.2-1B-Instruct', filename = 'config.json'
@validate_hf_hub_args
def hf_hub_download(
repo_id: str,
filename: str,
*,
subfolder: Optional[str] = None,
repo_type: Optional[str] = None,
revision: Optional[str] = None,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
cache_dir: Union[str, Path, None] = None,
local_dir: Union[str, Path, None] = None,
user_agent: Union[Dict, str, None] = None,
force_download: bool = False,
proxies: Optional[Dict] = None,
etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
token: Union[bool, str, None] = None,
local_files_only: bool = False,
headers: Optional[Dict[str, str]] = None,
endpoint: Optional[str] = None,
resume_download: Optional[bool] = None,
force_filename: Optional[str] = None,
local_dir_use_symlinks: Union[bool, Literal["auto"]] = "auto",
) -> str:
"""Download a given file if it's not already present in the local cache.
The new cache file layout looks like this:
- The cache directory contains one subfolder per repo_id (namespaced by repo type)
- inside each repo folder:
- refs is a list of the latest known revision => commit_hash pairs
- blobs contains the actual file blobs (identified by their git-sha or sha256, depending on
whether they're LFS files or not)
- snapshots contains one subfolder per commit, each "commit" contains the subset of the files
that have been resolved at that particular commit. Each filename is a symlink to the blob
at that particular commit.
```
[ 96] .
└── [ 160] models--julien-c--EsperBERTo-small
├── [ 160] blobs
│ ├── [321M] 403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
│ ├── [ 398] 7cb18dc9bafbfcf74629a4b760af1b160957a83e
│ └── [1.4K] d7edf6bd2a681fb0175f7735299831ee1b22b812
├── [ 96] refs
│ └── [ 40] main
└── [ 128] snapshots
├── [ 128] 2439f60ef33a0d46d85da5001d52aeda5b00ce9f
│ ├── [ 52] README.md -> ../../blobs/d7edf6bd2a681fb0175f7735299831ee1b22b812
│ └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
└── [ 128] bbc77c8132af1cc5cf678da3f1ddf2de43606d48
├── [ 52] README.md -> ../../blobs/7cb18dc9bafbfcf74629a4b760af1b160957a83e
└── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
```
If `local_dir` is provided, the file structure from the repo will be replicated in this location. When using this
option, the `cache_dir` will not be used and a `.cache/huggingface/` folder will be created at the root of `local_dir`
to store some metadata related to the downloaded files. While this mechanism is not as robust as the main
cache-system, it's optimized for regularly pulling the latest version of a repository.
Args:
repo_id (`str`):
A user or an organization name and a repo name separated by a `/`.
filename (`str`):
The name of the file in the repo.
subfolder (`str`, *optional*):
An optional value corresponding to a folder inside the model repo.
repo_type (`str`, *optional*):
Set to `"dataset"` or `"space"` if downloading from a dataset or space,
`None` or `"model"` if downloading from a model. Default is `None`.
revision (`str`, *optional*):
An optional Git revision id which can be a branch name, a tag, or a
commit hash.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
cache_dir (`str`, `Path`, *optional*):
Path to the folder where cached files are stored.
local_dir (`str` or `Path`, *optional*):
If provided, the downloaded file will be placed under this directory.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
force_download (`bool`, *optional*, defaults to `False`):
Whether the file should be downloaded even if it already exists in
the local cache.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
etag_timeout (`float`, *optional*, defaults to `10`):
When fetching ETag, how many seconds to wait for the server to send
data before giving up which is passed to `requests.request`.
token (`str`, `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If a string, it's used as the authentication token.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, avoid downloading the file and return the path to the
local cached file if it exists.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
`str`: Local path of file or if networking is off, last version of file cached on disk.
Raises:
[`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it doesn't exist,
or because it is set to `private` and you do not have access.
[`~utils.RevisionNotFoundError`]
If the revision to download from cannot be found.
[`~utils.EntryNotFoundError`]
If the file to download cannot be found.
[`~utils.LocalEntryNotFoundError`]
If network is disabled or unavailable and file is not found in cache.
[`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
If `token=True` but the token cannot be found.
[`OSError`](https://docs.python.org/3/library/exceptions.html#OSError)
If ETag cannot be determined.
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
If some parameter value is invalid.
"""
if constants.HF_HUB_ETAG_TIMEOUT != constants.DEFAULT_ETAG_TIMEOUT:
# Respect environment variable above user value
etag_timeout = constants.HF_HUB_ETAG_TIMEOUT
if force_filename is not None:
warnings.warn(
"The `force_filename` parameter is deprecated as a new caching system, "
"which keeps the filenames as they are on the Hub, is now in place.",
FutureWarning,
)
if resume_download is not None:
warnings.warn(
"`resume_download` is deprecated and will be removed in version 1.0.0. "
"Downloads always resume when possible. "
"If you want to force a new download, use `force_download=True`.",
FutureWarning,
)
if cache_dir is None:
cache_dir = constants.HF_HUB_CACHE
if revision is None:
revision = constants.DEFAULT_REVISION
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if isinstance(local_dir, Path):
local_dir = str(local_dir)
if subfolder == "":
subfolder = None
if subfolder is not None:
# This is used to create a URL, and not a local path, hence the forward slash.
filename = f"{subfolder}/{filename}"
if repo_type is None:
repo_type = "model"
if repo_type not in constants.REPO_TYPES:
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(constants.REPO_TYPES)}")
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
if local_dir is not None:
if local_dir_use_symlinks != "auto":
warnings.warn(
"`local_dir_use_symlinks` parameter is deprecated and will be ignored. "
"The process to download files to a local folder has been updated and do "
"not rely on symlinks anymore. You only need to pass a destination folder "
"as`local_dir`.\n"
"For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder."
)
return _hf_hub_download_to_local_dir(
# Destination
local_dir=local_dir,
# File info
repo_id=repo_id,
repo_type=repo_type,
filename=filename,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
)
else:
> return _hf_hub_download_to_cache_dir(
# Destination
cache_dir=cache_dir,
# File info
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
local_files_only=local_files_only,
force_download=force_download,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:860:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _hf_hub_download_to_cache_dir(
*,
# Destination
cache_dir: str,
# File info
repo_id: str,
filename: str,
repo_type: str,
revision: str,
# HTTP info
endpoint: Optional[str],
etag_timeout: float,
headers: Dict[str, str],
proxies: Optional[Dict],
token: Optional[Union[bool, str]],
# Additional options
local_files_only: bool,
force_download: bool,
) -> str:
"""Download a given file to a cache folder, if not already present.
Method should not be called directly. Please use `hf_hub_download` instead.
"""
locks_dir = os.path.join(cache_dir, ".locks")
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
# cross platform transcription of filename, to be used as a local file path.
relative_filename = os.path.join(*filename.split("/"))
if os.name == "nt":
if relative_filename.startswith("..\\") or "\\..\\" in relative_filename:
raise ValueError(
f"Invalid filename: cannot handle filename '{relative_filename}' on Windows. Please ask the repository"
" owner to rename this file."
)
# if user provides a commit_hash and they already have the file on disk, shortcut everything.
if REGEX_COMMIT_HASH.match(revision):
pointer_path = _get_pointer_path(storage_folder, revision, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Try to get metadata (etag, commit_hash, url, size) from the server.
# If we can't, a HEAD request error is returned.
(url_to_download, etag, commit_hash, expected_size, head_call_error) = _get_metadata_or_catch_error(
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
endpoint=endpoint,
proxies=proxies,
etag_timeout=etag_timeout,
headers=headers,
token=token,
local_files_only=local_files_only,
storage_folder=storage_folder,
relative_filename=relative_filename,
)
# etag can be None for several reasons:
# 1. we passed local_files_only.
# 2. we don't have a connection
# 3. Hub is down (HTTP 500, 503, 504)
# 4. repo is not found -for example private or gated- and invalid/missing token sent
# 5. Hub is blocked by a firewall or proxy is not set correctly.
# => Try to get the last downloaded one from the specified revision.
#
# If the specified revision is a commit hash, look inside "snapshots".
# If the specified revision is a branch or tag, look inside "refs".
if head_call_error is not None:
# Couldn't make a HEAD call => let's try to find a local file
if not force_download:
commit_hash = None
if REGEX_COMMIT_HASH.match(revision):
commit_hash = revision
else:
ref_path = os.path.join(storage_folder, "refs", revision)
if os.path.isfile(ref_path):
with open(ref_path) as f:
commit_hash = f.read()
# Return pointer file if exists
if commit_hash is not None:
pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Otherwise, raise appropriate error
> _raise_on_head_call_error(head_call_error, force_download, local_files_only)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:967:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
head_call_error = GatedRepoError('401 Client Error. (Request ID: Root=1-67660e69-686765224a9df84c50313d6e;190c776d-d322-4bc8-9f1b-be5aa3...ama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.')
force_download = False, local_files_only = False
def _raise_on_head_call_error(head_call_error: Exception, force_download: bool, local_files_only: bool) -> NoReturn:
"""Raise an appropriate error when the HEAD call failed and we cannot locate a local file."""
# No head call => we cannot force download.
if force_download:
if local_files_only:
raise ValueError("Cannot pass 'force_download=True' and 'local_files_only=True' at the same time.")
elif isinstance(head_call_error, OfflineModeIsEnabled):
raise ValueError("Cannot pass 'force_download=True' when offline mode is enabled.") from head_call_error
else:
raise ValueError("Force download failed due to the above error.") from head_call_error
# No head call + couldn't find an appropriate file on disk => raise an error.
if local_files_only:
raise LocalEntryNotFoundError(
"Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable"
" hf.co look-ups and downloads online, set 'local_files_only' to False."
)
elif isinstance(head_call_error, RepositoryNotFoundError) or isinstance(head_call_error, GatedRepoError):
# Repo not found or gated => let's raise the actual error
> raise head_call_error
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1482:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _get_metadata_or_catch_error(
*,
repo_id: str,
filename: str,
repo_type: str,
revision: str,
endpoint: Optional[str],
proxies: Optional[Dict],
etag_timeout: Optional[float],
headers: Dict[str, str], # mutated inplace!
token: Union[bool, str, None],
local_files_only: bool,
relative_filename: Optional[str] = None, # only used to store `.no_exists` in cache
storage_folder: Optional[str] = None, # only used to store `.no_exists` in cache
) -> Union[
# Either an exception is caught and returned
Tuple[None, None, None, None, Exception],
# Or the metadata is returned as
# `(url_to_download, etag, commit_hash, expected_size, None)`
Tuple[str, str, str, int, None],
]:
"""Get metadata for a file on the Hub, safely handling network issues.
Returns either the etag, commit_hash and expected size of the file, or the error
raised while fetching the metadata.
NOTE: This function mutates `headers` inplace! It removes the `authorization` header
if the file is a LFS blob and the domain of the url is different from the
domain of the location (typically an S3 bucket).
"""
if local_files_only:
return (
None,
None,
None,
None,
OfflineModeIsEnabled(
f"Cannot access file since 'local_files_only=True' as been set. (repo_id: {repo_id}, repo_type: {repo_type}, revision: {revision}, filename: {filename})"
),
)
url = hf_hub_url(repo_id, filename, repo_type=repo_type, revision=revision, endpoint=endpoint)
url_to_download: str = url
etag: Optional[str] = None
commit_hash: Optional[str] = None
expected_size: Optional[int] = None
head_error_call: Optional[Exception] = None
# Try to get metadata from the server.
# Do not raise yet if the file is not found or not accessible.
if not local_files_only:
try:
try:
> metadata = get_hf_file_metadata(
url=url, proxies=proxies, timeout=etag_timeout, headers=headers, token=token
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1374:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ()
kwargs = {'headers': {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0;...3f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10, 'token': None, ...}
has_token = False, arg_name = 'token', arg_value = None
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json'
token = None, proxies = None, timeout = 10, library_name = None
library_version = None, user_agent = None
headers = {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; transformers/4.47.0; session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}
@validate_hf_hub_args
def get_hf_file_metadata(
url: str,
token: Union[bool, str, None] = None,
proxies: Optional[Dict] = None,
timeout: Optional[float] = constants.DEFAULT_REQUEST_TIMEOUT,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
user_agent: Union[Dict, str, None] = None,
headers: Optional[Dict[str, str]] = None,
) -> HfFileMetadata:
"""Fetch metadata of a file versioned on the Hub for a given url.
Args:
url (`str`):
File url, for example returned by [`hf_hub_url`].
token (`str` or `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If `False` or `None`, no token is provided.
- If a string, it's used as the authentication token.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
timeout (`float`, *optional*, defaults to 10):
How many seconds to wait for the server to send metadata before giving up.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
A [`HfFileMetadata`] object containing metadata such as location, etag, size and
commit_hash.
"""
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
hf_headers["Accept-Encoding"] = "identity" # prevent any compression => we want to know the real size of the file
# Retrieve metadata
> r = _request_wrapper(
method="HEAD",
url=url,
headers=hf_headers,
allow_redirects=False,
follow_relative_redirects=True,
proxies=proxies,
timeout=timeout,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1294:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json'
follow_relative_redirects = True
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
> response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:278:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json'
follow_relative_redirects = False
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
response = <Response [401]>
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
# If redirection, we redirect only relative paths.
# This is useful in case of a renamed repository.
if 300 <= response.status_code <= 399:
parsed_target = urlparse(response.headers["Location"])
if parsed_target.netloc == "":
# This means it is a relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# We want to follow this relative redirect !
#
# Highly inspired by `resolve_redirects` from requests library.
# See https://github.com/psf/requests/blob/main/requests/sessions.py#L159
next_url = urlparse(url)._replace(path=parsed_target.path).geturl()
return _request_wrapper(method=method, url=next_url, follow_relative_redirects=True, **params)
return response
# Perform request and return if status_code is not in the retry list.
response = get_session().request(method=method, url=url, **params)
> hf_raise_for_status(response)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:302:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
response.raise_for_status()
except HTTPError as e:
error_code = response.headers.get("X-Error-Code")
error_message = response.headers.get("X-Error-Message")
if error_code == "RevisionNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
raise _format(RevisionNotFoundError, message, response) from e
elif error_code == "EntryNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
raise _format(EntryNotFoundError, message, response) from e
elif error_code == "GatedRepo":
message = (
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
)
> raise _format(GatedRepoError, message, response) from e
E huggingface_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-67660e69-686765224a9df84c50313d6e;190c776d-d322-4bc8-9f1b-be5aa3c95044)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:423: GatedRepoError
The above exception was the direct cause of the following exception:
variant = 'meta-llama/Llama-3.2-1B-Instruct', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_llama3_causal_lm(variant, test_device):
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Load model (with tokenizer)
> tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
forge/test/models/pytorch/text/llama/test_llama3.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/test/utils.py:15: in download_model
return download_func(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py:878: in from_pretrained
config = AutoConfig.from_pretrained(
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:1021: in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:590: in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:649: in _get_config_dict
resolved_config_file = cached_file(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path_or_repo_id = 'meta-llama/Llama-3.2-1B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
except GatedRepoError as e:
resolved_file = _get_cache_file_to_return(path_or_repo_id, full_filename, cache_dir, revision)
if resolved_file is not None or not _raise_exceptions_for_gated_repo:
return resolved_file
> raise EnvironmentError(
"You are trying to access a gated repo.\nMake sure to have access to it at "
f"https://huggingface.co/{path_or_repo_id}.\n{str(e)}"
) from e
E OSError: You are trying to access a gated repo.
E Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct.
E 401 Client Error. (Request ID: Root=1-67660e69-686765224a9df84c50313d6e;190c776d-d322-4bc8-9f1b-be5aa3c95044)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:421: OSError
Check failure on line 172 in forge/test/models/pytorch/text/llama/test_llama3.py
github-actions / TT-Forge-FE Tests
test_llama3.test_llama3_sequence_classification[no_device-meta-llama/Meta-Llama-3-8B-Instruct]
OSError: You are trying to access a gated repo.
Make sure to have access to it at https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct.
401 Client Error. (Request ID: Root=1-67660e6a-0603b22218e29c2b31487d7b;6f131876-c327-4e98-a632-a70b2d17e2e9)
Cannot access gated repo for url https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json.
Access to model meta-llama/Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
Raw output
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
> response.raise_for_status()
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
path_or_repo_id = 'meta-llama/Meta-Llama-3-8B-Instruct'
filename = 'config.json', cache_dir = '/github/home/.cache/huggingface/hub'
force_download = False, resume_download = None, proxies = None, token = None
revision = None, local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
> resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:403:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ('meta-llama/Meta-Llama-3-8B-Instruct', 'config.json')
kwargs = {'cache_dir': '/github/home/.cache/huggingface/hub', 'force_download': False, 'local_files_only': False, 'proxies': None, ...}
has_token = False, arg_name = 'local_files_only', arg_value = False
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
repo_id = 'meta-llama/Meta-Llama-3-8B-Instruct', filename = 'config.json'
@validate_hf_hub_args
def hf_hub_download(
repo_id: str,
filename: str,
*,
subfolder: Optional[str] = None,
repo_type: Optional[str] = None,
revision: Optional[str] = None,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
cache_dir: Union[str, Path, None] = None,
local_dir: Union[str, Path, None] = None,
user_agent: Union[Dict, str, None] = None,
force_download: bool = False,
proxies: Optional[Dict] = None,
etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
token: Union[bool, str, None] = None,
local_files_only: bool = False,
headers: Optional[Dict[str, str]] = None,
endpoint: Optional[str] = None,
resume_download: Optional[bool] = None,
force_filename: Optional[str] = None,
local_dir_use_symlinks: Union[bool, Literal["auto"]] = "auto",
) -> str:
"""Download a given file if it's not already present in the local cache.
The new cache file layout looks like this:
- The cache directory contains one subfolder per repo_id (namespaced by repo type)
- inside each repo folder:
- refs is a list of the latest known revision => commit_hash pairs
- blobs contains the actual file blobs (identified by their git-sha or sha256, depending on
whether they're LFS files or not)
- snapshots contains one subfolder per commit, each "commit" contains the subset of the files
that have been resolved at that particular commit. Each filename is a symlink to the blob
at that particular commit.
```
[ 96] .
└── [ 160] models--julien-c--EsperBERTo-small
├── [ 160] blobs
│ ├── [321M] 403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
│ ├── [ 398] 7cb18dc9bafbfcf74629a4b760af1b160957a83e
│ └── [1.4K] d7edf6bd2a681fb0175f7735299831ee1b22b812
├── [ 96] refs
│ └── [ 40] main
└── [ 128] snapshots
├── [ 128] 2439f60ef33a0d46d85da5001d52aeda5b00ce9f
│ ├── [ 52] README.md -> ../../blobs/d7edf6bd2a681fb0175f7735299831ee1b22b812
│ └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
└── [ 128] bbc77c8132af1cc5cf678da3f1ddf2de43606d48
├── [ 52] README.md -> ../../blobs/7cb18dc9bafbfcf74629a4b760af1b160957a83e
└── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
```
If `local_dir` is provided, the file structure from the repo will be replicated in this location. When using this
option, the `cache_dir` will not be used and a `.cache/huggingface/` folder will be created at the root of `local_dir`
to store some metadata related to the downloaded files. While this mechanism is not as robust as the main
cache-system, it's optimized for regularly pulling the latest version of a repository.
Args:
repo_id (`str`):
A user or an organization name and a repo name separated by a `/`.
filename (`str`):
The name of the file in the repo.
subfolder (`str`, *optional*):
An optional value corresponding to a folder inside the model repo.
repo_type (`str`, *optional*):
Set to `"dataset"` or `"space"` if downloading from a dataset or space,
`None` or `"model"` if downloading from a model. Default is `None`.
revision (`str`, *optional*):
An optional Git revision id which can be a branch name, a tag, or a
commit hash.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
cache_dir (`str`, `Path`, *optional*):
Path to the folder where cached files are stored.
local_dir (`str` or `Path`, *optional*):
If provided, the downloaded file will be placed under this directory.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
force_download (`bool`, *optional*, defaults to `False`):
Whether the file should be downloaded even if it already exists in
the local cache.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
etag_timeout (`float`, *optional*, defaults to `10`):
When fetching ETag, how many seconds to wait for the server to send
data before giving up which is passed to `requests.request`.
token (`str`, `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If a string, it's used as the authentication token.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, avoid downloading the file and return the path to the
local cached file if it exists.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
`str`: Local path of file or if networking is off, last version of file cached on disk.
Raises:
[`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it doesn't exist,
or because it is set to `private` and you do not have access.
[`~utils.RevisionNotFoundError`]
If the revision to download from cannot be found.
[`~utils.EntryNotFoundError`]
If the file to download cannot be found.
[`~utils.LocalEntryNotFoundError`]
If network is disabled or unavailable and file is not found in cache.
[`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
If `token=True` but the token cannot be found.
[`OSError`](https://docs.python.org/3/library/exceptions.html#OSError)
If ETag cannot be determined.
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
If some parameter value is invalid.
"""
if constants.HF_HUB_ETAG_TIMEOUT != constants.DEFAULT_ETAG_TIMEOUT:
# Respect environment variable above user value
etag_timeout = constants.HF_HUB_ETAG_TIMEOUT
if force_filename is not None:
warnings.warn(
"The `force_filename` parameter is deprecated as a new caching system, "
"which keeps the filenames as they are on the Hub, is now in place.",
FutureWarning,
)
if resume_download is not None:
warnings.warn(
"`resume_download` is deprecated and will be removed in version 1.0.0. "
"Downloads always resume when possible. "
"If you want to force a new download, use `force_download=True`.",
FutureWarning,
)
if cache_dir is None:
cache_dir = constants.HF_HUB_CACHE
if revision is None:
revision = constants.DEFAULT_REVISION
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if isinstance(local_dir, Path):
local_dir = str(local_dir)
if subfolder == "":
subfolder = None
if subfolder is not None:
# This is used to create a URL, and not a local path, hence the forward slash.
filename = f"{subfolder}/{filename}"
if repo_type is None:
repo_type = "model"
if repo_type not in constants.REPO_TYPES:
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(constants.REPO_TYPES)}")
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
if local_dir is not None:
if local_dir_use_symlinks != "auto":
warnings.warn(
"`local_dir_use_symlinks` parameter is deprecated and will be ignored. "
"The process to download files to a local folder has been updated and do "
"not rely on symlinks anymore. You only need to pass a destination folder "
"as`local_dir`.\n"
"For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder."
)
return _hf_hub_download_to_local_dir(
# Destination
local_dir=local_dir,
# File info
repo_id=repo_id,
repo_type=repo_type,
filename=filename,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
)
else:
> return _hf_hub_download_to_cache_dir(
# Destination
cache_dir=cache_dir,
# File info
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
local_files_only=local_files_only,
force_download=force_download,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:860:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _hf_hub_download_to_cache_dir(
*,
# Destination
cache_dir: str,
# File info
repo_id: str,
filename: str,
repo_type: str,
revision: str,
# HTTP info
endpoint: Optional[str],
etag_timeout: float,
headers: Dict[str, str],
proxies: Optional[Dict],
token: Optional[Union[bool, str]],
# Additional options
local_files_only: bool,
force_download: bool,
) -> str:
"""Download a given file to a cache folder, if not already present.
Method should not be called directly. Please use `hf_hub_download` instead.
"""
locks_dir = os.path.join(cache_dir, ".locks")
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
# cross platform transcription of filename, to be used as a local file path.
relative_filename = os.path.join(*filename.split("/"))
if os.name == "nt":
if relative_filename.startswith("..\\") or "\\..\\" in relative_filename:
raise ValueError(
f"Invalid filename: cannot handle filename '{relative_filename}' on Windows. Please ask the repository"
" owner to rename this file."
)
# if user provides a commit_hash and they already have the file on disk, shortcut everything.
if REGEX_COMMIT_HASH.match(revision):
pointer_path = _get_pointer_path(storage_folder, revision, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Try to get metadata (etag, commit_hash, url, size) from the server.
# If we can't, a HEAD request error is returned.
(url_to_download, etag, commit_hash, expected_size, head_call_error) = _get_metadata_or_catch_error(
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
endpoint=endpoint,
proxies=proxies,
etag_timeout=etag_timeout,
headers=headers,
token=token,
local_files_only=local_files_only,
storage_folder=storage_folder,
relative_filename=relative_filename,
)
# etag can be None for several reasons:
# 1. we passed local_files_only.
# 2. we don't have a connection
# 3. Hub is down (HTTP 500, 503, 504)
# 4. repo is not found -for example private or gated- and invalid/missing token sent
# 5. Hub is blocked by a firewall or proxy is not set correctly.
# => Try to get the last downloaded one from the specified revision.
#
# If the specified revision is a commit hash, look inside "snapshots".
# If the specified revision is a branch or tag, look inside "refs".
if head_call_error is not None:
# Couldn't make a HEAD call => let's try to find a local file
if not force_download:
commit_hash = None
if REGEX_COMMIT_HASH.match(revision):
commit_hash = revision
else:
ref_path = os.path.join(storage_folder, "refs", revision)
if os.path.isfile(ref_path):
with open(ref_path) as f:
commit_hash = f.read()
# Return pointer file if exists
if commit_hash is not None:
pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Otherwise, raise appropriate error
> _raise_on_head_call_error(head_call_error, force_download, local_files_only)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:967:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
head_call_error = GatedRepoError('401 Client Error. (Request ID: Root=1-67660e6a-0603b22218e29c2b31487d7b;6f131876-c327-4e98-a632-a70b2d.../Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.')
force_download = False, local_files_only = False
def _raise_on_head_call_error(head_call_error: Exception, force_download: bool, local_files_only: bool) -> NoReturn:
"""Raise an appropriate error when the HEAD call failed and we cannot locate a local file."""
# No head call => we cannot force download.
if force_download:
if local_files_only:
raise ValueError("Cannot pass 'force_download=True' and 'local_files_only=True' at the same time.")
elif isinstance(head_call_error, OfflineModeIsEnabled):
raise ValueError("Cannot pass 'force_download=True' when offline mode is enabled.") from head_call_error
else:
raise ValueError("Force download failed due to the above error.") from head_call_error
# No head call + couldn't find an appropriate file on disk => raise an error.
if local_files_only:
raise LocalEntryNotFoundError(
"Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable"
" hf.co look-ups and downloads online, set 'local_files_only' to False."
)
elif isinstance(head_call_error, RepositoryNotFoundError) or isinstance(head_call_error, GatedRepoError):
# Repo not found or gated => let's raise the actual error
> raise head_call_error
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1482:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _get_metadata_or_catch_error(
*,
repo_id: str,
filename: str,
repo_type: str,
revision: str,
endpoint: Optional[str],
proxies: Optional[Dict],
etag_timeout: Optional[float],
headers: Dict[str, str], # mutated inplace!
token: Union[bool, str, None],
local_files_only: bool,
relative_filename: Optional[str] = None, # only used to store `.no_exists` in cache
storage_folder: Optional[str] = None, # only used to store `.no_exists` in cache
) -> Union[
# Either an exception is caught and returned
Tuple[None, None, None, None, Exception],
# Or the metadata is returned as
# `(url_to_download, etag, commit_hash, expected_size, None)`
Tuple[str, str, str, int, None],
]:
"""Get metadata for a file on the Hub, safely handling network issues.
Returns either the etag, commit_hash and expected size of the file, or the error
raised while fetching the metadata.
NOTE: This function mutates `headers` inplace! It removes the `authorization` header
if the file is a LFS blob and the domain of the url is different from the
domain of the location (typically an S3 bucket).
"""
if local_files_only:
return (
None,
None,
None,
None,
OfflineModeIsEnabled(
f"Cannot access file since 'local_files_only=True' as been set. (repo_id: {repo_id}, repo_type: {repo_type}, revision: {revision}, filename: {filename})"
),
)
url = hf_hub_url(repo_id, filename, repo_type=repo_type, revision=revision, endpoint=endpoint)
url_to_download: str = url
etag: Optional[str] = None
commit_hash: Optional[str] = None
expected_size: Optional[int] = None
head_error_call: Optional[Exception] = None
# Try to get metadata from the server.
# Do not raise yet if the file is not found or not accessible.
if not local_files_only:
try:
try:
> metadata = get_hf_file_metadata(
url=url, proxies=proxies, timeout=etag_timeout, headers=headers, token=token
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1374:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ()
kwargs = {'headers': {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0;...3f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10, 'token': None, ...}
has_token = False, arg_name = 'token', arg_value = None
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json'
token = None, proxies = None, timeout = 10, library_name = None
library_version = None, user_agent = None
headers = {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; transformers/4.47.0; session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}
@validate_hf_hub_args
def get_hf_file_metadata(
url: str,
token: Union[bool, str, None] = None,
proxies: Optional[Dict] = None,
timeout: Optional[float] = constants.DEFAULT_REQUEST_TIMEOUT,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
user_agent: Union[Dict, str, None] = None,
headers: Optional[Dict[str, str]] = None,
) -> HfFileMetadata:
"""Fetch metadata of a file versioned on the Hub for a given url.
Args:
url (`str`):
File url, for example returned by [`hf_hub_url`].
token (`str` or `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If `False` or `None`, no token is provided.
- If a string, it's used as the authentication token.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
timeout (`float`, *optional*, defaults to 10):
How many seconds to wait for the server to send metadata before giving up.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
A [`HfFileMetadata`] object containing metadata such as location, etag, size and
commit_hash.
"""
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
hf_headers["Accept-Encoding"] = "identity" # prevent any compression => we want to know the real size of the file
# Retrieve metadata
> r = _request_wrapper(
method="HEAD",
url=url,
headers=hf_headers,
allow_redirects=False,
follow_relative_redirects=True,
proxies=proxies,
timeout=timeout,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1294:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = True
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
> response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:278:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = False
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
response = <Response [401]>
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
# If redirection, we redirect only relative paths.
# This is useful in case of a renamed repository.
if 300 <= response.status_code <= 399:
parsed_target = urlparse(response.headers["Location"])
if parsed_target.netloc == "":
# This means it is a relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# We want to follow this relative redirect !
#
# Highly inspired by `resolve_redirects` from requests library.
# See https://github.com/psf/requests/blob/main/requests/sessions.py#L159
next_url = urlparse(url)._replace(path=parsed_target.path).geturl()
return _request_wrapper(method=method, url=next_url, follow_relative_redirects=True, **params)
return response
# Perform request and return if status_code is not in the retry list.
response = get_session().request(method=method, url=url, **params)
> hf_raise_for_status(response)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:302:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
response.raise_for_status()
except HTTPError as e:
error_code = response.headers.get("X-Error-Code")
error_message = response.headers.get("X-Error-Message")
if error_code == "RevisionNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
raise _format(RevisionNotFoundError, message, response) from e
elif error_code == "EntryNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
raise _format(EntryNotFoundError, message, response) from e
elif error_code == "GatedRepo":
message = (
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
)
> raise _format(GatedRepoError, message, response) from e
E huggingface_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-67660e6a-0603b22218e29c2b31487d7b;6f131876-c327-4e98-a632-a70b2d17e2e9)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:423: GatedRepoError
The above exception was the direct cause of the following exception:
variant = 'meta-llama/Meta-Llama-3-8B-Instruct', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_llama3_sequence_classification(variant, test_device):
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Load model (with tokenizer)
> tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
forge/test/models/pytorch/text/llama/test_llama3.py:172:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/test/utils.py:15: in download_model
return download_func(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py:878: in from_pretrained
config = AutoConfig.from_pretrained(
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:1021: in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:590: in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:649: in _get_config_dict
resolved_config_file = cached_file(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path_or_repo_id = 'meta-llama/Meta-Llama-3-8B-Instruct'
filename = 'config.json', cache_dir = '/github/home/.cache/huggingface/hub'
force_download = False, resume_download = None, proxies = None, token = None
revision = None, local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
except GatedRepoError as e:
resolved_file = _get_cache_file_to_return(path_or_repo_id, full_filename, cache_dir, revision)
if resolved_file is not None or not _raise_exceptions_for_gated_repo:
return resolved_file
> raise EnvironmentError(
"You are trying to access a gated repo.\nMake sure to have access to it at "
f"https://huggingface.co/{path_or_repo_id}.\n{str(e)}"
) from e
E OSError: You are trying to access a gated repo.
E Make sure to have access to it at https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct.
E 401 Client Error. (Request ID: Root=1-67660e6a-0603b22218e29c2b31487d7b;6f131876-c327-4e98-a632-a70b2d17e2e9)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Meta-Llama-3-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:421: OSError
Check failure on line 172 in forge/test/models/pytorch/text/llama/test_llama3.py
github-actions / TT-Forge-FE Tests
test_llama3.test_llama3_sequence_classification[no_device-meta-llama/Llama-3.1-8B-Instruct]
OSError: You are trying to access a gated repo.
Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct.
401 Client Error. (Request ID: Root=1-67660e6a-341104852fa3cd287a928741;a622f28d-9963-4634-afb8-6a63c617639d)
Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json.
Access to model meta-llama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
Raw output
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
> response.raise_for_status()
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
path_or_repo_id = 'meta-llama/Llama-3.1-8B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
> resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:403:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ('meta-llama/Llama-3.1-8B-Instruct', 'config.json')
kwargs = {'cache_dir': '/github/home/.cache/huggingface/hub', 'force_download': False, 'local_files_only': False, 'proxies': None, ...}
has_token = False, arg_name = 'local_files_only', arg_value = False
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
repo_id = 'meta-llama/Llama-3.1-8B-Instruct', filename = 'config.json'
@validate_hf_hub_args
def hf_hub_download(
repo_id: str,
filename: str,
*,
subfolder: Optional[str] = None,
repo_type: Optional[str] = None,
revision: Optional[str] = None,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
cache_dir: Union[str, Path, None] = None,
local_dir: Union[str, Path, None] = None,
user_agent: Union[Dict, str, None] = None,
force_download: bool = False,
proxies: Optional[Dict] = None,
etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
token: Union[bool, str, None] = None,
local_files_only: bool = False,
headers: Optional[Dict[str, str]] = None,
endpoint: Optional[str] = None,
resume_download: Optional[bool] = None,
force_filename: Optional[str] = None,
local_dir_use_symlinks: Union[bool, Literal["auto"]] = "auto",
) -> str:
"""Download a given file if it's not already present in the local cache.
The new cache file layout looks like this:
- The cache directory contains one subfolder per repo_id (namespaced by repo type)
- inside each repo folder:
- refs is a list of the latest known revision => commit_hash pairs
- blobs contains the actual file blobs (identified by their git-sha or sha256, depending on
whether they're LFS files or not)
- snapshots contains one subfolder per commit, each "commit" contains the subset of the files
that have been resolved at that particular commit. Each filename is a symlink to the blob
at that particular commit.
```
[ 96] .
└── [ 160] models--julien-c--EsperBERTo-small
├── [ 160] blobs
│ ├── [321M] 403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
│ ├── [ 398] 7cb18dc9bafbfcf74629a4b760af1b160957a83e
│ └── [1.4K] d7edf6bd2a681fb0175f7735299831ee1b22b812
├── [ 96] refs
│ └── [ 40] main
└── [ 128] snapshots
├── [ 128] 2439f60ef33a0d46d85da5001d52aeda5b00ce9f
│ ├── [ 52] README.md -> ../../blobs/d7edf6bd2a681fb0175f7735299831ee1b22b812
│ └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
└── [ 128] bbc77c8132af1cc5cf678da3f1ddf2de43606d48
├── [ 52] README.md -> ../../blobs/7cb18dc9bafbfcf74629a4b760af1b160957a83e
└── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
```
If `local_dir` is provided, the file structure from the repo will be replicated in this location. When using this
option, the `cache_dir` will not be used and a `.cache/huggingface/` folder will be created at the root of `local_dir`
to store some metadata related to the downloaded files. While this mechanism is not as robust as the main
cache-system, it's optimized for regularly pulling the latest version of a repository.
Args:
repo_id (`str`):
A user or an organization name and a repo name separated by a `/`.
filename (`str`):
The name of the file in the repo.
subfolder (`str`, *optional*):
An optional value corresponding to a folder inside the model repo.
repo_type (`str`, *optional*):
Set to `"dataset"` or `"space"` if downloading from a dataset or space,
`None` or `"model"` if downloading from a model. Default is `None`.
revision (`str`, *optional*):
An optional Git revision id which can be a branch name, a tag, or a
commit hash.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
cache_dir (`str`, `Path`, *optional*):
Path to the folder where cached files are stored.
local_dir (`str` or `Path`, *optional*):
If provided, the downloaded file will be placed under this directory.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
force_download (`bool`, *optional*, defaults to `False`):
Whether the file should be downloaded even if it already exists in
the local cache.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
etag_timeout (`float`, *optional*, defaults to `10`):
When fetching ETag, how many seconds to wait for the server to send
data before giving up which is passed to `requests.request`.
token (`str`, `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If a string, it's used as the authentication token.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, avoid downloading the file and return the path to the
local cached file if it exists.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
`str`: Local path of file or if networking is off, last version of file cached on disk.
Raises:
[`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it doesn't exist,
or because it is set to `private` and you do not have access.
[`~utils.RevisionNotFoundError`]
If the revision to download from cannot be found.
[`~utils.EntryNotFoundError`]
If the file to download cannot be found.
[`~utils.LocalEntryNotFoundError`]
If network is disabled or unavailable and file is not found in cache.
[`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
If `token=True` but the token cannot be found.
[`OSError`](https://docs.python.org/3/library/exceptions.html#OSError)
If ETag cannot be determined.
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
If some parameter value is invalid.
"""
if constants.HF_HUB_ETAG_TIMEOUT != constants.DEFAULT_ETAG_TIMEOUT:
# Respect environment variable above user value
etag_timeout = constants.HF_HUB_ETAG_TIMEOUT
if force_filename is not None:
warnings.warn(
"The `force_filename` parameter is deprecated as a new caching system, "
"which keeps the filenames as they are on the Hub, is now in place.",
FutureWarning,
)
if resume_download is not None:
warnings.warn(
"`resume_download` is deprecated and will be removed in version 1.0.0. "
"Downloads always resume when possible. "
"If you want to force a new download, use `force_download=True`.",
FutureWarning,
)
if cache_dir is None:
cache_dir = constants.HF_HUB_CACHE
if revision is None:
revision = constants.DEFAULT_REVISION
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if isinstance(local_dir, Path):
local_dir = str(local_dir)
if subfolder == "":
subfolder = None
if subfolder is not None:
# This is used to create a URL, and not a local path, hence the forward slash.
filename = f"{subfolder}/{filename}"
if repo_type is None:
repo_type = "model"
if repo_type not in constants.REPO_TYPES:
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(constants.REPO_TYPES)}")
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
if local_dir is not None:
if local_dir_use_symlinks != "auto":
warnings.warn(
"`local_dir_use_symlinks` parameter is deprecated and will be ignored. "
"The process to download files to a local folder has been updated and do "
"not rely on symlinks anymore. You only need to pass a destination folder "
"as`local_dir`.\n"
"For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder."
)
return _hf_hub_download_to_local_dir(
# Destination
local_dir=local_dir,
# File info
repo_id=repo_id,
repo_type=repo_type,
filename=filename,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
)
else:
> return _hf_hub_download_to_cache_dir(
# Destination
cache_dir=cache_dir,
# File info
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
local_files_only=local_files_only,
force_download=force_download,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:860:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _hf_hub_download_to_cache_dir(
*,
# Destination
cache_dir: str,
# File info
repo_id: str,
filename: str,
repo_type: str,
revision: str,
# HTTP info
endpoint: Optional[str],
etag_timeout: float,
headers: Dict[str, str],
proxies: Optional[Dict],
token: Optional[Union[bool, str]],
# Additional options
local_files_only: bool,
force_download: bool,
) -> str:
"""Download a given file to a cache folder, if not already present.
Method should not be called directly. Please use `hf_hub_download` instead.
"""
locks_dir = os.path.join(cache_dir, ".locks")
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
# cross platform transcription of filename, to be used as a local file path.
relative_filename = os.path.join(*filename.split("/"))
if os.name == "nt":
if relative_filename.startswith("..\\") or "\\..\\" in relative_filename:
raise ValueError(
f"Invalid filename: cannot handle filename '{relative_filename}' on Windows. Please ask the repository"
" owner to rename this file."
)
# if user provides a commit_hash and they already have the file on disk, shortcut everything.
if REGEX_COMMIT_HASH.match(revision):
pointer_path = _get_pointer_path(storage_folder, revision, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Try to get metadata (etag, commit_hash, url, size) from the server.
# If we can't, a HEAD request error is returned.
(url_to_download, etag, commit_hash, expected_size, head_call_error) = _get_metadata_or_catch_error(
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
endpoint=endpoint,
proxies=proxies,
etag_timeout=etag_timeout,
headers=headers,
token=token,
local_files_only=local_files_only,
storage_folder=storage_folder,
relative_filename=relative_filename,
)
# etag can be None for several reasons:
# 1. we passed local_files_only.
# 2. we don't have a connection
# 3. Hub is down (HTTP 500, 503, 504)
# 4. repo is not found -for example private or gated- and invalid/missing token sent
# 5. Hub is blocked by a firewall or proxy is not set correctly.
# => Try to get the last downloaded one from the specified revision.
#
# If the specified revision is a commit hash, look inside "snapshots".
# If the specified revision is a branch or tag, look inside "refs".
if head_call_error is not None:
# Couldn't make a HEAD call => let's try to find a local file
if not force_download:
commit_hash = None
if REGEX_COMMIT_HASH.match(revision):
commit_hash = revision
else:
ref_path = os.path.join(storage_folder, "refs", revision)
if os.path.isfile(ref_path):
with open(ref_path) as f:
commit_hash = f.read()
# Return pointer file if exists
if commit_hash is not None:
pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Otherwise, raise appropriate error
> _raise_on_head_call_error(head_call_error, force_download, local_files_only)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:967:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
head_call_error = GatedRepoError('401 Client Error. (Request ID: Root=1-67660e6a-341104852fa3cd287a928741;a622f28d-9963-4634-afb8-6a63c6...ama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.')
force_download = False, local_files_only = False
def _raise_on_head_call_error(head_call_error: Exception, force_download: bool, local_files_only: bool) -> NoReturn:
"""Raise an appropriate error when the HEAD call failed and we cannot locate a local file."""
# No head call => we cannot force download.
if force_download:
if local_files_only:
raise ValueError("Cannot pass 'force_download=True' and 'local_files_only=True' at the same time.")
elif isinstance(head_call_error, OfflineModeIsEnabled):
raise ValueError("Cannot pass 'force_download=True' when offline mode is enabled.") from head_call_error
else:
raise ValueError("Force download failed due to the above error.") from head_call_error
# No head call + couldn't find an appropriate file on disk => raise an error.
if local_files_only:
raise LocalEntryNotFoundError(
"Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable"
" hf.co look-ups and downloads online, set 'local_files_only' to False."
)
elif isinstance(head_call_error, RepositoryNotFoundError) or isinstance(head_call_error, GatedRepoError):
# Repo not found or gated => let's raise the actual error
> raise head_call_error
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1482:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _get_metadata_or_catch_error(
*,
repo_id: str,
filename: str,
repo_type: str,
revision: str,
endpoint: Optional[str],
proxies: Optional[Dict],
etag_timeout: Optional[float],
headers: Dict[str, str], # mutated inplace!
token: Union[bool, str, None],
local_files_only: bool,
relative_filename: Optional[str] = None, # only used to store `.no_exists` in cache
storage_folder: Optional[str] = None, # only used to store `.no_exists` in cache
) -> Union[
# Either an exception is caught and returned
Tuple[None, None, None, None, Exception],
# Or the metadata is returned as
# `(url_to_download, etag, commit_hash, expected_size, None)`
Tuple[str, str, str, int, None],
]:
"""Get metadata for a file on the Hub, safely handling network issues.
Returns either the etag, commit_hash and expected size of the file, or the error
raised while fetching the metadata.
NOTE: This function mutates `headers` inplace! It removes the `authorization` header
if the file is a LFS blob and the domain of the url is different from the
domain of the location (typically an S3 bucket).
"""
if local_files_only:
return (
None,
None,
None,
None,
OfflineModeIsEnabled(
f"Cannot access file since 'local_files_only=True' as been set. (repo_id: {repo_id}, repo_type: {repo_type}, revision: {revision}, filename: {filename})"
),
)
url = hf_hub_url(repo_id, filename, repo_type=repo_type, revision=revision, endpoint=endpoint)
url_to_download: str = url
etag: Optional[str] = None
commit_hash: Optional[str] = None
expected_size: Optional[int] = None
head_error_call: Optional[Exception] = None
# Try to get metadata from the server.
# Do not raise yet if the file is not found or not accessible.
if not local_files_only:
try:
try:
> metadata = get_hf_file_metadata(
url=url, proxies=proxies, timeout=etag_timeout, headers=headers, token=token
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1374:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ()
kwargs = {'headers': {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0;...3f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10, 'token': None, ...}
has_token = False, arg_name = 'token', arg_value = None
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json'
token = None, proxies = None, timeout = 10, library_name = None
library_version = None, user_agent = None
headers = {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; transformers/4.47.0; session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}
@validate_hf_hub_args
def get_hf_file_metadata(
url: str,
token: Union[bool, str, None] = None,
proxies: Optional[Dict] = None,
timeout: Optional[float] = constants.DEFAULT_REQUEST_TIMEOUT,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
user_agent: Union[Dict, str, None] = None,
headers: Optional[Dict[str, str]] = None,
) -> HfFileMetadata:
"""Fetch metadata of a file versioned on the Hub for a given url.
Args:
url (`str`):
File url, for example returned by [`hf_hub_url`].
token (`str` or `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If `False` or `None`, no token is provided.
- If a string, it's used as the authentication token.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
timeout (`float`, *optional*, defaults to 10):
How many seconds to wait for the server to send metadata before giving up.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
A [`HfFileMetadata`] object containing metadata such as location, etag, size and
commit_hash.
"""
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
hf_headers["Accept-Encoding"] = "identity" # prevent any compression => we want to know the real size of the file
# Retrieve metadata
> r = _request_wrapper(
method="HEAD",
url=url,
headers=hf_headers,
allow_redirects=False,
follow_relative_redirects=True,
proxies=proxies,
timeout=timeout,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1294:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = True
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
> response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:278:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json'
follow_relative_redirects = False
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
response = <Response [401]>
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
# If redirection, we redirect only relative paths.
# This is useful in case of a renamed repository.
if 300 <= response.status_code <= 399:
parsed_target = urlparse(response.headers["Location"])
if parsed_target.netloc == "":
# This means it is a relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# We want to follow this relative redirect !
#
# Highly inspired by `resolve_redirects` from requests library.
# See https://github.com/psf/requests/blob/main/requests/sessions.py#L159
next_url = urlparse(url)._replace(path=parsed_target.path).geturl()
return _request_wrapper(method=method, url=next_url, follow_relative_redirects=True, **params)
return response
# Perform request and return if status_code is not in the retry list.
response = get_session().request(method=method, url=url, **params)
> hf_raise_for_status(response)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:302:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
response.raise_for_status()
except HTTPError as e:
error_code = response.headers.get("X-Error-Code")
error_message = response.headers.get("X-Error-Message")
if error_code == "RevisionNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
raise _format(RevisionNotFoundError, message, response) from e
elif error_code == "EntryNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
raise _format(EntryNotFoundError, message, response) from e
elif error_code == "GatedRepo":
message = (
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
)
> raise _format(GatedRepoError, message, response) from e
E huggingface_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-67660e6a-341104852fa3cd287a928741;a622f28d-9963-4634-afb8-6a63c617639d)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:423: GatedRepoError
The above exception was the direct cause of the following exception:
variant = 'meta-llama/Llama-3.1-8B-Instruct', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_llama3_sequence_classification(variant, test_device):
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Load model (with tokenizer)
> tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
forge/test/models/pytorch/text/llama/test_llama3.py:172:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/test/utils.py:15: in download_model
return download_func(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py:878: in from_pretrained
config = AutoConfig.from_pretrained(
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:1021: in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:590: in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:649: in _get_config_dict
resolved_config_file = cached_file(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path_or_repo_id = 'meta-llama/Llama-3.1-8B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
except GatedRepoError as e:
resolved_file = _get_cache_file_to_return(path_or_repo_id, full_filename, cache_dir, revision)
if resolved_file is not None or not _raise_exceptions_for_gated_repo:
return resolved_file
> raise EnvironmentError(
"You are trying to access a gated repo.\nMake sure to have access to it at "
f"https://huggingface.co/{path_or_repo_id}.\n{str(e)}"
) from e
E OSError: You are trying to access a gated repo.
E Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct.
E 401 Client Error. (Request ID: Root=1-67660e6a-341104852fa3cd287a928741;a622f28d-9963-4634-afb8-6a63c617639d)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.1-8B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:421: OSError
Check failure on line 172 in forge/test/models/pytorch/text/llama/test_llama3.py
github-actions / TT-Forge-FE Tests
test_llama3.test_llama3_sequence_classification[no_device-meta-llama/Llama-3.2-1B-Instruct]
OSError: You are trying to access a gated repo.
Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct.
401 Client Error. (Request ID: Root=1-67660e6a-1669a74d52b2d321343d228a;8cc24f44-4955-42c5-bb01-6c12708b3e12)
Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json.
Access to model meta-llama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
Raw output
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
> response.raise_for_status()
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
path_or_repo_id = 'meta-llama/Llama-3.2-1B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
> resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:403:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ('meta-llama/Llama-3.2-1B-Instruct', 'config.json')
kwargs = {'cache_dir': '/github/home/.cache/huggingface/hub', 'force_download': False, 'local_files_only': False, 'proxies': None, ...}
has_token = False, arg_name = 'local_files_only', arg_value = False
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
repo_id = 'meta-llama/Llama-3.2-1B-Instruct', filename = 'config.json'
@validate_hf_hub_args
def hf_hub_download(
repo_id: str,
filename: str,
*,
subfolder: Optional[str] = None,
repo_type: Optional[str] = None,
revision: Optional[str] = None,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
cache_dir: Union[str, Path, None] = None,
local_dir: Union[str, Path, None] = None,
user_agent: Union[Dict, str, None] = None,
force_download: bool = False,
proxies: Optional[Dict] = None,
etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
token: Union[bool, str, None] = None,
local_files_only: bool = False,
headers: Optional[Dict[str, str]] = None,
endpoint: Optional[str] = None,
resume_download: Optional[bool] = None,
force_filename: Optional[str] = None,
local_dir_use_symlinks: Union[bool, Literal["auto"]] = "auto",
) -> str:
"""Download a given file if it's not already present in the local cache.
The new cache file layout looks like this:
- The cache directory contains one subfolder per repo_id (namespaced by repo type)
- inside each repo folder:
- refs is a list of the latest known revision => commit_hash pairs
- blobs contains the actual file blobs (identified by their git-sha or sha256, depending on
whether they're LFS files or not)
- snapshots contains one subfolder per commit, each "commit" contains the subset of the files
that have been resolved at that particular commit. Each filename is a symlink to the blob
at that particular commit.
```
[ 96] .
└── [ 160] models--julien-c--EsperBERTo-small
├── [ 160] blobs
│ ├── [321M] 403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
│ ├── [ 398] 7cb18dc9bafbfcf74629a4b760af1b160957a83e
│ └── [1.4K] d7edf6bd2a681fb0175f7735299831ee1b22b812
├── [ 96] refs
│ └── [ 40] main
└── [ 128] snapshots
├── [ 128] 2439f60ef33a0d46d85da5001d52aeda5b00ce9f
│ ├── [ 52] README.md -> ../../blobs/d7edf6bd2a681fb0175f7735299831ee1b22b812
│ └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
└── [ 128] bbc77c8132af1cc5cf678da3f1ddf2de43606d48
├── [ 52] README.md -> ../../blobs/7cb18dc9bafbfcf74629a4b760af1b160957a83e
└── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd
```
If `local_dir` is provided, the file structure from the repo will be replicated in this location. When using this
option, the `cache_dir` will not be used and a `.cache/huggingface/` folder will be created at the root of `local_dir`
to store some metadata related to the downloaded files. While this mechanism is not as robust as the main
cache-system, it's optimized for regularly pulling the latest version of a repository.
Args:
repo_id (`str`):
A user or an organization name and a repo name separated by a `/`.
filename (`str`):
The name of the file in the repo.
subfolder (`str`, *optional*):
An optional value corresponding to a folder inside the model repo.
repo_type (`str`, *optional*):
Set to `"dataset"` or `"space"` if downloading from a dataset or space,
`None` or `"model"` if downloading from a model. Default is `None`.
revision (`str`, *optional*):
An optional Git revision id which can be a branch name, a tag, or a
commit hash.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
cache_dir (`str`, `Path`, *optional*):
Path to the folder where cached files are stored.
local_dir (`str` or `Path`, *optional*):
If provided, the downloaded file will be placed under this directory.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
force_download (`bool`, *optional*, defaults to `False`):
Whether the file should be downloaded even if it already exists in
the local cache.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
etag_timeout (`float`, *optional*, defaults to `10`):
When fetching ETag, how many seconds to wait for the server to send
data before giving up which is passed to `requests.request`.
token (`str`, `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If a string, it's used as the authentication token.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, avoid downloading the file and return the path to the
local cached file if it exists.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
`str`: Local path of file or if networking is off, last version of file cached on disk.
Raises:
[`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it doesn't exist,
or because it is set to `private` and you do not have access.
[`~utils.RevisionNotFoundError`]
If the revision to download from cannot be found.
[`~utils.EntryNotFoundError`]
If the file to download cannot be found.
[`~utils.LocalEntryNotFoundError`]
If network is disabled or unavailable and file is not found in cache.
[`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
If `token=True` but the token cannot be found.
[`OSError`](https://docs.python.org/3/library/exceptions.html#OSError)
If ETag cannot be determined.
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
If some parameter value is invalid.
"""
if constants.HF_HUB_ETAG_TIMEOUT != constants.DEFAULT_ETAG_TIMEOUT:
# Respect environment variable above user value
etag_timeout = constants.HF_HUB_ETAG_TIMEOUT
if force_filename is not None:
warnings.warn(
"The `force_filename` parameter is deprecated as a new caching system, "
"which keeps the filenames as they are on the Hub, is now in place.",
FutureWarning,
)
if resume_download is not None:
warnings.warn(
"`resume_download` is deprecated and will be removed in version 1.0.0. "
"Downloads always resume when possible. "
"If you want to force a new download, use `force_download=True`.",
FutureWarning,
)
if cache_dir is None:
cache_dir = constants.HF_HUB_CACHE
if revision is None:
revision = constants.DEFAULT_REVISION
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if isinstance(local_dir, Path):
local_dir = str(local_dir)
if subfolder == "":
subfolder = None
if subfolder is not None:
# This is used to create a URL, and not a local path, hence the forward slash.
filename = f"{subfolder}/{filename}"
if repo_type is None:
repo_type = "model"
if repo_type not in constants.REPO_TYPES:
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(constants.REPO_TYPES)}")
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
if local_dir is not None:
if local_dir_use_symlinks != "auto":
warnings.warn(
"`local_dir_use_symlinks` parameter is deprecated and will be ignored. "
"The process to download files to a local folder has been updated and do "
"not rely on symlinks anymore. You only need to pass a destination folder "
"as`local_dir`.\n"
"For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder."
)
return _hf_hub_download_to_local_dir(
# Destination
local_dir=local_dir,
# File info
repo_id=repo_id,
repo_type=repo_type,
filename=filename,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
)
else:
> return _hf_hub_download_to_cache_dir(
# Destination
cache_dir=cache_dir,
# File info
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
# HTTP info
endpoint=endpoint,
etag_timeout=etag_timeout,
headers=hf_headers,
proxies=proxies,
token=token,
# Additional options
local_files_only=local_files_only,
force_download=force_download,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:860:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _hf_hub_download_to_cache_dir(
*,
# Destination
cache_dir: str,
# File info
repo_id: str,
filename: str,
repo_type: str,
revision: str,
# HTTP info
endpoint: Optional[str],
etag_timeout: float,
headers: Dict[str, str],
proxies: Optional[Dict],
token: Optional[Union[bool, str]],
# Additional options
local_files_only: bool,
force_download: bool,
) -> str:
"""Download a given file to a cache folder, if not already present.
Method should not be called directly. Please use `hf_hub_download` instead.
"""
locks_dir = os.path.join(cache_dir, ".locks")
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
# cross platform transcription of filename, to be used as a local file path.
relative_filename = os.path.join(*filename.split("/"))
if os.name == "nt":
if relative_filename.startswith("..\\") or "\\..\\" in relative_filename:
raise ValueError(
f"Invalid filename: cannot handle filename '{relative_filename}' on Windows. Please ask the repository"
" owner to rename this file."
)
# if user provides a commit_hash and they already have the file on disk, shortcut everything.
if REGEX_COMMIT_HASH.match(revision):
pointer_path = _get_pointer_path(storage_folder, revision, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Try to get metadata (etag, commit_hash, url, size) from the server.
# If we can't, a HEAD request error is returned.
(url_to_download, etag, commit_hash, expected_size, head_call_error) = _get_metadata_or_catch_error(
repo_id=repo_id,
filename=filename,
repo_type=repo_type,
revision=revision,
endpoint=endpoint,
proxies=proxies,
etag_timeout=etag_timeout,
headers=headers,
token=token,
local_files_only=local_files_only,
storage_folder=storage_folder,
relative_filename=relative_filename,
)
# etag can be None for several reasons:
# 1. we passed local_files_only.
# 2. we don't have a connection
# 3. Hub is down (HTTP 500, 503, 504)
# 4. repo is not found -for example private or gated- and invalid/missing token sent
# 5. Hub is blocked by a firewall or proxy is not set correctly.
# => Try to get the last downloaded one from the specified revision.
#
# If the specified revision is a commit hash, look inside "snapshots".
# If the specified revision is a branch or tag, look inside "refs".
if head_call_error is not None:
# Couldn't make a HEAD call => let's try to find a local file
if not force_download:
commit_hash = None
if REGEX_COMMIT_HASH.match(revision):
commit_hash = revision
else:
ref_path = os.path.join(storage_folder, "refs", revision)
if os.path.isfile(ref_path):
with open(ref_path) as f:
commit_hash = f.read()
# Return pointer file if exists
if commit_hash is not None:
pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
if os.path.exists(pointer_path) and not force_download:
return pointer_path
# Otherwise, raise appropriate error
> _raise_on_head_call_error(head_call_error, force_download, local_files_only)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:967:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
head_call_error = GatedRepoError('401 Client Error. (Request ID: Root=1-67660e6a-1669a74d52b2d321343d228a;8cc24f44-4955-42c5-bb01-6c1270...ama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.')
force_download = False, local_files_only = False
def _raise_on_head_call_error(head_call_error: Exception, force_download: bool, local_files_only: bool) -> NoReturn:
"""Raise an appropriate error when the HEAD call failed and we cannot locate a local file."""
# No head call => we cannot force download.
if force_download:
if local_files_only:
raise ValueError("Cannot pass 'force_download=True' and 'local_files_only=True' at the same time.")
elif isinstance(head_call_error, OfflineModeIsEnabled):
raise ValueError("Cannot pass 'force_download=True' when offline mode is enabled.") from head_call_error
else:
raise ValueError("Force download failed due to the above error.") from head_call_error
# No head call + couldn't find an appropriate file on disk => raise an error.
if local_files_only:
raise LocalEntryNotFoundError(
"Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable"
" hf.co look-ups and downloads online, set 'local_files_only' to False."
)
elif isinstance(head_call_error, RepositoryNotFoundError) or isinstance(head_call_error, GatedRepoError):
# Repo not found or gated => let's raise the actual error
> raise head_call_error
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1482:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _get_metadata_or_catch_error(
*,
repo_id: str,
filename: str,
repo_type: str,
revision: str,
endpoint: Optional[str],
proxies: Optional[Dict],
etag_timeout: Optional[float],
headers: Dict[str, str], # mutated inplace!
token: Union[bool, str, None],
local_files_only: bool,
relative_filename: Optional[str] = None, # only used to store `.no_exists` in cache
storage_folder: Optional[str] = None, # only used to store `.no_exists` in cache
) -> Union[
# Either an exception is caught and returned
Tuple[None, None, None, None, Exception],
# Or the metadata is returned as
# `(url_to_download, etag, commit_hash, expected_size, None)`
Tuple[str, str, str, int, None],
]:
"""Get metadata for a file on the Hub, safely handling network issues.
Returns either the etag, commit_hash and expected size of the file, or the error
raised while fetching the metadata.
NOTE: This function mutates `headers` inplace! It removes the `authorization` header
if the file is a LFS blob and the domain of the url is different from the
domain of the location (typically an S3 bucket).
"""
if local_files_only:
return (
None,
None,
None,
None,
OfflineModeIsEnabled(
f"Cannot access file since 'local_files_only=True' as been set. (repo_id: {repo_id}, repo_type: {repo_type}, revision: {revision}, filename: {filename})"
),
)
url = hf_hub_url(repo_id, filename, repo_type=repo_type, revision=revision, endpoint=endpoint)
url_to_download: str = url
etag: Optional[str] = None
commit_hash: Optional[str] = None
expected_size: Optional[int] = None
head_error_call: Optional[Exception] = None
# Try to get metadata from the server.
# Do not raise yet if the file is not found or not accessible.
if not local_files_only:
try:
try:
> metadata = get_hf_file_metadata(
url=url, proxies=proxies, timeout=etag_timeout, headers=headers, token=token
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1374:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ()
kwargs = {'headers': {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0;...3f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10, 'token': None, ...}
has_token = False, arg_name = 'token', arg_value = None
@wraps(fn)
def _inner_fn(*args, **kwargs):
has_token = False
for arg_name, arg_value in chain(
zip(signature.parameters, args), # Args values
kwargs.items(), # Kwargs values
):
if arg_name in ["repo_id", "from_id", "to_id"]:
validate_repo_id(arg_value)
elif arg_name == "token" and arg_value is not None:
has_token = True
if check_use_auth_token:
kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
> return fn(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json'
token = None, proxies = None, timeout = 10, library_name = None
library_version = None, user_agent = None
headers = {'user-agent': 'unknown/None; hf_hub/0.27.0; python/3.10.12; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; transformers/4.47.0; session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}
@validate_hf_hub_args
def get_hf_file_metadata(
url: str,
token: Union[bool, str, None] = None,
proxies: Optional[Dict] = None,
timeout: Optional[float] = constants.DEFAULT_REQUEST_TIMEOUT,
library_name: Optional[str] = None,
library_version: Optional[str] = None,
user_agent: Union[Dict, str, None] = None,
headers: Optional[Dict[str, str]] = None,
) -> HfFileMetadata:
"""Fetch metadata of a file versioned on the Hub for a given url.
Args:
url (`str`):
File url, for example returned by [`hf_hub_url`].
token (`str` or `bool`, *optional*):
A token to be used for the download.
- If `True`, the token is read from the HuggingFace config
folder.
- If `False` or `None`, no token is provided.
- If a string, it's used as the authentication token.
proxies (`dict`, *optional*):
Dictionary mapping protocol to the URL of the proxy passed to
`requests.request`.
timeout (`float`, *optional*, defaults to 10):
How many seconds to wait for the server to send metadata before giving up.
library_name (`str`, *optional*):
The name of the library to which the object corresponds.
library_version (`str`, *optional*):
The version of the library.
user_agent (`dict`, `str`, *optional*):
The user-agent info in the form of a dictionary or a string.
headers (`dict`, *optional*):
Additional headers to be sent with the request.
Returns:
A [`HfFileMetadata`] object containing metadata such as location, etag, size and
commit_hash.
"""
hf_headers = build_hf_headers(
token=token,
library_name=library_name,
library_version=library_version,
user_agent=user_agent,
headers=headers,
)
hf_headers["Accept-Encoding"] = "identity" # prevent any compression => we want to know the real size of the file
# Retrieve metadata
> r = _request_wrapper(
method="HEAD",
url=url,
headers=hf_headers,
allow_redirects=False,
follow_relative_redirects=True,
proxies=proxies,
timeout=timeout,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1294:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json'
follow_relative_redirects = True
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
> response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:278:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
method = 'HEAD'
url = 'https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json'
follow_relative_redirects = False
params = {'allow_redirects': False, 'headers': {'Accept-Encoding': 'identity', 'user-agent': 'unknown/None; hf_hub/0.27.0; pyth... session_id/85b7e9c13f9b45b385d075dc2205eb84; file_type/config; from_auto_class/True'}, 'proxies': None, 'timeout': 10}
response = <Response [401]>
def _request_wrapper(
method: HTTP_METHOD_T, url: str, *, follow_relative_redirects: bool = False, **params
) -> requests.Response:
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
`allow_redirection=False`.
Args:
method (`str`):
HTTP method, such as 'GET' or 'HEAD'.
url (`str`):
The URL of the resource to fetch.
follow_relative_redirects (`bool`, *optional*, defaults to `False`)
If True, relative redirection (redirection to the same site) will be resolved even when `allow_redirection`
kwarg is set to False. Useful when we want to follow a redirection to a renamed repository without
following redirection to a CDN.
**params (`dict`, *optional*):
Params to pass to `requests.request`.
"""
# Recursively follow relative redirects
if follow_relative_redirects:
response = _request_wrapper(
method=method,
url=url,
follow_relative_redirects=False,
**params,
)
# If redirection, we redirect only relative paths.
# This is useful in case of a renamed repository.
if 300 <= response.status_code <= 399:
parsed_target = urlparse(response.headers["Location"])
if parsed_target.netloc == "":
# This means it is a relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# We want to follow this relative redirect !
#
# Highly inspired by `resolve_redirects` from requests library.
# See https://github.com/psf/requests/blob/main/requests/sessions.py#L159
next_url = urlparse(url)._replace(path=parsed_target.path).geturl()
return _request_wrapper(method=method, url=next_url, follow_relative_redirects=True, **params)
return response
# Perform request and return if status_code is not in the retry list.
response = get_session().request(method=method, url=url, **params)
> hf_raise_for_status(response)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py:302:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
response.raise_for_status()
except HTTPError as e:
error_code = response.headers.get("X-Error-Code")
error_message = response.headers.get("X-Error-Message")
if error_code == "RevisionNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
raise _format(RevisionNotFoundError, message, response) from e
elif error_code == "EntryNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
raise _format(EntryNotFoundError, message, response) from e
elif error_code == "GatedRepo":
message = (
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
)
> raise _format(GatedRepoError, message, response) from e
E huggingface_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-67660e6a-1669a74d52b2d321343d228a;8cc24f44-4955-42c5-bb01-6c12708b3e12)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:423: GatedRepoError
The above exception was the direct cause of the following exception:
variant = 'meta-llama/Llama-3.2-1B-Instruct', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_llama3_sequence_classification(variant, test_device):
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Load model (with tokenizer)
> tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
forge/test/models/pytorch/text/llama/test_llama3.py:172:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/test/utils.py:15: in download_model
return download_func(*args, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py:878: in from_pretrained
config = AutoConfig.from_pretrained(
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:1021: in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:590: in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/configuration_utils.py:649: in _get_config_dict
resolved_config_file = cached_file(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path_or_repo_id = 'meta-llama/Llama-3.2-1B-Instruct', filename = 'config.json'
cache_dir = '/github/home/.cache/huggingface/hub', force_download = False
resume_download = None, proxies = None, token = None, revision = None
local_files_only = False, subfolder = '', repo_type = None
user_agent = 'transformers/4.47.0; python/3.10.12; session_id/85b7e9c13f9b45b385d075dc2205eb84; torch/2.1.0+cpu.cxx11.abi; tensorflow/2.13.0; file_type/config; from_auto_class/True'
_raise_exceptions_for_gated_repo = True
_raise_exceptions_for_missing_entries = True
_raise_exceptions_for_connection_errors = True, _commit_hash = None
deprecated_kwargs = {}, use_auth_token = None, full_filename = 'config.json'
resolved_file = None
def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: Optional[bool] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
repo_type: Optional[str] = None,
user_agent: Optional[Union[str, Dict[str, str]]] = None,
_raise_exceptions_for_gated_repo: bool = True,
_raise_exceptions_for_missing_entries: bool = True,
_raise_exceptions_for_connection_errors: bool = True,
_commit_hash: Optional[str] = None,
**deprecated_kwargs,
) -> Optional[str]:
"""
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
Args:
path_or_repo_id (`str` or `os.PathLike`):
This can be either:
- a string, the *model id* of a model repo on huggingface.co.
- a path to a *directory* potentially containing the file.
filename (`str`):
The name of the file to locate in `path_or_repo`.
cache_dir (`str` or `os.PathLike`, *optional*):
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
cache should not be used.
force_download (`bool`, *optional*, defaults to `False`):
Whether or not to force to (re-)download the configuration files and override the cached versions if they
exist.
resume_download:
Deprecated and ignored. All downloads are now resumed by default when possible.
Will be removed in v5 of Transformers.
proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
when running `huggingface-cli login` (stored in `~/.huggingface`).
revision (`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git.
local_files_only (`bool`, *optional*, defaults to `False`):
If `True`, will only try to load the tokenizer configuration from local files.
subfolder (`str`, *optional*, defaults to `""`):
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.
repo_type (`str`, *optional*):
Specify the repo type (useful when downloading from a space for instance).
<Tip>
Passing `token=True` is required when you want to use a private model.
</Tip>
Returns:
`Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).
Examples:
```python
# Download a model weight from the Hub and cache it.
model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
```
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# Private arguments
# _raise_exceptions_for_gated_repo: if False, do not raise an exception for gated repo error but return
# None.
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
# None.
# _raise_exceptions_for_connection_errors: if False, do not raise an exception for connection errors but return
# None.
# _commit_hash: passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
# a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
if subfolder is None:
subfolder = ""
path_or_repo_id = str(path_or_repo_id)
full_filename = os.path.join(subfolder, filename)
if os.path.isdir(path_or_repo_id):
resolved_file = os.path.join(os.path.join(path_or_repo_id, subfolder), filename)
if not os.path.isfile(resolved_file):
if _raise_exceptions_for_missing_entries and filename not in ["config.json", f"{subfolder}/config.json"]:
raise EnvironmentError(
f"{path_or_repo_id} does not appear to have a file named {full_filename}. Checkout "
f"'https://huggingface.co/{path_or_repo_id}/tree/{revision}' for available files."
)
else:
return None
return resolved_file
if cache_dir is None:
cache_dir = TRANSFORMERS_CACHE
if isinstance(cache_dir, Path):
cache_dir = str(cache_dir)
if _commit_hash is not None and not force_download:
# If the file is cached under that commit hash, we return it directly.
resolved_file = try_to_load_from_cache(
path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash, repo_type=repo_type
)
if resolved_file is not None:
if resolved_file is not _CACHED_NO_EXIST:
return resolved_file
elif not _raise_exceptions_for_missing_entries:
return None
else:
raise EnvironmentError(f"Could not locate {full_filename} inside {path_or_repo_id}.")
user_agent = http_user_agent(user_agent)
try:
# Load from URL or cache if already cached
resolved_file = hf_hub_download(
path_or_repo_id,
filename,
subfolder=None if len(subfolder) == 0 else subfolder,
repo_type=repo_type,
revision=revision,
cache_dir=cache_dir,
user_agent=user_agent,
force_download=force_download,
proxies=proxies,
resume_download=resume_download,
token=token,
local_files_only=local_files_only,
)
except GatedRepoError as e:
resolved_file = _get_cache_file_to_return(path_or_repo_id, full_filename, cache_dir, revision)
if resolved_file is not None or not _raise_exceptions_for_gated_repo:
return resolved_file
> raise EnvironmentError(
"You are trying to access a gated repo.\nMake sure to have access to it at "
f"https://huggingface.co/{path_or_repo_id}.\n{str(e)}"
) from e
E OSError: You are trying to access a gated repo.
E Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct.
E 401 Client Error. (Request ID: Root=1-67660e6a-1669a74d52b2d321343d228a;8cc24f44-4955-42c5-bb01-6c12708b3e12)
E
E Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json.
E Access to model meta-llama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:421: OSError
Check failure on line 58 in forge/test/models/pytorch/text/mistral/test_mistral.py
github-actions / TT-Forge-FE Tests
test_mistral.test_mistral[no_device-mistralai/Mistral-7B-v0.1]
OSError: mistralai/Mistral-7B-v0.1 is a gated repository. Make sure to request access at https://huggingface.co/mistralai/Mistral-7B-v0.1 and pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`.
Raw output
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
> response.raise_for_status()
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/mistralai/Mistral-7B-v0.1/resolve/main/tf_model.h5
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
path_or_repo = 'mistralai/Mistral-7B-v0.1', filename = 'tf_model.h5'
revision = 'main', proxies = None, token = None, local_files_only = False
cache_dir = None, repo_type = None, deprecated_kwargs = {}
use_auth_token = None, cached_path = None, has_file_in_cache = False
response = <Response [401]>
def has_file(
path_or_repo: Union[str, os.PathLike],
filename: str,
revision: Optional[str] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
*,
local_files_only: bool = False,
cache_dir: Union[str, Path, None] = None,
repo_type: Optional[str] = None,
**deprecated_kwargs,
):
"""
Checks if a repo contains a given file without downloading it. Works for remote repos and local folders.
If offline mode is enabled, checks if the file exists in the cache.
<Tip warning={false}>
This function will raise an error if the repository `path_or_repo` is not valid or if `revision` does not exist for
this repo, but will return False for regular connection errors.
</Tip>
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# If path to local directory, check if the file exists
if os.path.isdir(path_or_repo):
return os.path.isfile(os.path.join(path_or_repo, filename))
# Else it's a repo => let's check if the file exists in local cache or on the Hub
# Check if file exists in cache
# This information might be outdated so it's best to also make a HEAD call (if allowed).
cached_path = try_to_load_from_cache(
repo_id=path_or_repo,
filename=filename,
revision=revision,
repo_type=repo_type,
cache_dir=cache_dir,
)
has_file_in_cache = isinstance(cached_path, str)
# If local_files_only, don't try the HEAD call
if local_files_only:
return has_file_in_cache
# Check if the file exists
try:
response = get_session().head(
hf_hub_url(path_or_repo, filename=filename, revision=revision, repo_type=repo_type),
headers=build_hf_headers(token=token, user_agent=http_user_agent()),
allow_redirects=False,
proxies=proxies,
timeout=10,
)
except (requests.exceptions.SSLError, requests.exceptions.ProxyError):
# Actually raise for those subclasses of ConnectionError
raise
except (
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
OfflineModeIsEnabled,
):
return has_file_in_cache
try:
> hf_raise_for_status(response)
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:676:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response [401]>, endpoint_name = None
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
"""
Internal version of `response.raise_for_status()` that will refine a
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
This helper is meant to be the unique method to raise_for_status when making a call
to the Hugging Face Hub.
Example:
```py
import requests
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
response = get_session().post(...)
try:
hf_raise_for_status(response)
except HfHubHTTPError as e:
print(str(e)) # formatted message
e.request_id, e.server_message # details returned by server
# Complete the error message with additional information once it's raised
e.append_to_message("\n`create_commit` expects the repository to exist.")
raise
```
Args:
response (`Response`):
Response from the server.
endpoint_name (`str`, *optional*):
Name of the endpoint that has been called. If provided, the error message
will be more complete.
<Tip warning={true}>
Raises when the request has failed:
- [`~utils.RepositoryNotFoundError`]
If the repository to download from cannot be found. This may be because it
doesn't exist, because `repo_type` is not set correctly, or because the repo
is `private` and you do not have access.
- [`~utils.GatedRepoError`]
If the repository exists but is gated and the user is not on the authorized
list.
- [`~utils.RevisionNotFoundError`]
If the repository exists but the revision couldn't be find.
- [`~utils.EntryNotFoundError`]
If the repository exists but the entry (e.g. the requested file) couldn't be
find.
- [`~utils.BadRequestError`]
If request failed with a HTTP 400 BadRequest error.
- [`~utils.HfHubHTTPError`]
If request failed for a reason not listed above.
</Tip>
"""
try:
response.raise_for_status()
except HTTPError as e:
error_code = response.headers.get("X-Error-Code")
error_message = response.headers.get("X-Error-Message")
if error_code == "RevisionNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
raise _format(RevisionNotFoundError, message, response) from e
elif error_code == "EntryNotFound":
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
raise _format(EntryNotFoundError, message, response) from e
elif error_code == "GatedRepo":
message = (
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
)
> raise _format(GatedRepoError, message, response) from e
E huggingface_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-67660e6b-31599e49400990f55c603670;fd6f7fc7-ab2b-4af1-ac2d-8ec458c72e70)
E
E Cannot access gated repo for url https://huggingface.co/mistralai/Mistral-7B-v0.1/resolve/main/tf_model.h5.
E Access to model mistralai/Mistral-7B-v0.1 is restricted. You must have access to it and be authenticated to access it. Please log in.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:423: GatedRepoError
The above exception was the direct cause of the following exception:
variant = 'mistralai/Mistral-7B-v0.1', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_mistral(variant, test_device):
configuration = MistralConfig()
configuration.sliding_window = None
configuration.use_cache = False
configuration.return_dict = False
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
> module = AutoModelForCausalLM.from_pretrained(variant, device_map="auto", config=configuration)
forge/test/models/pytorch/text/mistral/test_mistral.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py:564: in from_pretrained
return model_class.from_pretrained(
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/modeling_utils.py:3908: in from_pretrained
if has_file(pretrained_model_name_or_path, TF2_WEIGHTS_NAME, **has_file_kwargs):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path_or_repo = 'mistralai/Mistral-7B-v0.1', filename = 'tf_model.h5'
revision = 'main', proxies = None, token = None, local_files_only = False
cache_dir = None, repo_type = None, deprecated_kwargs = {}
use_auth_token = None, cached_path = None, has_file_in_cache = False
response = <Response [401]>
def has_file(
path_or_repo: Union[str, os.PathLike],
filename: str,
revision: Optional[str] = None,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
*,
local_files_only: bool = False,
cache_dir: Union[str, Path, None] = None,
repo_type: Optional[str] = None,
**deprecated_kwargs,
):
"""
Checks if a repo contains a given file without downloading it. Works for remote repos and local folders.
If offline mode is enabled, checks if the file exists in the cache.
<Tip warning={false}>
This function will raise an error if the repository `path_or_repo` is not valid or if `revision` does not exist for
this repo, but will return False for regular connection errors.
</Tip>
"""
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
if use_auth_token is not None:
warnings.warn(
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
FutureWarning,
)
if token is not None:
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
token = use_auth_token
# If path to local directory, check if the file exists
if os.path.isdir(path_or_repo):
return os.path.isfile(os.path.join(path_or_repo, filename))
# Else it's a repo => let's check if the file exists in local cache or on the Hub
# Check if file exists in cache
# This information might be outdated so it's best to also make a HEAD call (if allowed).
cached_path = try_to_load_from_cache(
repo_id=path_or_repo,
filename=filename,
revision=revision,
repo_type=repo_type,
cache_dir=cache_dir,
)
has_file_in_cache = isinstance(cached_path, str)
# If local_files_only, don't try the HEAD call
if local_files_only:
return has_file_in_cache
# Check if the file exists
try:
response = get_session().head(
hf_hub_url(path_or_repo, filename=filename, revision=revision, repo_type=repo_type),
headers=build_hf_headers(token=token, user_agent=http_user_agent()),
allow_redirects=False,
proxies=proxies,
timeout=10,
)
except (requests.exceptions.SSLError, requests.exceptions.ProxyError):
# Actually raise for those subclasses of ConnectionError
raise
except (
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
OfflineModeIsEnabled,
):
return has_file_in_cache
try:
hf_raise_for_status(response)
return True
except GatedRepoError as e:
logger.error(e)
> raise EnvironmentError(
f"{path_or_repo} is a gated repository. Make sure to request access at "
f"https://huggingface.co/{path_or_repo} and pass a token having permission to this repo either by "
"logging in with `huggingface-cli login` or by passing `token=<your_token>`."
) from e
E OSError: mistralai/Mistral-7B-v0.1 is a gated repository. Make sure to request access at https://huggingface.co/mistralai/Mistral-7B-v0.1 and pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`.
/opt/ttforge-toolchain/venv/lib/python3.10/site-packages/transformers/utils/hub.py:680: OSError
Check failure on line 42 in forge/test/models/pytorch/text/opt/test_opt.py
github-actions / TT-Forge-FE Tests
test_opt.test_opt_causal_lm[no_device-facebook/opt-350m]
RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
info:
update_reshape_attr called for a non-reshape operation
backtrace:
--- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
--- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
--- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
--- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
--- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
Raw output
variant = 'facebook/opt-350m', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_opt_causal_lm(variant, test_device):
# Load tokenizer and model from HuggingFace
# Variants: "facebook/opt-125m", "facebook/opt-350m", "facebook/opt-1.3b"
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
config = OPTConfig.from_pretrained(variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = OPTConfig(**config_dict)
model = download_model(OPTForCausalLM.from_pretrained, variant, config=config)
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
tokenizer.pad_token = tokenizer.eos_token
# Input sample
prefix_text = "My name is Thomas and my main"
input_tokens = tokenizer(
prefix_text,
max_length=256,
padding="max_length",
truncation=True,
return_tensors="pt",
)
inputs = [input_tokens["input_ids"], input_tokens["attention_mask"]]
> compiled_model = forge.compile(
model,
sample_inputs=inputs,
module_name="pt_" + str(variant.split("/")[-1].replace("-", "_").replace(".", "_")) + "_causal_lm",
)
forge/test/models/pytorch/text/opt/test_opt.py:42:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_opt_350m_causal_lm], graph_name='pt_opt_350m_causal_lm', compiler_cfg=CompilerConfig...in_recompile=False, recompile_count=0, target_cycles_offset=0, forge_module=None, compiled_binary=None, attach_to=None)
def run_optimization_pass(context: CompileContext) -> CompileDepth:
"""
Runs optimization passes.
Parameters
----------
context: CompileContext
Compile context
Returns
-------
CompileDepth - next compile stage
"""
compiler_cfg = context.compiler_cfg
graph_name = context.graph_name
graph, intermediate_tensors = context.graph, context.intermediate_tensors
> run_optimization_graph_passes(graph)
E RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
E info:
E update_reshape_attr called for a non-reshape operation
E backtrace:
E --- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
E --- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
E --- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
E --- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
forge/forge/compile.py:785: RuntimeError
Check failure on line 42 in forge/test/models/pytorch/text/opt/test_opt.py
github-actions / TT-Forge-FE Tests
test_opt.test_opt_causal_lm[no_device-facebook/opt-1.3b]
RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
info:
update_reshape_attr called for a non-reshape operation
backtrace:
--- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
--- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
--- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
--- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
--- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
Raw output
variant = 'facebook/opt-1.3b', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_opt_causal_lm(variant, test_device):
# Load tokenizer and model from HuggingFace
# Variants: "facebook/opt-125m", "facebook/opt-350m", "facebook/opt-1.3b"
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
config = OPTConfig.from_pretrained(variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = OPTConfig(**config_dict)
model = download_model(OPTForCausalLM.from_pretrained, variant, config=config)
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
tokenizer.pad_token = tokenizer.eos_token
# Input sample
prefix_text = "My name is Thomas and my main"
input_tokens = tokenizer(
prefix_text,
max_length=256,
padding="max_length",
truncation=True,
return_tensors="pt",
)
inputs = [input_tokens["input_ids"], input_tokens["attention_mask"]]
> compiled_model = forge.compile(
model,
sample_inputs=inputs,
module_name="pt_" + str(variant.split("/")[-1].replace("-", "_").replace(".", "_")) + "_causal_lm",
)
forge/test/models/pytorch/text/opt/test_opt.py:42:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_opt_1_3b_causal_lm], graph_name='pt_opt_1_3b_causal_lm', compiler_cfg=CompilerConfig...in_recompile=False, recompile_count=0, target_cycles_offset=0, forge_module=None, compiled_binary=None, attach_to=None)
def run_optimization_pass(context: CompileContext) -> CompileDepth:
"""
Runs optimization passes.
Parameters
----------
context: CompileContext
Compile context
Returns
-------
CompileDepth - next compile stage
"""
compiler_cfg = context.compiler_cfg
graph_name = context.graph_name
graph, intermediate_tensors = context.graph, context.intermediate_tensors
> run_optimization_graph_passes(graph)
E RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
E info:
E update_reshape_attr called for a non-reshape operation
E backtrace:
E --- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
E --- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
E --- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
E --- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
forge/forge/compile.py:785: RuntimeError
Check failure on line 78 in forge/test/models/pytorch/text/opt/test_opt.py
github-actions / TT-Forge-FE Tests
test_opt.test_opt_qa[no_device-facebook/opt-125m]
RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
info:
update_reshape_attr called for a non-reshape operation
backtrace:
--- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
--- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
--- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
--- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
--- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
Raw output
variant = 'facebook/opt-125m', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_opt_qa(variant, test_device):
# Load tokenizer and model from HuggingFace
# Variants: "facebook/opt-125m", "facebook/opt-350m", "facebook/opt-1.3b"
# NOTE: These model variants are pre-trined only. They need to be fine-tuned
# on a downstream task. Code is for demonstration purposes only.
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
model = download_model(OPTForQuestionAnswering.from_pretrained, variant, torchscript=True)
# Load data sample
question, context = "Who was Jim Henson?", "Jim Henson was a nice puppet"
# Data preprocessing
input_tokens = tokenizer(
question,
context,
max_length=32,
padding="max_length",
truncation=True,
return_tensors="pt",
)
inputs = [input_tokens["input_ids"], input_tokens["attention_mask"]]
> compiled_model = forge.compile(
model,
sample_inputs=inputs,
module_name="pt_" + str(variant.split("/")[-1].replace("-", "_").replace(".", "_")) + "_qa",
)
forge/test/models/pytorch/text/opt/test_opt.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_opt_125m_qa], graph_name='pt_opt_125m_qa', compiler_cfg=CompilerConfig(enable_traini...in_recompile=False, recompile_count=0, target_cycles_offset=0, forge_module=None, compiled_binary=None, attach_to=None)
def run_optimization_pass(context: CompileContext) -> CompileDepth:
"""
Runs optimization passes.
Parameters
----------
context: CompileContext
Compile context
Returns
-------
CompileDepth - next compile stage
"""
compiler_cfg = context.compiler_cfg
graph_name = context.graph_name
graph, intermediate_tensors = context.graph, context.intermediate_tensors
> run_optimization_graph_passes(graph)
E RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
E info:
E update_reshape_attr called for a non-reshape operation
E backtrace:
E --- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
E --- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
E --- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
E --- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
forge/forge/compile.py:785: RuntimeError
Check failure on line 59 in forge/test/models/pytorch/text/phi3/test_phi3.py
github-actions / TT-Forge-FE Tests
test_phi3.test_phi3_causal_lm[no_device-microsoft/phi-3-mini-4k-instruct]
NotImplementedError: The following operators are not implemented: ['aten::bitwise_or_']
Raw output
variant = 'microsoft/phi-3-mini-4k-instruct', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants)
def test_phi3_causal_lm(variant, test_device):
# Configurations
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
# Phi3Config from pretrained variant, disable return_dict and caching.
config = Phi3Config.from_pretrained(variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = Phi3Config(**config_dict)
# Load tokenizer and model from HuggingFace
tokenizer = AutoTokenizer.from_pretrained(variant, return_tensors="pt", trust_remote_code=True)
tokenizer.add_special_tokens({"pad_token": "[PAD]"})
model = Phi3ForCausalLM.from_pretrained(variant, trust_remote_code=True, config=config)
model.eval()
# input_prompt
input_prompt = "Africa is an emerging economy because"
# Tokenize input
inputs = tokenizer(
input_prompt,
return_tensors="pt",
max_length=256,
pad_to_max_length=True,
truncation=True,
)
input_ids = inputs["input_ids"]
attn_mask = inputs["attention_mask"]
inputs = [input_ids, attn_mask]
> compiled_model = forge.compile(
model, sample_inputs=inputs, module_name="pt_" + str(variant.split("/")[-1].replace("-", "_")) + "_causal_lm"
)
forge/test/models/pytorch/text/phi3/test_phi3.py:59:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:634: in generate_initial_graph
module, module_inputs = convert_to_forge_module(
forge/forge/compile.py:973: in convert_to_forge_module
forge_module, dev_types, module_inputs = generate_forge_module(
forge/forge/tvm_to_python.py:2076: in generate_forge_module
module_writers, flattened_inputs = compile_tvm_to_python(
forge/forge/tvm_to_python.py:2168: in compile_tvm_to_python
json_graphs, flattened_pytorch_inputs, weights = load_tvm_graph(
third_party/tvm/python/tvm/contrib/forge_compile.py:106: in load_tvm_graph
json_graphs, flattened_inputs = compile_tvm_graph(inputs, module, compiler_cfg, graph_name=graph_name, input_names=input_names, path=path, verify_cfg=verify_cfg, framework=framework)
third_party/tvm/python/tvm/contrib/forge_compile.py:146: in compile_tvm_graph
json_graphs, inputs = compile_pytorch_for_forge(module, *inputs, graph_name=graph_name, compiler_cfg=compiler_cfg, verify_cfg=verify_cfg, input_names=input_names)
third_party/tvm/python/tvm/contrib/forge_compile.py:372: in compile_pytorch_for_forge
mod, params = tvm.relay.frontend.from_pytorch(traced_model, input_structure, do_convert_params=convert_params)
third_party/tvm/python/tvm/relay/frontend/pytorch.py:6077: in from_pytorch
converter.report_missing_conversion(op_names)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tvm.relay.frontend.pytorch.PyTorchOpConverter object at 0x7f4d7b1523b0>
op_names = {'aten::Int', 'aten::ScalarImplicit', 'aten::add', 'aten::add_', 'aten::arange', 'aten::bitwise_or_', ...}
def report_missing_conversion(self, op_names):
"""Check if all ops in an input graph are supported by TVM"""
known_ops = [
"prim::Constant",
"prim::GetAttr",
"prim::ListConstruct",
"prim::ListUnpack",
"prim::TupleConstruct",
"prim::TupleUnpack",
"prim::RaiseException",
"prim::If",
"prim::Loop",
"prim::DictConstruct",
"prim::dtype",
"prim::SetAttr",
"prim::unchecked_cast"
]
known_ops += list(self.convert_map.keys())
known_ops += list(qnn_torch.convert_map.keys())
missing = []
for op_name in op_names:
# Also take care of in-place variant ops like aten::relu_
if op_name not in known_ops and not (
op_name.endswith("_") and op_name[:-1] in known_ops
):
missing.append(op_name)
if missing:
msg = f"The following operators are not implemented: {missing}"
> raise NotImplementedError(msg)
E NotImplementedError: The following operators are not implemented: ['aten::bitwise_or_']
third_party/tvm/python/tvm/relay/frontend/pytorch.py:4956: NotImplementedError
Check failure on line 41 in forge/test/models/pytorch/text/xglm/test_xglm.py
github-actions / TT-Forge-FE Tests
test_xglm.test_xglm_causal_lm[no_device-facebook/xglm-1.7B]
RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
info:
update_reshape_attr called for a non-reshape operation
backtrace:
--- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
--- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
--- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
--- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
--- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
--- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
Raw output
variant = 'facebook/xglm-1.7B', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_xglm_causal_lm(variant, test_device):
# Set Forge configuration parameters
compiler_cfg = forge.config._get_global_compiler_config()
compiler_cfg.compile_depth = forge.CompileDepth.SPLIT_GRAPH
config = XGLMConfig.from_pretrained(variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = XGLMConfig(**config_dict)
model = download_model(XGLMForCausalLM.from_pretrained, variant, config=config)
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
tokenizer.pad_token = tokenizer.eos_token
# Input sample
prefix_text = "My name is Thomas and my main"
input_tokens = tokenizer(
prefix_text,
max_length=256,
padding="max_length",
truncation=True,
return_tensors="pt",
)
inputs = [input_tokens["input_ids"], input_tokens["attention_mask"]]
> compiled_model = forge.compile(
model, sample_inputs=inputs, module_name="pt_" + str(variant.split("/")[-1].replace("-", "_").replace(".", "_"))
)
forge/test/models/pytorch/text/xglm/test_xglm.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_xglm_1_7B], graph_name='pt_xglm_1_7B', compiler_cfg=CompilerConfig(enable_training=F...in_recompile=False, recompile_count=0, target_cycles_offset=0, forge_module=None, compiled_binary=None, attach_to=None)
def run_optimization_pass(context: CompileContext) -> CompileDepth:
"""
Runs optimization passes.
Parameters
----------
context: CompileContext
Compile context
Returns
-------
CompileDepth - next compile stage
"""
compiler_cfg = context.compiler_cfg
graph_name = context.graph_name
graph, intermediate_tensors = context.graph, context.intermediate_tensors
> run_optimization_graph_passes(graph)
E RuntimeError: TT_ASSERT @ /__w/tt-forge-fe/tt-forge-fe/forge/csrc/passes/commute_utils.cpp:1105: reshape->op_name() == "reshape"
E info:
E update_reshape_attr called for a non-reshape operation
E backtrace:
E --- tt::passes::update_reshape_attr(tt::graphlib::OpNode*, tt::graphlib::Shape)
E --- tt::passes::commute_and_bypass(tt::graphlib::Graph*, std::vector<tt::graphlib::Node*, std::allocator<tt::graphlib::Node*> > const&)
E --- tt::passes::erase_inverse_ops(tt::graphlib::Graph*)
E --- tt::run_optimization_graph_passes(tt::graphlib::Graph*)
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xfc639) [0x7f4dca9c1639]
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xdf8f5) [0x7f4dca9a48f5]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x18b282) [0x555dce3f2282]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5c7d) [0x555dce3e1f4d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x555dce400882]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x818) [0x555dce3dcae8]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x555dce40081b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x555dce3e7dbd]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x555dce3fcd4c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29e054) [0x555dce505054]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x555dce3e8b4b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x671a) [0x555dce3e29ea]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6d2) [0x555dce3dc9a2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2c89) [0x555dce3def59]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x1a22) [0x555dce3ddcf2]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x555dce3f2aec]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x58aa) [0x555dce3e1b7a]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x198be1) [0x555dce3ffbe1]
forge/forge/compile.py:785: RuntimeError
Check failure on line 38 in forge/test/models/pytorch/timeseries/nbeats/test_nbeats.py
github-actions / TT-Forge-FE Tests
test_nbeats.test_nbeats_with_seasonality_basis[no_device]
RuntimeError: Tensor 4 - stride mismatch: expected [24, 1], got [1, 12]
Raw output
test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
# @pytest.mark.xfail(reason="Failing with pcc=0.82")
def test_nbeats_with_seasonality_basis(test_device):
compiler_cfg = forge.config._get_global_compiler_config()
x, x_mask = get_electricity_dataset_input()
pytorch_model = NBeatsWithSeasonalityBasis(
input_size=72,
output_size=24,
num_of_harmonics=1,
stacks=30,
layers=4,
layer_size=2048,
)
pytorch_model.eval()
compiled_model = forge.compile(pytorch_model, sample_inputs=[x, x_mask], module_name="nbeats_seasonality")
inputs = [x, x_mask]
> co_out = compiled_model(*inputs)
forge/test/models/pytorch/timeseries/nbeats/test_nbeats.py:38:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <forge.compiled_graph_state.CompiledModel object at 0x7f4e07a96bf0>
inputs = (tensor([[[[ 160.50679, 156.32184, 146.39499, ..., 264.03345, 169.91641, 163.64682],
[ 79.53951, 85...[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.]]]]))
inputs_and_parameters = [tensor([[[[ 160.50679, 156.32184, 146.39499, ..., 264.03345, 169.91641, 163.64682],
[ 79.53951, 85...0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), ...]
def __call__(self, *inputs: AnyTensor) -> List[torch.Tensor]:
"""
Run inference on the compiled model.
Parameters
----------
inputs: [Tensor, ...]
Input tensors
Returns
-------
List[Tensor]
Output tensors
"""
self.inputs = [*inputs]
inputs_and_parameters = [
*inputs,
*self.fwd_compiled_graph_state.get_ordered_constant_tensors(),
*self.fwd_compiled_graph_state.get_ordered_parameter_tensors(),
]
if any([not isinstance(t, torch.Tensor) for t in inputs_and_parameters]):
logger.info("Converting inputs and parameters to PyTorch tensors...")
inputs_and_parameters = to_pt_tensors(inputs_and_parameters)
if self.training() and isinstance(self.framework_module, PyTorchModule):
for name, param in self.framework_module.module.named_parameters():
if param.requires_grad:
our_tensor = self.fwd_compiled_graph_state.get_parameter_tensor(name)
# NOTE: for parameters that require gradients, we want to share the same tensor with the PyTorch module.
# This is because we want to be able to optimize the parameters both on the device (through our runtime)
# and via the torch optimizers. So this ensures that whichever side updates the parameter value, the other side can see the change.
#
# This could change in the future, but for now ensure that our premise is correct.
assert param is our_tensor
logger.info(
f"Running model {self.framework_module.get_name()} {self.fwd_compiled_graph_state.graph.get_name()} on device..."
)
> all_outputs = run_binary(self.compiled_binary, int(ProgramId.FORWARD), inputs_and_parameters)
E RuntimeError: Tensor 4 - stride mismatch: expected [24, 1], got [1, 12]
forge/forge/compiled_graph_state.py:273: RuntimeError
Check failure on line 104 in forge/test/models/pytorch/vision/vovnet/test_vovnet.py
github-actions / TT-Forge-FE Tests
test_vovnet.test_vovnet_timm_pytorch[no_device-ese_vovnet39b]
AssertionError: Eltwise binary ops must have the same shape in both inputs, or one operand must be 1 wide to broadcast: [1, 1, 7, 7168] vs [1, 1, 7, 7]
Raw output
variant = 'ese_vovnet39b', test_device = None
@pytest.mark.nightly
@pytest.mark.model_analysis
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_vovnet_timm_pytorch(variant, test_device):
model, inputs, _ = generate_model_vovnet_imgcls_timm_pytorch(
test_device,
variant,
)
> compiled_model = forge.compile(model, sample_inputs=[inputs[0]], module_name=f"pt_{variant}")
forge/test/models/pytorch/vision/vovnet/test_vovnet.py:104:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:250: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:292: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:785: in run_optimization_pass
run_optimization_graph_passes(graph)
forge/forge/op/eval/forge/__init__.py:217: in <lambda>
return lambda *inputs: module_or_class.shape(op_type.op, op_type.attr, *inputs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
type = 'multiply', attr = [], ops = [[1, 1, 7, 7168], [1, 1, 7, 7]]
def shape(type, attr, ops) -> Tuple[Tuple, List]:
assert len(ops) == 2, "Eltwise binary should have two inputs"
if type == "binary_stack":
dim = attr[0]
assert ops[0] == ops[1]
output_shape = list(ops[0])
output_shape[dim] *= 2
return tuple(output_shape), []
assert len(attr) == 0, "Eltwise binary should have no attributes"
broadcast = []
output_shape = []
ops[0] = list(ops[0])
while len(ops[0]) < len(ops[1]):
ops[0] = [1] + ops[0]
ops[1] = list(ops[1])
while len(ops[1]) < len(ops[0]):
ops[1] = [1] + ops[1]
for dim in range(len(ops[0])):
if ops[0][dim] != ops[1][dim]:
if ops[1][dim] == 1:
broadcast.append((1, dim - len(ops[1]), ops[0][dim])) # Convert to negative indexing
output_shape.append(ops[0][dim])
else:
assert (
> ops[0][dim] == 1
), f"Eltwise binary ops must have the same shape in both inputs, or one operand must be 1 wide to broadcast: {ops[0]} vs {ops[1]}"
E AssertionError: Eltwise binary ops must have the same shape in both inputs, or one operand must be 1 wide to broadcast: [1, 1, 7, 7168] vs [1, 1, 7, 7]
forge/forge/op/eval/forge/eltwise_binary.py:91: AssertionError
Check failure on line 1 in forge/test/mlir/llama/test_llama_inference.py
github-actions / TT-Forge-FE Tests
test_llama_inference.test_llama_inference[openlm-research/open_llama_3b]
[XPASS(strict)]
Raw output
[XPASS(strict)]