OpenABC
OpenABC copied to clipboard
Looking for Bulls-Eye method
Thanks for your excellent work and building of community.
I ' m reading Too Big to Fail? Active Few-shot Learning Guided Logic Synthesis, which says that We have made our code and associated dataset available to the community at: https://github.com/NYU-MLDA/OpenABC. The method in this paper is called as "Bulls-Eye"
I wonder where can I get codes and models about Bulls-Eye method?
Hi @sun123-cmd,
We have used the baseline models and fine-tuned models of OpenABC-D as the synthesis evaluator of simulated annealing for the Bulls-eye paper. The process to train the model and the architecture is present in this repository. Only the simulated annealing wrapper is not present in this repository.
The dataset is currently under migration at NYU server and it's taking some time as I'm currently maintaining this along with NYU-IT team support during weekends. We are trying our best to make it online soon.
Hi @sun123-cmd,
We have used the baseline models and fine-tuned models of OpenABC-D as the synthesis evaluator of simulated annealing for the Bulls-eye paper. The process to train the model and the architecture is present in this repository. Only the simulated annealing wrapper is not present in this repository.
The dataset is currently under migration at NYU server and it's taking some time as I'm currently maintaining this along with NYU-IT team support during weekends. We are trying our best to make it online soon.
Hello, I meet a new problem:
In OpenABC/datagen/utilities/andAIG2Graphml.py:
line 185 with:
if(benchDict[node][1] == gateType["AND"]):
In the init part, only with nodeType and edgeType but gateType, which lead to:
Traceback (most recent call last):
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/datagen/utilities/andAIG2Graphml.py", line 229, in <module>
main()
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/datagen/utilities/andAIG2Graphml.py", line 226, in main
writeBenchFileFromGML(list(nxCktDAG.nodes),nx.get_node_attributes(nxCktDAG,'node_id'))
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/datagen/utilities/andAIG2Graphml.py", line 191, in writeBenchFileFromGML
if (benchDict[node][1] == gateType["AND"]):
NameError: name 'gateType' is not defined. Did you mean: 'nodeType'?
I wonder how to fix it? Thank you~
Hi @sun123-cmd,
I wrote this function for checking purpose in case the graph ml file generated from AIG bench is recoverable and validated to original bench file. However, the function is deprecated and I believe shouldn't be called while you run the utility andAIG2Graphml.py.
Is your purpose to recover AIG in graph ml format back to bench? If that's the case, I may look into this. At the outset it looks like, if you define a dictionary of gateType = {"BUFF":0, "NOT":1 , "AND":2} should solve the purpose, but I have to check at its validity.
Like I said, it is not a mandatory function for andAIG2Graphml and was written for validation purpose during development phase to check the graphml generated matches the original andAIG bench file if I'm given the graphml. Let me know if you need it for similar purpose and I can look over this.
Hi @sun123-cmd,
I wrote this function for checking purpose in case the graph ml file generated from AIG bench is recoverable and validated to original bench file. However, the function is deprecated and I believe shouldn't be called while you run the utility andAIG2Graphml.py.
Is your purpose to recover AIG in graph ml format back to bench? If that's the case, I may look into this. At the outset it looks like, if you define a dictionary of gateType = {"BUFF":0, "NOT":1 , "AND":2} should solve the purpose, but I have to check at its validity.
Like I said, it is not a mandatory function for andAIG2Graphml and was written for validation purpose during development phase to check the graphml generated matches the original andAIG bench file if I'm given the graphml. Let me know if you need it for similar purpose and I can look over this.
Thanks so much for your reply!
I want to predict my own circuit' s QoR, so I think it' s necessary to get graphml AIG and convert it to .pt format for the QoR predicting model. While converting .BENCH file to graphml, I called this function for writing .graphml format file. Thus I called writeBenchFileFromGML function.
Do you think my operation is correct? How can I predict the QoR of my own circuit?
What is the starting circuit representation you're working with?
The openABC-D flow assumes the following flow:
AIG (in bench format) --> Graphml --> .pt format --> Regression --> Predict QoR
For this flow, you need to first run andAIG2graphml.py followed by PyGDataAIG.py to convert each graphml to .pt format. You can tweak PyGDataAIG.py to consume your labels and generate .pt format which can be used with any pytorch based GNN frameworks.
For this flow, you need to first run andAIG2graphml.py followed by PyGDataAIG.py to convert each graphml to .pt format. You can tweak PyGDataAIG.py to consume your labels and generate .pt format which can be used with any pytorch based GNN frameworks.
Thanks so much! I will try your method~
To get AIG in the bench format, read the circuit in any format in ABC, strash it, and dump it in bench format. The default format for writing bench is in LUT format, but you have to use a toggle flag supported in ABC, via which you can dump the circuit in bench format having only AND, NOT and BUFF gates.
You can use that bench output and follow the openABC-D flow to generate the pt datapoints.
Alternatively, if you can invoke ABC via python wrapper, you can refer to ABC-RL work (https://github.com/NYU-MLDA/ABC-RL/blob/main/ABC-RL_ICLR/src/LogicSynthesisEnv.py#L105), which is simple and better way of directly extracting data from ABC, convert it into a dictionary, and generate a pytorch data point. This bypass all the steps done in OpenABC-D (convert from bench to grapml to pytorch data point).
What is the starting circuit representation you're working with?
The openABC-D flow assumes the following flow:
AIG (in bench format) --> Graphml --> .pt format --> Regression --> Predict QoR
For this flow, you need to first run andAIG2graphml.py followed by PyGDataAIG.py to convert each graphml to .pt format. You can tweak PyGDataAIG.py to consume your labels and generate .pt format which can be used with any pytorch based GNN frameworks.
Hi!
I get .pt file by PyGDataAIG.py as:
├── processed
│ ├── pre_filter.pt
│ ├── pre_transform.pt
Following the format at OpenABC/OPENABC2_DATASET/processed, I zip them as:
├── processed
│ ├── pre_filter.pt
│ ├── pre_filter.pt.zip
│ ├── pre_transform.pt
│ └── pre_transform.pt.zip
Then I copy these .zip files to OpenABC/OPENABC2_DATASET/processed and add the two .zip file in OpenABC/OPENABC2_DATASET/test_data_set1.csv :
fileName
pre_filter.pt.zip
pre_transform.pt.zip
dynamic_node_syn1093_step0.pt.zip
...
In this way, can I get final QoR predict result of my own circuit?
Like I just did, errors:
/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/pandas/plotting/_matplotlib/core.py:509: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
fig = self.plt.figure(figsize=self.figsize)
Traceback (most recent call last):
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/models/qor/SynthNetV1/evaluate.py", line 161, in <module>
main()
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/models/qor/SynthNetV1/evaluate.py", line 136, in main
testMSE,testBatchData = evaluate_plot(model, device, test_dl)
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/models/qor/SynthNetV1/evaluate.py", line 48, in evaluate_plot
for _, batch in enumerate(tqdm(dataloader, desc="Iteration",file=sys.stdout)):
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/tqdm/std.py", line 1181, in __iter__
for obj in iterable:
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 681, in __next__
data = self._next_data()
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1356, in _next_data
return self._process_data(data)
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1402, in _process_data
data.reraise()
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/_utils.py", line 461, in reraise
raise exception
AttributeError: Caught AttributeError in DataLoader worker process 2.
Original Traceback (most recent call last):
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch_geometric/data/dataset.py", line 188, in __getitem__
data = data if self.transform is None else self.transform(data)
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torchvision/transforms/transforms.py", line 94, in __call__
img = t(img)
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/models/qor/SynthNetV1/evaluate.py", line 111, in <lambda>
testDS.transform = transforms.Compose([lambda data: addNormalizedTargets(data,targetStats,meanVarTargetDict,targetVar=targetLbl)])
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/models/qor/SynthNetV1/utils.py", line 27, in addNormalizedTargets
sid = data.synID[0]
AttributeError: 'str' object has no attribute 'synID'
After that I try to modify both train_data_set1.csv and test_data_set1.csv, but failed to fix this problem:
AttributeError: Caught AttributeError in DataLoader worker process 2.
Original Traceback (most recent call last):
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torch_geometric/data/dataset.py", line 188, in __getitem__
data = data if self.transform is None else self.transform(data)
File "/home/hs/disk1/miniconda3/envs/openabc-sun/lib/python3.10/site-packages/torchvision/transforms/transforms.py", line 94, in __call__
img = t(img)
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/models/qor/SynthNetV1/evaluate.py", line 111, in <lambda>
testDS.transform = transforms.Compose([lambda data: addNormalizedTargets(data,targetStats,meanVarTargetDict,targetVar=targetLbl)])
File "/home/hs/disk1/sunwenhao/eda_attack/OpenABC/models/qor/SynthNetV1/utils.py", line 27, in addNormalizedTargets
sid = data.synID[0]
AttributeError: 'str' object has no attribute 'synID'
I wonder if my evluate method is wrong?