a llm/vlm usage case
Does TorchView support analysis of large models, such as qwen2.5-7b
Torchview's support does not depend on the size of the model. It essentially records the torch functions during forward propogation.
There is a few cases where the network might be cut off (e.g. when you insert numpy op inside the network, by torch.tensor -> numpy.array -> numpy operation -> torch.tensor). So, unless this is done in the model, the model should be supported.
model_id = "models/Qwen/Qwen2.5-0.5B-Instruct"
device = 'cpu'
dtype = 'float16'
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.eos_token
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt").to('cpu')
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=getattr(torch, dtype),
device_map=device,
trust_remote_code=True
)
model_graph1 = draw_graph(
model, input_data=inputs, graph_name='Qwen2.5-0.5B-Instruct', depth=3, directory='tests1',
save_graph=True, expand_nested=True,
hide_module_functions=True, hide_inner_tensors=True, roll=True, collect_attributes=False
)
model_graph1.visual_graph
- test llm model is ok
- Do you have plans to add features such as flops, parameters, MACs, read&write @mert-kurttutan
* test llm model is ok * Do you have plans to add features such as flops, parameters, MACs, read&write [@mert-kurttutan](https://github.com/mert-kurttutan)
Not in the near future. But for a quick solution you can also check torchinfo package that has this implemented.
I am willing to help if there is any PR for this feature.