-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cupybackend, mixed backends #37
Open
danlkv
wants to merge
59
commits into
dev
Choose a base branch
from
cupybackend
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 26 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
3dc26db
add cutensor backend
e7ef12b
add experiment group arg
149e340
update experiment group
4477818
update fixed size tensor contraction
b2f4c71
update measurement for tncontract
7bfb3fe
update byte calculation
f765aeb
restructure and change torch gen_tensor from cpu to gpu
sansangela 3ac3a76
restructure and change torch gen_tensor from cpu to gpu
a0e73e7
Merge branch 'matmul' of https://github.com/DaniloZZZ/QTensor into ma…
sansangela 5a60560
add bridge
sansangela c92f7e7
random generate tensors
sansangela 974a158
add benchmark functions for matmul and tncontract
sansangela 0660314
remove get_operation
sansangela 2d3964b
add random generate tensor
sansangela 4659a7b
update ggen_sizes
sansangela 0df2083
add random tensor transpose
sansangela 7a8b263
add test
sansangela 5c6c28a
update args init
sansangela bf01bd3
add transpose backend
sansangela e44b1eb
add transposed backends
sansangela 33049dc
update timing
sansangela dc16ef7
add transpose backend & update timing
sansangela 42c65bb
update dtype casting
sansangela 1a88493
Mixed BE Implemented
huaxuan250 d56013d
Modified Json Format
huaxuan250 eccbb37
Higher Threshold and Complete
huaxuan250 41b17a5
Adding Numpy-Torch Conpatibility
huaxuan250 f96f695
Adding Watershed Control
huaxuan250 fafb4f0
Accurate Width Calculation
huaxuan250 ddbfa59
Auto Threshold Optimization
huaxuan250 731a05b
Basic Performance Probing using 12 4 3
huaxuan250 c3c6d90
Bris Benchmarking by Bucket
huaxuan250 bdce309
Updated Parameter
huaxuan250 eaaabbf
merged backends
sansangela 1889e3b
Mixed Merged Working
huaxuan250 76ea8ff
Name Change
huaxuan250 53635bb
QAOA Mix Merge Operational
huaxuan250 31c1ed7
String Parsing Fixed
huaxuan250 0bf7215
Bucket Iso
huaxuan250 747b143
Iso Done
huaxuan250 74f3a33
Probing Done
huaxuan250 32e9b70
Probing Result on V100
huaxuan250 d11c067
Fitting Done
huaxuan250 1c77a20
Merge branch 'cupybackend' of https://github.com/DaniloZZZ/QTensor in…
huaxuan250 b07d25d
Updated Result
huaxuan250 c578a79
1.12 Result
huaxuan250 075dce1
Probing Test Metrics
huaxuan250 a974fa9
Merge branch 'cupybackend' of https://github.com/DaniloZZZ/QTensor in…
huaxuan250 1fb42f7
Probing Done with Tests
huaxuan250 9f72abe
load detection
huaxuan250 c78e4fb
Load Detect Focus on maxwidth
huaxuan250 d0600e8
Updated Thr control
huaxuan250 3b02dd2
Basic Util Completes
huaxuan250 eaceb1d
CPU UTIL DONE FOR BASIC PROBING
huaxuan250 b3015b6
Example Code Done
huaxuan250 fb359d2
Change to Timing
huaxuan250 cfb320b
test script for merged backend
danlkv 87b3a37
rename gpu_mix_test file
danlkv 593b1d9
add notebook with tensor compression tests
danlkv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from qtensor.contraction_backends import ContractionBackend | ||
""" | ||
class MixedBe(ConBE): | ||
be1: cpu_be | ||
be2: gpu_be | ||
|
||
def get_sliced_bucket(): | ||
normal slicing | ||
either use be1_get_sliuced or naive implementation | ||
np.array for convinience | ||
|
||
def process_bucket(): | ||
- Check input bucket width | ||
- If larger than 8, use gpu_be.process(bucket) | ||
- Else, use less than 8, use cpu_be.process(bucket) | ||
|
||
def get_result_data(): | ||
- always use gpu_be's get_result | ||
- so that the gpu_be shall handle the gpu-cpu transfer all the time | ||
|
||
""" | ||
|
||
|
||
''' | ||
Input: Array of either (indices) or a tensor | ||
If a tensor, use t.indices for conversion | ||
''' | ||
def bucketWidth(bucket): | ||
bucket_width = 0 | ||
for tensor in bucket: | ||
tensor_len = 0 | ||
if tensor is tuple: | ||
tensor_len = len(tensor) | ||
if tensor_len > bucket_width: | ||
bucket_width = tensor_len | ||
else: | ||
tensor_len = len(tensor.indices) | ||
if tensor_len > bucket_width: | ||
bucket_width = tensor_len | ||
return bucket_width | ||
|
||
|
||
|
||
|
||
''' | ||
I/O: Actual BE Objects -> Wrapped Class | ||
''' | ||
|
||
class MixBackend(ContractionBackend): | ||
|
||
def __init__(self, cpu_be, gpu_be): | ||
self.cpu_be = cpu_be | ||
self.gpu_be = gpu_be | ||
|
||
def process_bucket(self, bucket, no_sum = False): | ||
bucket_width = bucketWidth(bucket) | ||
if bucket_width >= 11: | ||
danlkv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#print("In GPU") | ||
return self.gpu_be.process_bucket(bucket, no_sum) | ||
else: | ||
return self.cpu_be.process_bucket(bucket, no_sum) | ||
|
||
def get_sliced_buckets(self, buckets, data_dict, slice_dict): | ||
return self.cpu_be.get_sliced_buckets(buckets, data_dict, slice_dict) | ||
|
||
def get_result_data(self, result): | ||
return self.gpu_be.get_result_data(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,16 @@ def __init__(self): | |
#self.status_bar = tqdm(desc='Current status', position=3, bar_format='{desc}') | ||
|
||
def process_bucket(self, bucket, no_sum=False): | ||
''' | ||
TODO: Preprocess the bucket to make sure the all data are in numpy format | ||
''' | ||
for tensor in bucket: | ||
if not isinstance(tensor._data, np.ndarray): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to do |
||
try: | ||
tensor._data = tensor._data.cpu().numpy() | ||
except: | ||
pass | ||
|
||
res = np_framework.process_bucket_np(bucket, no_sum=no_sum) | ||
return res | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in class name